Hi all,
This is I hope the definitive FAQ for most GCC queries I have seen on the net.
Please read this before you post. It should hopefully reduce noise on this
channel.
Mitch
---------------------------Linux GCC FAQ--------------------------
1) How do I tell what version of GCC I am using ?
2) Where is the latest distribution of GCC, as, ld, ar, etc.. ?
3) Where can I find the newest shared libraries libc.so and libm.so ?
4) What other shared libraries are available for Linux ?
5) How do I build a shared DLL library for Linux ?
6) Why do I get the message "PLT__oct__FUii" when I execute a certain binary ?
7) How do I build a cross compiler on platform XXX to produce code for Linux ?
8) What symbols are automatically defined by Linux's GCC ?
9) How do I get over BSD'isms (especially signals, sigvec etc..) when compiling code ?
10) Where are SIGBUS, SIGEMT, SIGIOT, SIGTRAP, SIGSYS etc ?
11) What is libhard and libsoft ?
12) What does the message "can't load library: /lib/libxxx.so, Incompatible version" mean ?
13) Why are my binaries so huge and how do I reduce them ?
14) What does the -N flag do, and when should I use it ?
15) How do I get debugging information into a program ?
16) What debuggers are available for Linux ?
17) How do I debug a daemon program ?
18) What is profiling and how do I profile a program ?
19) Is there a way to tell if a binary is linked statically or to a shared library ?
20) Does Linux have support for LD_LIBRARY_PATH ?
21) My program wants /lib/cpp ! Where can I get it from ?
22) Where is <varargs.h> ?
23) My program wants to include <linux/foo.h> but cannot find it, where is it ?
24) Do we have the function foo() in our libraries ?
25) How do I port program XXX to Linux ?
26) I think I have found a bug in gcc/library foo, what do I do now ?
27) Why are shared libraries so large in comparison to their static counterparts ?
28) What are .sa file I see in /usr/lib ?
29) Where can I get Objective C for Linux ?
30) What does the message "Internal compiler error: cc1 got fatal signal 11" mean ?
31) What is a libc.so.lite ?
32) Does Linux libraries have SHADOW Password support, and how do I switch it on/off ??
33) Can't find math.h routines ! My program compiles but cannot find log(), sin(), etc.., HELP !!
34) Is there a manual for GCC? If so, where do I get it, and how do I print it out ?
35) I get the message "Undefined symbol _bsd_ioctl". Where is this anyhow ??
----------------------------------------------------------------
1) How do I tell what version of GCC I am using ?
Ans: Execute the command
gcc -v
to find out what version you are using. At the time of writing the
above command produces on my machine
Reading specs from /usr/lib/gcc-lib/i386-linux/2.4.0/specs
gcc version 2.4.0
You would be well advised to upgrade to a version similar to this or
above.
P.S. If you get the output
Reading specs from /usr/lib/gcc-lib/i486-linux/2.4.0/specs
gcc version 2.4.0
you are running a gcc compiled for a 486.
----------------------------------------------------------------
2) Where is the latest distribution of GCC, as, ld, ar, etc.. ?
Ans: The Official place for GCC distributions is tsx-11.mit.edu in
/pub/linux/packages/GCC. All others sites mirror this.
The latest versions of all GCC stuff will be found here.
At the time of writing the latest GCC is version 2.4 from
tsx-11.mit.edu:/pub/Linux/GCC/a-gcc-2.4.0.tar.z
----------------------------------------------------------------
3) Where can I find the newest shared libraries libc.so and libm.so ?
Ans: See (2) above. You need the file image*.tar.z. For 486 images look
under /pub/linux/packages/GCC/486.
----------------------------------------------------------------
4) What other shared libraries are available for Linux ?
Ans: Ok here is a list I have been compiling. Any additions/changes
graciously received.
The locations given below were where they were last seen (or
reportedly seen). They may have been moved by archive maintainers.
P.S. The descriptions of the libraries may not be obvious. I will
add descriptions in a later table (i.e. when all are filled). Please
send descriptions of the libraries (except the obvious) if you know
what they are.
Here are the locations of currently registered DLL libraries for Linux.
======================================================================
libc.so sunsite.unc.edu:/pub/Linux/GCC/image-4.4.tar.z
libm.so included in above tar.z file.
libX11.so tsx-11.mit.edu:pub/linux/packages/X11/XFree86-1.2/x1.2.base.tpz
libXt.so included in above tpz file.
libXaw.so included in above tpz file.
librl.so sunsite.unc.edu:/pub/Linux/libs/librl-1.1.tar.z
libgr.so sunsite.unc.edu:/pub/Linux/libs/libgr-1.2.tar.z
libf2c.so sunsite.unc.edu:/pub/Linux/development/fortran/libf2c-0.7.tar.z
libF77.so use libf2c.so instead.
libI77.so use libf2c.so instead.
libXpm.so sunsite.unc.edu:/pub/Linux/libs/libXpm32g.tar.z
libnet.so redundant (reintegrated into libc.so address space
librpc.so to be used for nis/yp and rpcsvc)
libolgx.so sunsite.unc.edu:/pub/Linux/X11/devel/xview3l4.tar.z
libxview.so included in above tar.z file.
libsspkg.so included in above tar.z file.
libUIC.so included in above tar.z file.
libPEX.so
libtcl.so sunsite.unc.edu:/pub/Linux/development/tcl/tclDist.tar.z
libtk.so included in above tar.z file.
libWc.so
libXp.so
libIV.so
libUnidraw.so
libXm.so(motif) Not free. See note below.
libsrgp.so sunsite.unc.edu:/pub/Linux/X11/devel/suit.tpz
libsuit.so included in above tpz file.
------------
Note:-
Drop in DLL libraries for Xaw to get a 3d effect (libXaw3d-0.6) and a Mac(TM)
like scroll bar on Xaw clients are available respectively at
sunsite.unc.edu:/pub/Linux/libs/libXaw3d-3.0-B.tar.z
and
sunsite.unc.edu:/pub/Linux/libs/libXaw.Scrollbar.taz
For motif libs you have to pay bucks !! Read an extract that follows...
------
Metro Link, Inc. is pleased to announce the availability of OSF/Motif 1.2.2
for Linux at the introductory price of $199 for a complete runtime and
development system.
[...]
2) Shared motif library (libXm.so.1.2.2)
[...]
This introductory offer is valid until June 10. The price will then return
to our regular Motif pricing which is $199 for runtime and $299 for
development
(which includes runtime).
You can order OSF/Motif 1.2.2 for Linux by calling Metro Link,Inc. at
(305) 970-7353 (voice) or (305) 970-7351 (fax) or by mailing us at
sa...@metrolink.com.
----------------------------------------------------------------
5) How do I build a shared DLL library for Linux ?
Ans: You need to get the file
/pub/linux/packages/GCC/src/tools-2.6.tar.z
from tsx-11.mit.edu, and install it. Read the README.tr in the doc
subdirectory thoroughly. If you find the README.tr more up to date
than the README.ps, you will have to recreate it if you want a
pretty Postscript version, but you *must* have groff installed. A
`make README.ps' in the doc subdirectory should suffice.
** Note: the version numbers may have changed.
----------------------------------------------------------------
6) Why do I get the message "PLT__oct__FUii" when I execute a certain binary ?
Ans: More likely than not you have a old version of the libraries, libc.so
and/or you compiled a program using a incorrect version of `ld'.
Solution is to get the new version of binutils package from
tsx-11.mit.edu in /pub/linux/packages/GCC/binutils.tar.z
----------------------------------------------------------------
7) How do I build a cross compiler on platform XXX to produce code for Linux ?
Ans: Assuming you have obtained the source code to gcc, usually you can
just follow the instructions given in the INSTALL file for GCC.
A `configure --target==i386-linux --host=XXX' on platform XXX
followed by a `make' should do the trick.
Note that you will need the linux includes, the kernel includes,
and also to build cross assembler, and cross linker from the sources
in /pub/linux/packages/GCC/src at tsx-11.mit.edu
----------------------------------------------------------------
8) What symbols are automatically defined by Linux's GCC ?
Ans: Symbols defined are `linux', `__unix__', `__i386__', `__linux__',
`__unix', `__i386', `__linux'.
You can get a correct list by using the flag -v to gcc whilst
compilation.
P.s. One should note that even though the compiler automatically
defines "linux" in a program, this is *not* POSIX compliant. Instead
__linux__ should be used in programs that need operating-system
specific compilation, since __linux__ *is* POSIX compliant.
This means you can wrap your linux specific code around (for example)
#ifdef __linux__
...[linux specific code here]...
#endif /* ifdef linux */
without adding anything extra to the Makefile defines etc..
You can also add your own defines to the file
/usr/lib/gcc-lib/i386-linux/2.4.0/specs
----------------------------------------------------------------
9) How do I get over BSD'isms (especially signals, sigvec etc..) when compiling code ?
Ans: You can compile your program with -I/usr/include/bsd and link it
with -lbsd - i.e. Add -I/usr/include/bsd to CFLAGS and -lbsd to
the LDFLAGS line in your Makefile. Also add -D__USE_BSD_SIGNAL to
the CFLAGS if you want BSD type signal behavior.
----------------------------------------------------------------
10) Where are SIGBUS, SIGEMT, SIGIOT, SIGTRAP, SIGSYS etc ?
Ans: Linux is 100% POSIX compliant and these signals are not POSIX
signals. As an easy way out you could redefine them to SIGUNUSED.
See the definitions in /usr/include/bsd/signal.h
However you should note that the lack of these signals *is* compliant
with POSIX. Instead of #define'ing to them to SIGUNUSED, new programs
should instead say:
#ifdef SIGSYS
....[non-posix sigsys code here]....
#endif
for code that requires the use of SIGSYS (similarly for SIGBUS).
Here is a snippet from ISO/IEC 9945-1:1990 (IEEE Std 1003.1-1990),
...
read more »