Re: [Dev-C++] implementation .o procedure
Open Source C & C++ IDE for Windows
Brought to you by:
claplace
|
From: Santiago <sa...@ho...> - 2002-10-13 18:28:29
|
Hi, I only have DevC++, I don't know if it's possible to use the commands gcc -c a.c and gcc -c b.c in DevC++. Anyway I'm still stuck with the first part of the process, creating a .o object file out of the implementation of a class I made. These are my questions again: 1- How do I create an object file using the implementation I created? I want someone else to use this object file so I don't have to give them my implementation code. 2- Once the object file is created, how does the user use it to compile his/her own client code? how does the user refer to the file in his/her client code by using #include "myClass.h", or "myClass.o", or both, or some other way? I'll play class creator and main creator(user) myself using DevC++ for testing purposes. I'll appreciate your help! Santiago ----- Original Message ----- From: "Elizabeth Barham" <sog...@ya...> To: "Santiago" <sa...@ho...> Sent: Monday, October 07, 2002 11:02 AM Subject: Re: [Dev-C++] implementation .o procedure > "Santiago" <sa...@ho...> writes: > > > Where do I add it? > > as an #include in *my* code? > > It is when you link the executable. > > If you have two source files, a.c and b.c, and compile them like: > > gcc -c a.c > gcc -c b.c > > you will have two files, a.o and b.o. Then it is a matter of linking > them to produce the end file: > > gcc -o test.exe a.o b.o > > The #include is in your code because that defines the interface to > myClass, which is all ready compiled and in object code format > in myClass.o. > > So to produce the executable, you'll need to do something like: > > gcc -o test.exe a.o b.o myClass.o > > In Dev-C++, you can make this occur when building using the: > > Project > Project Options > > dialog and placing "myClass.o" in the field labeled, "Linker > options/Optional Libs or Object Files" - the key words being "Object > Files" in this case (files that have the .o extension). > > Elizabeth > |