Not logged in, Join Here! or Log In Below:  
News Articles Search    

 Home / General Programming / gcc in windows... Account Manager
Archive Notice: This thread is old and no longer active. It is here for reference purposes. This thread was created on an older version of the flipcode forums, before the site closed in 2005. Please keep that in mind as you view this thread, as many of the topics and opinions may be outdated.

April 20, 2005, 12:27 PM


I'm trying to compile a program that uses a lib (called librl.a), in windows, with gcc.
I downloaded the MinGW package, installed on my root; created a system path to the bin of MinGW (so I can have access to gcc.exe); I open the prompt; call gcc like this: gcc -ansi -o prog1 -L. prog1.c -lrl ; and I get a bunch of undefined references to the functions declared inside the lib...
How can I make this work?

Huge thanks


April 20, 2005, 12:45 PM

Are these undefined references messages in some way related to the librl.a
you're using?
I'm not sure, but from my first linux/gcc programming trials I remember
that I specified the library paths explicitly when compiling
something that used 3rd party libraries.

Just another question: Is this library you're using the GNU
readline library? Is there really a windows version available
(at least I'm not able to find one)?
If you downloaded the linux version and try to use it with windows
I really doubt that this will work.

Danny Chapman

April 20, 2005, 12:57 PM

Are you sure those functions are actually defined (there's a difference between define and declare) inside librl.a, or are they referenced inside librl.a and actually defined in a different library that you need to link with as well.

To get info on symbols in a library run nm on it (at a cygwin command line), and search for the symbols that are undefined according to your linker:

nm librl.a | grep symbol_that_is_undefined

then the letter in the column just before the symbol name tells you if it's in there (a T, meaning the function is in the text section), or undefined (U).

If this is the case, then you'll need to work out what libs librl.a depends on.

Also - is librl.a in either the current or a system directory?


April 20, 2005, 01:04 PM

the functions are actually defined in the lib... I use a header file with the declarations...
the lib is not the GNU one...

I'm pretty sure the lib was compiled in linux... could that be a prob?


April 20, 2005, 01:09 PM

Yes it could. Libraries from different compilers are not *generally* compatible to each other. Though gcc makes an effort that they be.


April 20, 2005, 01:21 PM

so... is there ANY way I can compile this prog in win?


April 20, 2005, 01:53 PM


A '.a' file is normally a static library, not a shared library, therefor you will be unable to link with it. However, you should be to include the whole library inside your program.

Try this:

gcc -ansi -o prog1 prog1.c librl.a

Edit, teach me for posting without reading first, if the librt.a file was compiled under linux to actually run under linux, it probably won't work.


Sebastian Negomireanu

April 20, 2005, 02:11 PM

If it's compiled for linux, it won't work for sure. Anyway, if you have the sources to the library, just recompile it under win.

This thread contains 8 messages.
Hosting by Solid Eight Studios, maker of PhotoTangler Collage Maker.