This is the mail archive of the mailing list for the Cygwin project.

Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]

Re: Libraries not working

What I am creating is a game programming library. I am using the low
level library called SDL. SDL has a demo lib that
loads in images, that lib is call IMGLib. I have compiled IMGLib using
the Makefile provided and the cross-compiler. It
compiled and linked fine. (IMG.h is where IMG_Load_RW is defined, it is
implemented in IMG.c) So I have a compiled library
which had IMG_Load_RW defined and implemented. I installed the IMGLib
library in my cross-compiler's paths (include and
When I compile my library (which includes code from IMGLib) It compiles
and links fine under the cross-compiler. However,
if I try to build the IMGLib example directly with IMGLib, or one of my
libs examples, which would use IMGLib indirectly,
it brings the error 'undefined reference to IMG_Load_RW'  I have
included IMG.h, which declares IMG_Load_RW and I have
included -lIMG which is the libIMG.a file that implements IMG_Load_RW.
As I said everything compiles fine under GCC and IMG_Load_RW being the
only function from IMGLib it can't find confuses me,
if it were a linker error then it would complain about all of the
functions being passed from IMGLib wouldn't it?
Although the problem only exists when trying to compile a binary, so it
only makes since that it is in the linker, but if
it can find all the other functions why can't it find IMG_Load_RW?
I've asked Sam Lantinga (the guy that created SDL) the only suggestion
he had was that I was using an older version of his
library which I am not. (and that would make little difference anyway
because I compiled IMGLib with the same libSDL.a as I
am trying to compile and link my examples with) Yes I am using a windows
version of SDL.
What really baffles me is that even the Makefile for the show.c IMGLib
examples gives the error, if I were leaving out
something it would make since, but the Makefile wouldn't leave something
And yes I am also included -lSDL because other parts of the program need
The language is C by the way.
Here is the gcc command I am giving (actually I am using a Makefile, but
here is the result of what make is giving)

(CC) -Wall -O6 ex1.c -o ex1.exe -lIMG -lPD -lSDL -lttf

I have tried changing the position of -lIMG to the middle and the back I
have try putting -I before the -l's and after the
-l's, I just can't figure out why it would work fine on Linux GCC and
not Win32 GCC.
Is this enough info? I am trying to keep it relatively short.

Mumit Khan wrote:

> On Mon, 5 Jul 1999, John Garrison wrote:
> >
> > I am sorry about responding to your help via personal email, the
> > lists I have been on sent the message to the list when you reply.
> > you emailed to me instead of the list and I didn't bother to look,
> > sorry. Anyhow here is my reply to those in the list who might be
able to
> >
> > help.  By the way I am using a Linux version of the compiler, but it
> > a cross-compiler so It outputs Windows executables.
> >
> > > > /tmp/cciFT7S1.o(.text+0x103):show.c: undefined reference to
> > > > `IMG_Load_RW'
> > > >
> >

> >
> > > > undefined reference to `WinMain@16'
> > > > collect2: ld returned 1 exit status
> > > >
> > > > IMG_Load_RW is clearly defined in IMG.h which is included in the

> > show.c
> > > > source code.
> > >
> > > I guess that it is only declared, not defined
> > >
> >
> > IMG_Load_RW is a function, it can't help but be defined. Well, I
> > it is possible to not define a function, but this is
> > is defined. Besides it compiles fine for Linux.
> This is your second post, but still no details. Without any details on

> what you're doing, how you're linking, what options you're passing to
> and the linker, what files are being linked in, what language (C,
> how are we supposed to know what's wrong???
> > >
> > > > Also I have a main function and the FAQ says that if you
> > > > get the undefined reference to `WinMain@16' to include a blank
> > > > statement, well, I am not building a library I already HAVE a
> > > > statement.
> > >
> > > One solution: link with WinMain.o
> > > The other was explained by Mumit Khan in a posting May 13
> > >
> This is incorrect. There is no WinMain.o.
> >
> > WinMain.o?  Is that part of the distribution or do I have to create
> > empty WinMain()  source file? By the way, does anybody know why
> > decided to completely screw up portabilty with this WinMain function
> > the first place? What is wrong with the main() statement we have
> > using since like 1972 when the language was invented?
> WinMain() becomes the "entry" for GUI executables in Windows. As for
> the language has been changed under you on Windows, feel free to ask
> Microsoft ;-) Of course, I hope folks have switched from the language
> from 1972 to a much newer ANSI C, and soon to be C9x!
> Regards,
> Mumit
> --
> Want to unsubscribe from this list?
> Send a message to

Want to unsubscribe from this list?
Send a message to

Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]