Programming Forums

Programming Forums (http://www.programmingforums.org/forumindex.php)
-   C++ (http://www.programmingforums.org/forum15.html)
-   -   Shared Objects in Linux (http://www.programmingforums.org/showthread.php?t=15229)

Harakim Feb 21st, 2008 7:32 PM

Shared Objects in Linux
 
This is what I have to do:
gcc -o SPEThreadTest spu_hello_cef.o SPEThreadTest.cpp -lSPEException -lSPEThread -lThread -lpthread -lspe2

This is what I want:
gcc -o SPEThreadTest spu_hello_cef.o SPEThreadTest.cpp -lSPEThread

However, the only reason I have to link pthread, SPEException, spe2, and Thread are because I am linking to SPEThread.

Since I made the SPEThread library (and some of the other libraries), is there a way to make it automatically link in those other libraries, so the command line doesn't start getting terribly long?

Game_Ender Feb 21st, 2008 9:58 PM

Re: Shared Objects in Linux
 
I am not sure on this but if you are only using functions from SPEThread and they are all shared libraries, you should just be able to link SPEThread in. If they are static libraries there is no way around it.

Also you should consider a build system like SCons or CMake and don't worry about the length of the command line.

Infinite Recursion Feb 22nd, 2008 8:37 AM

Re: Shared Objects in Linux
 
if the length of the compile parameters is a problem... then write an alias for it.... or as Game_Ender suggests, use a make file.

Seif Feb 22nd, 2008 2:58 PM

Re: Shared Objects in Linux
 
If the shared objects in SPEException, lSPEThread, lThread, lpthread, spe2 libraries should all belong together then use the gnu program ar to merge em all together into one static library.

Harakim Feb 22nd, 2008 3:29 PM

Re: Shared Objects in Linux
 
The reason I want to shrink this command is many people will be using this library in the future and I don't want to make it any more confusing than it has to be.

Is there a tool that you know that I could use to merge them into one library or can I use gcc?

grumpy Feb 22nd, 2008 4:12 PM

Re: Shared Objects in Linux
 
It's not usually a good idea to merge third-party libraries into one library: there are often all sorts of copyright constraints making it illegal.

It would be easier to simply supply a sample makefile that executes the required commands to link. Then all the people using your library need to edit that makefile and then type "make". If you really want to make it easier, provide a script that automates creating the makefile

Any developer with any competence will be able to accept the need to add libraries to the command line when linking, or the need to edit a sample build script.

Seif Feb 23rd, 2008 4:04 AM

Re: Shared Objects in Linux
 
For the record... I wasn't saying it was a good idea. I was just making it known that library editting is possible using the ar, which should be part of the gnu toolchain. :)


All times are GMT -5. The time now is 4:16 AM.

Powered by vBulletin® Version 3.7.0, Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
Copyright ©2007 DaniWeb® LLC