"undefined reference" problem

— Donny Viszneki a ?crit?:

— Donny Viszneki a
?crit?:

If that (#include “SDL.h”) didn’t work when you
were

compiling with the
sdl-config --cflags then there is something
wrong

with your SDL
installation, and that is possibly the root of
the

problems you’re
having now.

That’s what i was thinking too, cause i don’t have
the
SDL include files in the current directory.

What “current directory” are you talking about?

It’s the directory where the main.cpp(the source code
i want to compile)is.

Man , i don’t even know what CVS is?

I don’t want to sound like a buzzkill but perhaps
you should take the
time to learn some other things before SDL. Either
way…

CVS is the Concurrent Versions System. It organizes
and serves source
code and keeps a history of revisions. There are
plenty of CVS clients
out there. If you’re running any sort of Unix you
probably already have
a cvs client (called, appropriately enough, cvs.)

To learn about using a cvs client, Google
recommends…
http://www.flat222.org/mac/cvs.html
https://www.cvshome.org/docs/blandy.html

  • Donny Viszneki

SDL mailing list
SDL at libsdl.org
http://www.libsdl.org/mailman/listinfo/sdl

Vous manquez d?espace pour stocker vos mails ?
Yahoo! Mail vous offre GRATUITEMENT 100 Mo !
Cr?ez votre Yahoo! Mail sur http://fr.benefits.yahoo.com/

Le nouveau Yahoo! Messenger est arriv? ! D?couvrez toutes les nouveaut?s pour dialoguer instantan?ment avec vos amis. A t?l?charger gratuitement sur http://fr.messenger.yahoo.com> On Aug 4, 2004, at 5:14 AM, remi tassing wrote:

It’s really strange!

Since i failed to use SDL on my laptop, i tried to
install linux on my PC and everything is compiling
just fine, i didn’t even have to install SDL!!

Maybe i’ll just never use SDL on my laptop(with linux)

Vous manquez d?espace pour stocker vos mails ?
Yahoo! Mail vous offre GRATUITEMENT 100 Mo !
Cr?ez votre Yahoo! Mail sur http://fr.benefits.yahoo.com/

Le nouveau Yahoo! Messenger est arriv? ! D?couvrez toutes les nouveaut?s pour dialoguer instantan?ment avec vos amis. A t?l?charger gratuitement sur http://fr.messenger.yahoo.com

  1. When linking statically, the order of the object files and
    libraries is critical. A static library satisfies references only for
    the files before it on the linker command line. This is normal
    behaviour, and yes, it means that you sometimes have to have some libs
    repeated in case there’s a circular dependency, like -lfoo -lbar
    -lfoo.
    The reason to this is that ld reads the linked files in the order of
    the
    command line, and when linking statically, references are linked at
    that
    point. When linking dynamically, the symbols are only checked to see
    that all references are satisfied.

I’m running Mac OS X 10.3.4 and very clearly:

~/Crap$ c++ test_mixer.cpp -L/opt/local/lib -I/opt/local/include/SDL
-lSDLmain -lSDL_mixer -lSDL -framework Cocoa
~/Crap$ c++ -L/opt/local/lib -I/opt/local/include/SDL -lSDLmain
-lSDL_mixer -lSDL -framework Cocoa test_mixer.cpp

I have no problem no matter what order I list them. Perhaps this is
relevant:

~/Crap$ c++ --version
c++ (GCC) 3.3 20030304 (Apple Computer, Inc. build 1495)
Copyright © 2002 Free Software Foundation, Inc.
This is free software; see the source for copying conditions. There is
NO
warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR
PURPOSE.

  • Donny VisznekiOn Aug 5, 2004, at 2:34 AM, Petri Latvala wrote:


Petri Latvala


SDL mailing list
SDL at libsdl.org
http://www.libsdl.org/mailman/listinfo/sdl

The relevant part is that you are linking dynamically, not statically.
Try with -static and you’ll see it matters.On Fri, 2004-08-06 at 09:45, Donny Viszneki wrote:

I’m running Mac OS X 10.3.4 and very clearly:

~/Crap$ c++ test_mixer.cpp -L/opt/local/lib -I/opt/local/include/SDL
-lSDLmain -lSDL_mixer -lSDL -framework Cocoa
~/Crap$ c++ -L/opt/local/lib -I/opt/local/include/SDL -lSDLmain
-lSDL_mixer -lSDL -framework Cocoa test_mixer.cpp

I have no problem no matter what order I list them. Perhaps this is
relevant:

~/Crap$ c++ --version
c++ (GCC) 3.3 20030304 (Apple Computer, Inc. build 1495)


Petri Latvala

Petri Latvala wrote:>On Tue, 2004-08-03 at 10:36, remi tassing wrote:

And this is how i’m building the executable:
g++ -Wall sdl-config --cflags sdl-config --libs
-Wno-deprecated -o main main.cpp.

A lot of bogus information was given in the threads replying to this.
Let’s get some facts.

  1. Your SDL installation is fine. No need to reinstall or get new
    versions from CVS
  2. When linking statically, the order of the object files and
    libraries is critical. A static library satisfies references only for
    the files before it on the linker command line. This is normal
    behaviour, and yes, it means that you sometimes have to have some libs
    repeated in case there’s a circular dependency, like -lfoo -lbar -lfoo.
    The reason to this is that ld reads the linked files in the order of the
    command line, and when linking statically, references are linked at that
    point. When linking dynamically, the symbols are only checked to see
    that all references are satisfied.


Petri Latvala


SDL mailing list
SDL at libsdl.org
http://www.libsdl.org/mailman/listinfo/sdl

Thanks for clarifying that!! I know that the maintainers on the Mingw
list always say that link order matters, but they never went into
detail. If I link against SDL.dll instead of -lSDL on mingw then I can
specify the libraries before the source files.

brian

I’m running Mac OS X 10.3.4 and very clearly:

~/Crap$ c++ test_mixer.cpp -L/opt/local/lib -I/opt/local/include/SDL
-lSDLmain -lSDL_mixer -lSDL -framework Cocoa
~/Crap$ c++ -L/opt/local/lib -I/opt/local/include/SDL -lSDLmain
-lSDL_mixer -lSDL -framework Cocoa test_mixer.cpp

I have no problem no matter what order I list them. Perhaps this is
relevant:

~/Crap$ c++ --version
c++ (GCC) 3.3 20030304 (Apple Computer, Inc. build 1495)

The relevant part is that you are linking dynamically, not statically.
Try with -static and you’ll see it matters.

Oh, I always thought static linking was the default behavior.


Petri Latvala


SDL mailing list
SDL at libsdl.org
http://www.libsdl.org/mailman/listinfo/sdl

  • Donny VisznekiOn Aug 6, 2004, at 11:54 AM, Petri Latvala wrote:

On Fri, 2004-08-06 at 09:45, Donny Viszneki wrote: