Following the instructions here, I’ve set up a CMakeLists.txt:
Find_Package (SDL REQUIRED)
Find_Package (SDL_image REQUIRED)
link_libraries (
${SDL_LIBRARY}
${SDLIMAGE_LIBRARY}
SDLmain
)
When running cmake, I get the following error:
ld: library not found for -lSDLmain
collect2: error: ld returned 1 exit status
make[2]: *** [src/GameOfLife] Error 1
Running g++ by hand gives the same error:
$ g++-4.7 -std=c++0x ../src/*.cpp -lSDLmain
ld: library not found for -lSDLmain
How do I fix this?
makedoesn’t know where to findSDLmain; I need to link to the directory usinglink_directoryin `CMakeLists.txt.Running
works fine, so I’ve clearly got SDL installed correctly. Checking the output of
sdl-config --libs:So the thing that’s not in the
CMakeLists.txtis the-L/opt/local/lib. That should be added into theCMakeLists.txtusinglink_directory:And then
cmakeruns fine.