This is the mail archive of the gcc-help@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Re: static vs. dynamic libraries


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 Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]