Sign in to follow this  
DpakoH

[SOLVED c++] making a library ?

Recommended Posts

hi all, i am writing a simple graphical application (based on gtk+) and i have couple of classes handling data management and drawing data (e.g. points in XY coord system).i want to create a simple library from these classes so it can be used not only for this certain project. i am wondering how can i do that ? it is supposed to be a linux library, (on windows i could manage to do smth with vs2008 but i am not very profound of linux) and any help will be greatly appreciated. best, y. [Edited by - DpakoH on July 31, 2008 4:37:08 AM]

Share this post


Link to post
Share on other sites
Here is what you do for a static library:

  1. Compile all of your code to object files:
    gcc -c file1.c
    gcc -c file2.c
    ...

  2. Create an archive containing all of the object code:
    ar rcs libraryname.a file1.o file2.o ...

  3. Create an index for the library:
    ranlib libraryname.a

  4. Link new code to your library:
    gcc libraryname.a code_that_uses_lib.c



That should at least get you started.

Share this post


Link to post
Share on other sites
thx for the answers,
i've been away for some time and i just checked this tread again.
again thx for the help , and i see the this is the way to create a static library (or maybe i am wrong again). i will try that but i think it will work.


best,
y.

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

Sign in to follow this