SDL_net cross compiling

I’m having problems getting SDL_net to link with my application
using the mingw32 cross compiler on linux. When specifing the
linkage with SDL_net and wsock32 with the ‘-l’ linker option to
g++, I get the following errors:

g++ -Wall -Werror -I/usr/local/cross-tools/i386-mingw32/include -I/usr/local/cross-tools/i386-mingw32/include/SDL -Dmain=SDL_main -I/usr/local//include -I. -I… -DWIN32 -g server.cc -o server -L/usr/local/cross-tools/i386-mingw32/lib -lmingw32 -lSDLmain
-lSDL -luser32 -lgdi32 -lwinmm -ldxguid -mwindows -lSDL_mixer -lSDL_net -lwsock32 -lpng -lopengl32 -lglu32 libserver.a …/util/libutil.a
libserver.a(Server.o): In function _6Serveri': Server.cc:20: undefined reference toSDLNet_AllocSocketSet’
Server.cc:33: undefined reference to SDLNet_TCP_Open' Server.cc:40: undefined reference toSDLNet_AddSocket’

etc…

However, when I explicitly link the 2 net libraries mentioned above,
it works. E.g. when I add:

/usr/local/cross-tools/i386-mingw32/lib/libSDL_net.a
/usr/local/cross-tools/i386-mingw32/lib/libwsock32.a

to the compiler arguments.

Is this some sort of subtle order-of-link-parameters problem?

Thanks,

JW–
// John Watson
// Software Engineer – STScI Archive Team

Is this some sort of subtle order-of-link-parameters problem?

Thanks,

Yup, play around with the order of the “-l” flags in your link line.–
Brian

writes:

Is this some sort of subtle order-of-link-parameters problem?

Thanks,

Yup, play around with the order of the “-l” flags in your link line.

To be exact, for a symbol to be linked in, there has to be a prior
object file referencing that symbol. Example: If the file myobj.o
wants the function some_thing from the lib libsome.so, this will fail:
"-lsome myobj.o". However “myobj.o -lsome” will work.

In the original example, the object referencing the symbol is
libserver.a, which is placed after -lSDL_net on the link line. move it
up before all the -l and it’ll work.–
[ Below is a random fortune, which is unrelated to the above message. ]
court, n.:
A place where they dispense with justice.
– Arthur Train