Page 1 of 1

Can't link to SDL2 (or boost) on Windows

Posted: Wed May 07, 2014 11:07 pm
by hardcoder
Hi,

I am testing CodeLite as an alternative IDE (to VC++) on Windows. I am trying to build simplest SDL2 application using console g++ template but I am getting this compilation errors:

C:\Windows\system32\cmd.exe /c "mingw32-make.exe -j 8 -e -f Makefile"
----------Building project:[ hello - Debug ]----------
mingw32-make[1]: Entering directory 'D:/projects/hello'
g++ -o ./Debug/hello @"hello.txt" -L. -LD:/SDL2-2.0.3-mingw/lib/x86 -lSDL2Main -lSDL2
Warning: .drectve `/manifestdependency:"type='win32' name='Microsoft.VC90.CRT' version='9.0.21022.8' processorArchitecture='x86' publicKeyToken='1fc8b3b9a1e18e3b'" /DEFAULTLIB:"MSVCRT" /DEFAULTLIB:"OLDNAMES" U¸ D•Warning: .drectve `' unrecognized
collect2.exe: error: ld returned 5 exit status
mingw32-make[1]: *** [Debug/hello] Error 1
mingw32-make.exe: *** [All] Error 2
hello.mk:79: recipe for target 'Debug/hello' failed
mingw32-make[1]: Leaving directory 'D:/projects/hello'
Makefile:4: recipe for target 'All' failed
0 errors, 0 warnings


I am using official SDL 2.0.3 mingw binaries and this is full source code:

#include <SDL.h>
int main(int argc, char **argv){
if (SDL_Init(SDL_INIT_EVERYTHING) != 0){

return 1;
}
SDL_Quit();

return 0;
}

Re: Can't link to SDL2 (or boost) on Windows

Posted: Fri May 09, 2014 2:00 pm
by Jarod42
Your are still referencing MSVC somewhere in your project, re-check your build options.
Don't mix g++ libraries with VC libraries.

Re: Can't link to SDL2 (or boost) on Windows

Posted: Fri May 09, 2014 4:41 pm
by hardcoder
I don't even have MSVC on that machine. I alredy tried on 3 machines. Clean CodeLite install, g++ console project and basic main. I tried linking SDL or BOOST libraries and there are no linkking errors but everything is still "unresolbed externals". Interestinly code snipped I posted originally also sometimes (it warries with revuild...) gives this:

C:\WINDOWS\system32\cmd.exe /c "mingw32-make.exe -j 1 -e -f Makefile"
"----------Building project:[ hello2 - Debug ]----------"
mingw32-make.exe[1]: Entering directory 'C:/hello2'
mingw32-make.exe[1]: Leaving directory 'C:/hello2'
mingw32-make.exe[1]: Entering directory 'C:/hello2'
g++ -c "C:/hello2/main.cpp" -g -O0 -Wall -std=c++11 -o ./Debug/main.o -I. -I.
g++ -o ./Debug/hello2 @"hello2.txt" -L. -lSDL2 -lSDL2
./Debug/main.o: In function `SDL_main':
C:/hello2/main.cpp:6: undefined reference to `SDL_Init'
C:/hello2/main.cpp:7: undefined reference to `SDL_Quit'
c:/mingw-4.8.1/bin/../lib/gcc/mingw32/4.8.1/../../../libmingw32.a(main.o):main.c:(.text.startup+0xa7): undefined reference to `WinMain@16'
collect2.exe: error: ld returned 1 exit status
mingw32-make.exe[1]: *** [Debug/hello2] Error 1
mingw32-make.exe: *** [All] Error 2
hello2.mk:79: recipe for target 'Debug/hello2' failed
mingw32-make.exe[1]: Leaving directory 'C:/hello2'
Makefile:4: recipe for target 'All' failed
3 errors, 0 warnings

Re: Can't link to SDL2 (or boost) on Windows

Posted: Sat May 17, 2014 12:04 pm
by evstevemd
hardcoder wrote:I don't even have MSVC on that machine. I alredy tried on 3 machines. Clean CodeLite install, g++ console project and basic main. I tried linking SDL or BOOST libraries and there are no linkking errors but everything is still "unresolbed externals". Interestinly code snipped I posted originally also sometimes (it warries with revuild...) gives this:

C:\WINDOWS\system32\cmd.exe /c "mingw32-make.exe -j 1 -e -f Makefile"
"----------Building project:[ hello2 - Debug ]----------"
mingw32-make.exe[1]: Entering directory 'C:/hello2'
mingw32-make.exe[1]: Leaving directory 'C:/hello2'
mingw32-make.exe[1]: Entering directory 'C:/hello2'
g++ -c "C:/hello2/main.cpp" -g -O0 -Wall -std=c++11 -o ./Debug/main.o -I. -I.
g++ -o ./Debug/hello2 @"hello2.txt" -L. -lSDL2 -lSDL2
./Debug/main.o: In function `SDL_main':
C:/hello2/main.cpp:6: undefined reference to `SDL_Init'
C:/hello2/main.cpp:7: undefined reference to `SDL_Quit'
c:/mingw-4.8.1/bin/../lib/gcc/mingw32/4.8.1/../../../libmingw32.a(main.o):main.c:(.text.startup+0xa7): undefined reference to `WinMain@16'
collect2.exe: error: ld returned 1 exit status
mingw32-make.exe[1]: *** [Debug/hello2] Error 1
mingw32-make.exe: *** [All] Error 2
hello2.mk:79: recipe for target 'Debug/hello2' failed
mingw32-make.exe[1]: Leaving directory 'C:/hello2'
Makefile:4: recipe for target 'All' failed
3 errors, 0 warnings
Did you add libraries to linker option?
Add it in linker tab of project settings (right click project)
- Add folder(s) where libs are
- add lib names separated by semi-colon

Re: Can't link to SDL2 (or boost) on Windows

Posted: Sat May 17, 2014 8:03 pm
by petah
can you zip & attach your CL project? your first post shows a number of directives that are clearly for MSVC.

-- p