public inbox for cygwin@cygwin.com
 help / color / mirror / Atom feed
* Re: Libraries not working
@ 1999-07-06 12:01 John Garrison
  1999-07-06 12:53 ` Mumit Khan
  1999-07-31 18:34 ` John Garrison
  0 siblings, 2 replies; 32+ messages in thread
From: John Garrison @ 1999-07-06 12:01 UTC (permalink / raw)
  To: cygwin

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
lib)
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
out.
And yes I am also included -lSDL because other parts of the program need
it.
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/usr/win32/include

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
other
> > lists I have been on sent the message to the list when you reply.
Maybe
> > 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
is
> > a cross-compiler so It outputs Windows executables.
> >
> > > > /tmp/cciFT7S1.o(.text+0x103):show.c: undefined reference to
> > > > `IMG_Load_RW'
> > > >
> >
/usr/win32/bin/../lib/gcc-lib/i586-mingw32/egcs-2.91.57/../../../../i586-mingw32/lib/libmingw32.a(main.o)(.text+0x7b):

> >
> > > > 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
guess
> > 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
GCC
> and the linker, what files are being linked in, what language (C,
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
main
> > > > statement, well, I am not building a library I already HAVE a
main
> > > > 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
an
> > empty WinMain()  source file? By the way, does anybody know why
Windows
> > decided to completely screw up portabilty with this WinMain function
in
> > the first place? What is wrong with the main() statement we have
been
> > using since like 1972 when the language was invented?
>
> WinMain() becomes the "entry" for GUI executables in Windows. As for
how
> 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 cygwin-unsubscribe@sourceware.cygnus.com




--
Want to unsubscribe from this list?
Send a message to cygwin-unsubscribe@sourceware.cygnus.com

^ permalink raw reply	[flat|nested] 32+ messages in thread
* Re: Libraries not working
@ 1999-07-06 14:31 DJ Delorie
  1999-07-06 14:50 ` Mumit Khan
  1999-07-31 18:34 ` DJ Delorie
  0 siblings, 2 replies; 32+ messages in thread
From: DJ Delorie @ 1999-07-06 14:31 UTC (permalink / raw)
  To: jeg, cygwin

> [bin]# ./i586-mingw32-nm /usr/win32/lib/libIMG.a | grep IMG_Load_RW
> ./i586-mingw32-nm: IMG.c: File format not recognized

One thing to note - you should put *.o in the archives, not *.c

--
Want to unsubscribe from this list?
Send a message to cygwin-unsubscribe@sourceware.cygnus.com

^ permalink raw reply	[flat|nested] 32+ messages in thread
* Re: Libraries not working
@ 1999-07-05 13:21 John Garrison
  1999-07-06 11:15 ` Mumit Khan
  1999-07-31 18:34 ` John Garrison
  0 siblings, 2 replies; 32+ messages in thread
From: John Garrison @ 1999-07-05 13:21 UTC (permalink / raw)
  To: cygwin

I am sorry about responding to your help via personal email, the other
lists I have been on sent the message to the list when you reply. Maybe
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 is
a cross-compiler so It outputs Windows executables.

> > /tmp/cciFT7S1.o(.text+0x103):show.c: undefined reference to
> > `IMG_Load_RW'
> >
/usr/win32/bin/../lib/gcc-lib/i586-mingw32/egcs-2.91.57/../../../../i586-mingw32/lib/libmingw32.a(main.o)(.text+0x7b):

> > 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 guess
it is possible to not define a function, but this is
is defined. Besides it compiles fine for Linux.

>
> > Also I have a main function and the FAQ says that if you
> > get the undefined reference to `WinMain@16' to include a blank main
> > statement, well, I am not building a library I already HAVE a main
> > statement.
>
> One solution: link with WinMain.o
> The other was explained by Mumit Khan in a posting May 13
>

WinMain.o?  Is that part of the distribution or do I have to create an
empty WinMain()  source file? By the way, does anybody know why Windows
decided to completely screw up portabilty with this WinMain function in
the first place? What is wrong with the main() statement we have been
using since like 1972 when the language was invented?


--
Want to unsubscribe from this list?
Send a message to cygwin-unsubscribe@sourceware.cygnus.com

^ permalink raw reply	[flat|nested] 32+ messages in thread
* Libraries not working
@ 1999-07-03 22:42 John Garrison
  1999-07-04  9:57 ` tjoen
  1999-07-31 18:34 ` John Garrison
  0 siblings, 2 replies; 32+ messages in thread
From: John Garrison @ 1999-07-03 22:42 UTC (permalink / raw)
  To: cygwin

I have just created a library using ar. I have a program that links to
the library, and have the header file included in the code. Everything
is setup properly ( I know because it compiles fine with gcc) I am using
the cross compiler on Linux version by the way.

The problem is after I try to compile the program I get a:

/tmp/cciFT7S1.o(.text+0x103):show.c: undefined reference to
`IMG_Load_RW'
/usr/win32/bin/../lib/gcc-lib/i586-mingw32/egcs-2.91.57/../../../../i586-mingw32/lib/libmingw32.a(main.o)(.text+0x7b):
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. Also I have a main function and the FAQ says that if you
get the undefined reference to `WinMain@16' to include a blank main
statement, well, I am not building a library I already HAVE a main
statement.

Any ideas why it would complain about not having two things that it does
have?


--
Want to unsubscribe from this list?
Send a message to cygwin-unsubscribe@sourceware.cygnus.com

^ permalink raw reply	[flat|nested] 32+ messages in thread

end of thread, other threads:[~1999-07-31 18:34 UTC | newest]

Thread overview: 32+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
1999-07-06 12:01 Libraries not working John Garrison
1999-07-06 12:53 ` Mumit Khan
1999-07-06 13:21   ` John Garrison
1999-07-06 14:27     ` Mumit Khan
1999-07-31 18:34       ` Mumit Khan
1999-07-31 18:34     ` John Garrison
1999-07-31 18:34   ` Mumit Khan
1999-07-31 18:34 ` John Garrison
  -- strict thread matches above, loose matches on Subject: below --
1999-07-06 14:31 DJ Delorie
1999-07-06 14:50 ` Mumit Khan
1999-07-06 15:04   ` John Garrison
1999-07-06 15:23     ` Mumit Khan
1999-07-06 15:47       ` John Garrison
1999-07-06 19:31         ` Mumit Khan
1999-07-31 18:34           ` Mumit Khan
1999-07-31 18:34         ` John Garrison
1999-07-31 18:34       ` Mumit Khan
1999-07-31 18:34     ` John Garrison
1999-07-31 18:34   ` Mumit Khan
1999-07-31 18:34 ` DJ Delorie
1999-07-05 13:21 John Garrison
1999-07-06 11:15 ` Mumit Khan
1999-07-31 18:34   ` Mumit Khan
1999-07-31 18:34 ` John Garrison
1999-07-03 22:42 John Garrison
1999-07-04  9:57 ` tjoen
1999-07-04 17:51   ` Mumit Khan
1999-07-05 11:02     ` tjoen
1999-07-31 18:34       ` tjoen
1999-07-31 18:34     ` Mumit Khan
1999-07-31 18:34   ` tjoen
1999-07-31 18:34 ` John Garrison

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).