From mboxrd@z Thu Jan 1 00:00:00 1970 From: pkurpis@keck.hawaii.edu (Peter Kurpis) To: carlanunes@yahoo.com Cc: gcc-help@gcc.gnu.org Subject: Re: gcc compile options Date: Fri, 06 Jul 2001 11:33:00 -0000 Message-id: <200107061833.IAA15282@kalani.keck.hawaii.edu> X-SW-Source: 2001-07/msg00097.html > I have one more question regarding the creation of a > shared library... > > Should I use the g++ command with the -Wl options or > can I use the ld command directly? Which one is > better? In general, I think g++ -shared is more convenient, because it silently includes libstdc++.so.* , for instance. But I think either can be used, although to be honest, I've not used nor seen ld used to build shared libs from c++ modules. (When creating an executable, gcc and g++ are even more handy, since they link in the startup module (usually called something like crt.o ), etcetera, whereas with ld , I think you'd have to be explicit about these things.) BTW, you may need to use -fpic when compiling source code that you plan to link into a shared lib. One way to see how things are commonly done on your system is to examine native makefiles. Besides looking at them with an editor, you can also (with GNU make, which you probably have on your system) do e.g. make -np | grep "^CPPFLAGS" to see how CPPFLAGS is defined. (The -n turns off any actual building.) Or, you can see how a particular target would be build (again, without actually building anything) with e.g. make -n mylib.so assuming there's a target called mylib.so .