Re: static vs. dynamic libraries

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

 



Hi Larry,

This is a VERY platform (OS + GCC version) sensitive way to solve the problem, as a target using GNU Make (I presume you know where the tabs go):

myfoo : foo.cpp
$(CXX) -o $@ $^ \
-nodefaultlibs \
-Wl,-Bstatic \
$(shell $(CXX) -print-file-name=libstdc++.a) \
$(shell $(CXX) -print-file-name=libgcc.a) \
$(shell $(CXX) -print-file-name=libgcc_eh.a) \
-Wl,-Bdynamic \
-lpthread -lc -lm -ldl

CAVEAT: Use with caution! This may work on, say, Solaris, and be completely wrong for, say, AIX or Linux. And the libraries may be correct for GCC 3.2, and wrong for GCC 3.3. Your mileage may vary.

HTH,
--Eljay


[Index of Archives]     [Linux C Programming]     [Linux Kernel]     [eCos]     [Fedora Development]     [Fedora Announce]     [Autoconf]     [The DWARVES Debugging Tools]     [Yosemite Campsites]     [Yosemite News]     [Linux GCC]

  Powered by Linux