7e3a0562eb64eb798bd8e32a9bf99041

7e3a0562eb64eb798bd8e32a9bf99041

Postby PsyPeng » 12 Nov 2014, 18:14

57049138d2d3fbe9fbc7dae6f52e68f3
Last edited by PsyPeng on 30 Apr 2015, 08:21, edited 3 times in total.
PsyPeng
 
Posts: 1
Joined: 12 Nov 2014, 17:50

Re: [Cmake][SDL2][Code::Blocks] Cannot find -lSDL2 or -lSDL2

Postby oln » 12 Nov 2014, 19:35

You seem to be setting both the "-lSDL2" in the compiler flags and telling cmake to link with SDL with target_link_libraries. You don't need both. target_link_libraries links the provided libraries, you don't need to add the linker flags manually.

You can also use the "find_package" command to locate libraries, which is the common way of using cmake, but you will need to look on the web for a FindSDL2.cmake module, as the one coming with cmake is not updated for SDL2.

I would recommend looking at other projects using cmake to see how they are set up, cmake can be a bit confusing to get used to.
User avatar
oln
 
Posts: 1020
Joined: 26 Oct 2010, 22:16
Location: Norway

Re: [Cmake][SDL2][Code::Blocks] Cannot find -lSDL2 or -lSDL2

Postby acme_pjz » 13 Nov 2014, 06:36

Hi,

You can look at my project https://code.google.com/p/puzzleboy which uses SDL2. In fact I also found FindSDL2.cmake on the Internet :)
Some of my open source games on GitHub
User avatar
acme_pjz
 
Posts: 665
Joined: 10 Dec 2009, 15:32
Location: PeeKing, China

Who is online

Users browsing this forum: No registered users and 1 guest

cron