This is the mail archive of the
gcc-help@gcc.gnu.org
mailing list for the GCC project.
Re: Simple linking problem
- From: Andrew Haley <aph-gcc at littlepinkcloud dot COM>
- To: gccNewbie <bguild at shaw dot ca>
- Cc: gcc-help at gcc dot gnu dot org
- Date: Thu, 10 May 2007 12:07:19 +0100
- Subject: Re: Simple linking problem
- References: <10410954.post@talk.nabble.com>
gccNewbie writes:
>
> After spending years working in Java, I've decided I'd like to do a little C
> programming. I've gotten gcc, which I think is the first step. In fact, I'm
> using an old version, 3.2.3 for MinGW. I've done "Hello world" just to be
> sure gcc is working. Now I'm trying to get gcc to link.
>
> I've studed all the options, all the ways to invoke gcc, and I can find
> nothing helpful. I've got a library in a file starting with 'lib' and ending
> with '.a'. I've downloaded this file from the web, I've downloaded the
> source and used the makefile to compile the library. It seems that no matter
> what I do I cannot get gcc to treat this file as a library containing the
> stuff that I am absolutely sure it is supposed to contain.
>
> I know gcc is finding the file. If I go "gcc -lblah" and it cannot find
> libblah.a, it will give me an error that tells me the library wasn't found.
> So the library file is found. I see nothing in the documentation that
> suggests I should need to do anything more than "gcc -lmylib test.c" to
> compile 'test.c' with the functions defined in mylib. I have the library, I
> tell gcc to use the library, and yet it acts as though these library
> functions are undefined, giving 'undefined reference to' messages.
>
> I've looked at all the documentation I can think to study without finding
> any possible solution. Is there any way to get gcc to tell me exactly what
> is really in the library file?
Yes. The command is called "nm".
Andrew.