libSDLmain.a and -lSDLmain!?
Hello.
I discovered that when in c:\cpp\lib\ (cpp is the DevC++ root dir) there is a file called libSDLmain.a and I link -lSDLmain, then it actually links to libSDLmain.a, and If I change the name to SDLmain.a in the lib directory, then it can't find the file?
I know, that the linker finds for files with the .a extension, so -lSDLmain -> SDLmain.a and it should! find the SDLmain.a but it doesn't.
What am I misunderstanding?
libSDL.dll.a instead of libSDL.a?
Quote:
Originally Posted by Cactus_Hugger
The linker translates -l*something* into lib*something*.a, not *something*.a. Thus libSDLmain.a is the correct name. If I say "-lhardi", it will look for a libhardi.a in the library directories.
If it translates -lSDL to libSDL.a, then why does it give an error, when I rename libSDL.dll.a into libSDLxxxx.dll.a(basically, it can't find the file it is supposed to - it should find libSDL.dll.a (which is a mistery) but I renamed the file and it can't find it).
Maybe the linker does not convert the -lSDL to libSDL.dll.a, maybe it converts it to libSDL.a and libSDL.a itself requires the libSDL.dll.a, BUT
when I link the file like this: c++ SDL_tester.o c:/cpp/lib/libSDL.a then it gives undefined references for all SDL functions the SDL_tester.o uses, but If I link c:/cpp/lib/libSDL.dll.a instead of libSDL.a then it gives no error. So maybe the libSDL.a does not require libSDL.dll.a afterall?
The command is:
C:\cpp\Projects>%c++% SDL_tester.o SDL_tester_private.res -o main.exe -mwindows
-lmingw32 c:/cpp/lib/libSDLmain.a c:/cpp/lib/libSDL.dll.a
It gives no errors.
Another command:
C:\cpp\Projects>%c++% SDL_tester.o SDL_tester_private.res -o main.exe -mwindows
-lmingw32 c:/cpp/lib/libSDLmain.a c:/cpp/lib/libSDL.a
c:/cpp/lib/libSDL.a(SDL_systimer.o)(.text+0x15): undefined reference to `timeBeg
inPeriod@4'
c:/cpp/lib/libSDL.a(SDL_systimer.o)(.text+0x1d): undefined reference to `timeGet
Time@0'
c:/cpp/lib/libSDL.a(SDL_systimer.o)(.text+0xc1): undefined reference to `timeGet
Time@0'
c:/cpp/lib/libSDL.a(SDL_systimer.o)(.text+0x17e): undefined reference to `timeBe
ginPeriod@4'
c:/cpp/lib/libSDL.a(SDL_systimer.o)(.text+0x1b1): undefined reference to `timeSe
tEvent@20' .....................
The 3rd command:
C:\cpp\Projects>%c++% SDL_tester.o SDL_tester_private.res -o main.exe -mwindows
-lmingw32 -lSDLmain -lSDL
gives no errors!
Where's the catch!? :confused: