I'm having problems statically linking my Poco libraries.
Red Hat Linux 5.8
GCC version 4.1.2 20080704 (RedHat 4.1.2-52)
IDE Vim (also tried NetBeans using my own Makefile with same result)
I static compiled my Poco libraries with this configuration:
./configure --static --no-tests --no-samples --omit=NetSSL_OpenSSL,Crypto,Data/MySQL
and it completed without errors.
I now have the .a libraries. Using the two step compile/link, here are some of the linker commands that I have tried:
g++ -L/usr/local/lib *.o -o CraDaemon -lodbc -Wl,-Bstatic -lPocoData -lPocoDataODBC cannot find lgcc_s. Yes it exists (.so version) and all symbolic links are good. --verbose shows that its looking for the .a version. To prevent this, I added dynamic at the end like this:
g++ -L/usr/local/lib *.o -o CraDaemon -lodbc -Wl,-Bstatic -lPocoData -lPocoDataODBC -Wl,-Bdynamic This ensures only the Poco libraries are static linked and the system libs are dynamically linked. This resulted in the complete list of Poco references as undefined.
g++ -L/usr/local/lib *.o -lodbc -Wl,-Bstatic -lPocoData -lPocoDataODBC -lPocoFoundation -Wl,-Bdynamic Added -lPocoFoundation just because I noticed some of the undefined ref were defined here... still get all poco references as undefined
g++ -L/usr/local/lib *.o -static -lodbc -lPocoData -lPocoDataODBC using -static instead of -Wl,-Bstatic appeared to work but it dynamically linked the Poco Libraries instead of static linking them ????
g++ -L/usr/local/lib *.o -lodbc -lPocoData -lPocoDataODBC This is my standard link command that works to dynamically link everything. I tried it again after renaming the shared Poco libraries (forcing the use of .a versions) but this also resulted in the full list of undefined Poco references
I also tried shifting the order of everything in the link command, I must have tried every combination.
I have narrowed the problem down to the lPocoDataODBC library. I can link all others statically like this but when I include -lPocoDataODBC, I get unresolved references.
g++ -L/usr/local/lib -Wl,-Bstatic -lodbc -lPocoData -Wl,-Bdynamic -lPocoDataODBC ---> works only because I'm not statically linking that last library
NOTE* I can add -lPocoFoundation, -lgcc, and -lstdc++ to the static linked side and it still links without error but does not help me statically link that last library (-lPocoDataODBC).
The link command in the first update above only appears to statically link all but -lPocoDataODBC. I found that when a library (-lPocoDataODBC) is dynamically linked, so are all of it's dependencies. -lPocoDataODBC has a dependency on all the libraries in the linker command above plus a couple more (libPocoFoundation and libodbcinst). UUUGGG.... That means EVERYTHING is still being dynamically linked. I verified this by moving the executable to another system and running it....it complained that it did not have each of those 'shared' libraries. Back to square one.
Both of the responses below were correct. The working link command is below. Sorry for the slow update: THANK YOU BOTH VERY MUCH!!!
g++ -L/usr/local/lib *.o -o CraDaemon -Wl,-Bstatic -lPocoDataODBC -lPocoData -lPocoFoundation -Wl,-Bdynamic -lodbc