Re: Building a Library (Code, not Books) Of Classes



Jason wrote:
If I am able to make the above into it's own library, would it be as
simple to use it in my main program just by using a

#include <mymenulibrary.h>?

Yes. First of all, you have to create dynamically loaded library (on M$ Win), or shared object library (*.so) on linux. Next, make new direcotiry in /usr/inlude for it, and copy *.so and *.h there. The last thing is to add "-lNAMEOFYOURLIBRARY" do gcc command line. And, remember to do ldconfig, it can be usefull. Then include e.g <mylib/mylib.h> to your application. That's all :)

On linux, to make *.so:
1. Compile all cpp

g++ -Wno-deprecated -c -fPIC file1.cpp file2.cpp


2. Make *so

g++ -shared -fPIC -o libNAME.so file1.o file2.o

PS. Remember, that NAMEOFYOURLIBRARY in gcc command line shoud be name of your lib WITHOUT "lib", for example, if your lib name is libsupertoolkit, you should add -lsupertoolkit.

Good luck,
taheto




[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]