This is the mail archive of the
gcc-help@gcc.gnu.org
mailing list for the GCC project.
Re: gcc compile options
- To: carlanunes at yahoo dot com
- Subject: Re: gcc compile options
- From: pkurpis at keck dot hawaii dot edu (Peter Kurpis)
- Date: Fri, 6 Jul 2001 08:33:48 -1000 (HST)
- Cc: gcc-help at gcc dot gnu dot org
> 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 .