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

General questions regarding the usage of CodeLite
hardcoder
CodeLite Curious
Posts: 2
Joined: Wed May 07, 2014 3:59 pm
Genuine User: Yes
IDE Question: c++
Contact:

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

Post 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;
}
User avatar
Jarod42
CodeLite Expert
Posts: 239
Joined: Wed Sep 30, 2009 5:54 pm
Genuine User: Yes
IDE Question: C++
Location: France
Contact:

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

Post by Jarod42 »

Your are still referencing MSVC somewhere in your project, re-check your build options.
Don't mix g++ libraries with VC libraries.
hardcoder
CodeLite Curious
Posts: 2
Joined: Wed May 07, 2014 3:59 pm
Genuine User: Yes
IDE Question: c++
Contact:

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

Post 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
evstevemd
CodeLite Guru
Posts: 352
Joined: Sun Nov 29, 2009 7:36 pm
Genuine User: Yes
IDE Question: C++
Contact:

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

Post 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

CodeLite 15.x
CodeLite is awesome, I just Love it!

petah
CodeLite Expert
Posts: 231
Joined: Sat Nov 24, 2012 8:04 pm
Genuine User: Yes
IDE Question: c++
Location: Los Angeles
Contact:

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

Post by petah »

can you zip & attach your CL project? your first post shows a number of directives that are clearly for MSVC.

-- p
main: Debian Jessie x64 + custom wxTrunk
Post Reply