C++ Libraries

K

Kieran Simpson

I have written a set of C++ classes that I would like to compile into a
library file, that then can be linked into other projects so I can use those
classes. The only thing is that I am not to sure how make the classes into
a library, and then how to consequently link them into my other projects.
Can anybody point me in the right direction please. I want to statically
link them so that the code is compiled into the app, because I don't want to
mess with DLL's

Thanks
 
J

Josephine Schafer

Kieran Simpson said:
I have written a set of C++ classes that I would like to compile into a
library file, that then can be linked into other projects so I can use those
classes. The only thing is that I am not to sure how make the classes into
a library, and then how to consequently link them into my other projects.
Can anybody point me in the right direction please. I want to statically
link them so that the code is compiled into the app, because I don't want to
mess with DLL's

Actually this is platform specific.

I can talk about Windows platform though -
Write your functions, compile the source files to object files. Then
instead of linking, use lib.exe to create a library file.
 
D

Dhruv

I have written a set of C++ classes that I would like to compile into a
library file, that then can be linked into other projects so I can use those
classes. The only thing is that I am not to sure how make the classes into
a library, and then how to consequently link them into my other projects.
Can anybody point me in the right direction please. I want to statically
link them so that the code is compiled into the app, because I don't want to
mess with DLL's

Thanks

Only compile the file, do not link it. Then, link the object files (.obj
on windows, or .o on UNIX), and you have the binary ready. You will have
to put the declarations in the headers (.h files), while definitions in
the .cpp files and compile those .cpp files.

-Dhruv.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,764
Messages
2,569,567
Members
45,041
Latest member
RomeoFarnh

Latest Threads

Top