I have my project, nested in another directory with the required libraries for my project. I'm using cmake that's bundled with Clion, 3.14. I am using subdirectories with cmake. I have it building just fine, but it's not linking SFML
Root-|
-lib1
-smfl
-lib3
-my_project
I've tried using things like using 'target_link_directories()' but either I did it wrong, or it's absolutely not the right option.
Root CMakeList.txt
cmake_minimum_required(VERSION 3.10)
include_directories("ChaiScript/include" Catch2/include freetype2/include SFML/include )
add_subdirectory(Catch2)
add_subdirectory(ChaiScript)
add_subdirectory(freetype2)
add_subdirectory(SFML)
add_subdirectory(Purrmaid)
./Purrmaid/CMakeList.txt
cmake_minimum_required (VERSION 3.10)
set(CMAKE_CXX_STANDARD 17)
project (purrmaid)
add_executable( purrmaid
main.cpp
Base_Object.cpp
...
ThreadManager.cpp)
target_link_libraries(purrmaid sfml-system sfml-window sfml-graphics sfml-network sfml-audio pthread dl)
../SFML/lib/libsfml-graphics-d.so.2.5.1: undefined reference to `FT_MulFix'
../SFML/lib/libsfml-graphics-d.so.2.5.1: undefined reference to `FT_Init_FreeType'
../SFML/lib/libsfml-graphics-d.so.2.5.1: undefined reference to `FT_Get_Char_Index'
../SFML/lib/libsfml-graphics-d.so.2.5.1: undefined reference to `FT_Get_Kerning'
../SFML/lib/libsfml-graphics-d.so.2.5.1: undefined reference to `FT_Get_Glyph'
../SFML/lib/libsfml-graphics-d.so.2.5.1: undefined reference to `FT_New_Face'
../SFML/lib/libsfml-graphics-d.so.2.5.1: undefined reference to `FT_Stroker_Set'
../SFML/lib/libsfml-graphics-d.so.2.5.1: undefined reference to `FT_Glyph_To_Bitmap'
../SFML/lib/libsfml-graphics-d.so.2.5.1: undefined reference to `FT_Outline_Embolden'
../SFML/lib/libsfml-graphics-d.so.2.5.1: undefined reference to `FT_Load_Char'
../SFML/lib/libsfml-graphics-d.so.2.5.1: undefined reference to `FT_Done_Glyph'
../SFML/lib/libsfml-graphics-d.so.2.5.1: undefined reference to `FT_Stroker_New'
../SFML/lib/libsfml-graphics-d.so.2.5.1: undefined reference to `FT_Open_Face'
../SFML/lib/libsfml-graphics-d.so.2.5.1: undefined reference to `FT_Glyph_Stroke'
../SFML/lib/libsfml-graphics-d.so.2.5.1: undefined reference to `FT_Bitmap_Embolden'
../SFML/lib/libsfml-graphics-d.so.2.5.1: undefined reference to `FT_Done_Face'
../SFML/lib/libsfml-graphics-d.so.2.5.1: undefined reference to `FT_New_Memory_Face'
../SFML/lib/libsfml-graphics-d.so.2.5.1: undefined reference to `FT_Stroker_Done'
../SFML/lib/libsfml-graphics-d.so.2.5.1: undefined reference to `FT_Done_FreeType'
../SFML/lib/libsfml-graphics-d.so.2.5.1: undefined reference to `FT_Set_Pixel_Sizes'
../SFML/lib/libsfml-graphics-d.so.2.5.1: undefined reference to `FT_Select_Charmap'
The error shown is that SFML cannot link because it cannot find reference to different FT_ symbols (FT_MulFix, FT_Init_FreeType, etc.)
These are defined by the FreeType library. I assume you are building the different SFML targets when you add_subdirectory(SFML)
In the CMakeLists.txt file in the SFML subdirectory, do you link the sfml-graphics target against Free type?
add_library(sfml-graphics
...)
# This is assuming you have a "freetype2" target available
# please replace by the actual name of the freetype target
target_link_libraries(sfml-graphics freetype2 ...)
EDIT: Thanks to Tsyvarev for pointing me in the direction of the actual target that was not able to link.
Related
I'm developing a dynamic C++17 library that uses SQLite. It's a CMake project and the requirement for it to be dynamic comes because I plan to mainly use the library through JNI.
So, in my project I build SQLite as a static library:
add_library(sqlite3 STATIC "${sqlite3_SOURCE_DIR}/sqlite3.c") # STATIC to efficiently link to SHARED main library
set_target_properties(sqlite3 PROPERTIES POSITION_INDEPENDENT_CODE ON) # Required to link STATIC to SHARED
target_include_directories(sqlite3 PUBLIC "${sqlite3_SOURCE_DIR}")
And my main library as shared:
add_library(${PROJECT_NAME} SHARED <library sources>)
target_compile_features(${PROJECT_NAME} PUBLIC cxx_std_17)
target_include_directories(${PROJECT_NAME} PRIVATE ${CMAKE_CURRENT_SOURCE_DIR}) # To include headers without using relative paths
target_link_libraries(${PROJECT_NAME} PRIVATE sqlite3)
Then if I link my library to some executable like this it builds and runs absolutely fine on my PC:
add_executable(app <app's sources>)
target_compile_features(app PUBLIC cxx_std_17)
target_include_directories(app PUBLIC ${CMAKE_CURRENT_SOURCE_DIR} <main library src dir>) # Including the main library like this is a temporary solution, because there is no separate include dir yet
target_link_libraries(app PUBLIC ${PROJECT_NAME})
But when I try to build it in GitHub Actions I get these errors:
[100%] Linking CXX executable app
/usr/bin/ld: ../src/mylib.so: undefined reference to `pthread_mutexattr_destroy'
/usr/bin/ld: ../src/mylib.so: undefined reference to `pthread_create'
/usr/bin/ld: ../src/mylib.so: undefined reference to `dlopen'
/usr/bin/ld: ../src/mylib.so: undefined reference to `pthread_mutex_trylock'
/usr/bin/ld: ../src/mylib.so: undefined reference to `dlclose'
/usr/bin/ld: ../src/mylib.so: undefined reference to `dlerror'
/usr/bin/ld: ../src/mylib.so: undefined reference to `dlsym'
/usr/bin/ld: ../src/mylib.so: undefined reference to `pthread_mutexattr_settype'
/usr/bin/ld: ../src/mylib.so: undefined reference to `pthread_join'
/usr/bin/ld: ../src/mylib.so: undefined reference to `pthread_mutexattr_init'
collect2: error: ld returned 1 exit status
I can fix it by linking the library target to ${CMAKE_DL_LIBS} and Threads::Threads, but I'm not sure if I'm doing what should be done and not just silencing some other mistakes of mine.
To be clear, I don't use any of the functions mentioned in the errors above in the code of my library.
The questions are:
Why does the original code work on my PC and doesn't on GitHub Actions?
Is what I did the right way to fix this?
I'm building the project locally on Ubuntu 22.04 (WSL) with a compiler identified as GNU 11.3.0, while GitHub Actions runs Ubuntu 20.04 using GNU 9.4.0 compiler.
This question already has answers here:
How to add "-l" (ell) compiler flag in CMake
(2 answers)
Closed 3 years ago.
I am trying to use curl inside c++ code. How should i do it properly ?
I have pasted libcurl.a & libcurl.dll.a in this directory:
C:\Program Files\mingw-w64\x86_64-8.1.0-posix-seh-rt_v6-rev0\mingw64\lib
This is my CMakeLists.txt from CLion/Mingw
cmake_minimum_required(VERSION 3.3)
project(tan)
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -std=c++14 -lcurl.dll")
add_executable(tan Tan/mail.cpp)
project(untitled6)
When I add "#define CURL_STATICLIB" i get these errors:
reference to `curl_easy_init'
C:/Users/John/CLionProjects/tan/Tan/mail.cpp:84: undefined
reference to `curl_easy_setopt'
C:/Users/John/CLionProjects/tan/Tan/mail.cpp:86: undefined reference to `curl_easy_setopt'
C:/Users/John/CLionProjects/tan/Tan/mail.cpp:91: undefined reference to `curl_slist_append'
C:/Users/John/CLionProjects/tan/Tan/mail.cpp:92: undefined reference to `curl_slist_append'
C:/Users/John/CLionProjects/tan/Tan/mail.cpp:93: undefined reference to `curl_easy_setopt'
C:/Users/John/CLionProjects/tan/Tan/mail.cpp:98: undefined reference to `curl_easy_setopt'
C:/Users/John/CLionProjects/tan/Tan/mail.cpp:99: undefined reference to `curl_easy_setopt'
C:/Users/John/CLionProjects/tan/Tan/mail.cpp:100: undefined reference to `curl_easy_setopt'
C:/Users/John/CLionProjects/tan/Tan/mail.cpp:103: undefined reference to `curl_easy_perform'
C:/Users/John/CLionProjects/tan/Tan/mail.cpp:107: undefined reference to `curl_easy_strerror'
C:/Users/John/CLionProjects/tan/Tan/mail.cpp:111: undefined reference to `curl_slist_free_all'
C:/Users/John/CLionProjects/tan/Tam/mail.cpp:121: undefined reference to ````curl_easy_cleanup
Without "#define CURL_STATICLIB" i get these errors:
CMakeFiles\tan.dir/objects.a(mail.cpp.obj): In function `main':
C:/Users/John/CLionProjects/tan/Tan/mail.cpp:81: undefined reference to `__imp_curl_easy_init'
C:/Users/John/CLionProjects/tan/Tan/mail.cpp:84: undefined reference to `__imp_curl_easy_setopt'
C:/Users/John/CLionProjects/tan/Tan/mail.cpp:86: undefined reference to `__imp_curl_easy_setopt'
C:/Users/John/CLionProjects/tan/Tan/mail.cpp:91: undefined reference to `__imp_curl_slist_append'
C:/Users/John/CLionProjects/tan/Tan/mail.cpp:92: undefined reference to `__imp_curl_slist_append'
C:/Users/John/CLionProjects/tan/Tan/mail.cpp:93: undefined reference to `__imp_curl_easy_setopt'
C:/Users/John/CLionProjects/tan/Tan/mail.cpp:98: undefined reference to `__imp_curl_easy_setopt'
C:/Users/John/CLionProjects/tan/Tan/mail.cpp:99: undefined reference to `__imp_curl_easy_setopt'
C:/Users/John/CLionProjects/tan/Tan/mail.cpp:100: undefined reference to `__imp_curl_easy_setopt'
C:/Users/John/CLionProjects/tan/Tan/mail.cpp:103: undefined reference to `__imp_curl_easy_perform'
C:/Users/John/CLionProjects/tan/Tan/mail.cpp:107: undefined reference to `__imp_curl_easy_strerror'
C:/Users/John/CLionProjects/tan/Tan/mail.cpp:111: undefined reference to `__imp_curl_slist_free_all'
C:/Users/John/CLionProjects/tan/Tan/mail.cpp:121: undefined reference to `__imp_curl_easy_cleanup'
If anybody comes looking use this in CMakeLists.txt. The last line solved the issue.
Step1:
Copy libcurl.dll.a in C:/curl.
No need to copy "libcurl.a" OR "libcurl.dll.a" at any other place.
No need for #define CURL_STATICLIB in main.cpp file
Step2: Edit the CMakeLists.txt as below.
set(CMAKE_CXX_STANDARD 14)
add_executable(tan Tan/mail.cpp)
project(untitled6)
target_link_libraries(tan "C:/curl/libcurl.dll.a")
Step3: If your program flashes quickly and closes. You might be missing some dll files. To check which ones you are missing , run the program (in my case tan.exe) with cmd. Take that dll from curl package (in my case curl-7.65.0-win64-mingw) and put it along side of your executable file. Make sure curl and your executable is compiled with same compiler. In my case it's Mingw.
I'm trying to create a Node.js addon in C++ following the example provided in this guide.
I've linked the node.h and v8.h libraries setting my CMakeLists.txt in this way:
cmake_minimum_required(VERSION 3.6) project(node___C__)
set(CMAKE_CXX_STANDARD 11)
set(SOURCE_FILES main.cpp)
add_executable(node___C__ ${SOURCE_FILES})
include_directories(/usr/include/nodejs/src)
include_directories(/usr/include/nodejs/deps/v8/include)
I think libraries are correctly setted in my CMakeList.txt but when I try to compile the file in Clion I get this error:
/usr/include/nodejs/src/node.h:239: undefined reference to `v8::Isolate::GetCurrent()'
/usr/include/nodejs/src/node.h:240: undefined reference to `v8::HandleScope::HandleScope(v8::Isolate*)'
/usr/include/nodejs/src/node.h:242: undefined reference to `v8::FunctionTemplate::New(v8::Isolate*, void (*)(v8::FunctionCallbackInfo<v8::Value> const&), v8::Local<v8::Value>, v8::Local<v8::Signature>, int)'
/usr/include/nodejs/src/node.h:243: undefined reference to `v8::FunctionTemplate::GetFunction()'
/usr/include/nodejs/src/node.h:244: undefined reference to `v8::String::NewFromUtf8(v8::Isolate*, char const*, v8::String::NewStringType, int)'
/usr/include/nodejs/src/node.h:245: undefined reference to `v8::Function::SetName(v8::Local<v8::String>)'
/usr/include/nodejs/src/node.h:246: undefined reference to `v8::Object::Set(v8::Local<v8::Value>, v8::Local<v8::Value>)'
/usr/include/nodejs/src/node.h:240: undefined reference to `v8::HandleScope::~HandleScope()'
/usr/include/nodejs/src/node.h:240: undefined reference to `v8::HandleScope::~HandleScope()'
What I'm doing wrong? I'm quite new with C++ so maybe I'm doing some dumb mistake.
I've forgot to link some dependencies?
I am trying to link glew and glfw on clion with cmake. I did it with visual studio easilly, but I am having problems with clion. This is how I have included my dependencies like glew (.dll shouldnt be there I guess):
And this is my cmake file.
cmake_minimum_required(VERSION 3.6)
project(Course)
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -std=gnu++11")
find_package(OpenGL REQUIRED)
include_directories(${CMAKE_CURRENT_SOURCE_DIR}/Dependencies/GLFW/include)
link_directories(${CMAKE_CURRENT_SOURCE_DIR}/Dependencies/GLFW/libs)
include_directories(${CMAKE_CURRENT_SOURCE_DIR}/Dependencies/GLEW/include)
link_directories(${CMAKE_CURRENT_SOURCE_DIR}/Dependencies/GLEW/libs)
set(SOURCE_FILES main.cpp Window.cpp Window.h)
add_executable(Course ${SOURCE_FILES})
target_link_libraries(Course ${OPENGL_LIBRARY} libglew32.a libglfw3.a )
Error:
C:/Users/Onur/Documents/MEGA/workspace/cpp/Course/Dependencies/GLEW/libs\libglew32.a(glew.o):glew.c:(.text+0x42c): undefined reference to `wglGetProcAddress#4'
C:/Users/Onur/Documents/MEGA/workspace/cpp/Course/Dependencies/GLEW/libs\libglew32.a(glew.o):glew.c:(.text+0x448): undefined reference to `wglGetProcAddress#4'
C:/Users/Onur/Documents/MEGA/workspace/cpp/Course/Dependencies/GLEW/libs\libglew32.a(glew.o):glew.c:(.text+0x464): undefined reference to `wglGetProcAddress#4'
C:/Users/Onur/Documents/MEGA/workspace/cpp/Course/Dependencies/GLEW/libs\libglew32.a(glew.o):glew.c:(.text+0x478): undefined reference to `wglGetProcAddress#4'
C:/Users/Onur/Documents/MEGA/workspace/cpp/Course/Dependencies/GLEW/libs\libglew32.a(glew.o):glew.c:(.text+0x48c): undefined reference to `wglGetProcAddress#4'
C:/Users/Onur/Documents/MEGA/workspace/cpp/Course/Dependencies/GLEW/libs\libglew32.a(glew.o):glew.c:(.text+0x4a0): more undefined references to `wglGetProcAddress#4' follow
C:/Users/Onur/Documents/MEGA/workspace/cpp/Course/Dependencies/GLEW/libs\libglew32.a(glew.o):glew.c:(.text+0x1de1f): undefined reference to `wglGetCurrentDC#0'
C:/Users/Onur/Documents/MEGA/workspace/cpp/Course/Dependencies/GLEW/libs\libglew32.a(glew.o):glew.c:(.text+0x1de8f): undefined reference to `wglGetProcAddress#4'
C:/Users/Onur/Documents/MEGA/workspace/cpp/Course/Dependencies/GLEW/libs\libglew32.a(glew.o):glew.c:(.text+0x1dea3): undefined reference to `wglGetProcAddress#4'
C:/Users/Onur/Documents/MEGA/workspace/cpp/Course/Dependencies/GLEW/libs\libglew32.a(glew.o):glew.c:(.text+0x1debe): undefined reference to `wglGetCurrentDC#0'
C:/Users/Onur/Documents/MEGA/workspace/cpp/Course/Dependencies/GLEW/libs\libglew32.a(glew.o):glew.c:(.text+0x1df3a): undefined reference to `wglGetProcAddress#4'
C:/Users/Onur/Documents/MEGA/workspace/cpp/Course/Dependencies/GLEW/libs\libglew32.a(glew.o):glew.c:(.text+0x1e0c0): undefined reference to `wglGetProcAddress#4'
C:/Users/Onur/Documents/MEGA/workspace/cpp/Course/Dependencies/GLEW/libs\libglew32.a(glew.o):glew.c:(.text+0x1e0dc): undefined reference to `wglGetProcAddress#4'
C:/Users/Onur/Documents/MEGA/workspace/cpp/Course/Dependencies/GLEW/libs\libglew32.a(glew.o):glew.c:(.text+0x1e0fa): undefined reference to `wglGetProcAddress#4'
C:/Users/Onur/Documents/MEGA/workspace/cpp/Course/Dependencies/GLEW/libs\libglew32.a(glew.o):glew.c:(.text+0x1e4dc): undefined reference to `wglGetProcAddress#4'
C:/Users/Onur/Documents/MEGA/workspace/cpp/Course/Dependencies/GLEW/libs\libglew32.a(glew.o):glew.c:(.text+0x1e4f8): more undefined references to `wglGetProcAddress#4' follow
C:/Users/Onur/Documents/MEGA/workspace/cpp/Course/Dependencies/GLEW/libs\libglew32.a(glew.o):glew.c:(.text+0x20352): undefined reference to `glGetString#4'
C:/Users/Onur/Documents/MEGA/workspace/cpp/Course/Dependencies/GLEW/libs\libglew32.a(glew.o):glew.c:(.text+0x204d4): undefined reference to `glGetIntegerv#8'
C:/Users/Onur/Documents/MEGA/workspace/cpp/Course/Dependencies/GLEW/libs\libglew32.a(glew.o):glew.c:(.text+0x204e3): undefined reference to `wglGetProcAddress#4'
C:/Users/Onur/Documents/MEGA/workspace/cpp/Course/Dependencies/GLEW/libs\libglew32.a(glew.o):glew.c:(.text+0x2055e): undefined reference to `wglGetProcAddress#4'
C:/Users/Onur/Documents/MEGA/workspace/cpp/Course/Dependencies/GLEW/libs\libglew32.a(glew.o):glew.c:(.text+0x2057a): undefined reference to `wglGetProcAddress#4'
C:/Users/Onur/Documents/MEGA/workspace/cpp/Course/Dependencies/GLEW/libs\libglew32.a(glew.o):glew.c:(.text+0x20596): undefined reference to `wglGetProcAddress#4'
C:/Users/Onur/Documents/MEGA/workspace/cpp/Course/Dependencies/GLEW/libs\libglew32.a(glew.o):glew.c:(.text+0x205ac): undefined reference to `wglGetProcAddress#4'
C:/Users/Onur/Documents/MEGA/workspace/cpp/Course/Dependencies/GLEW/libs\libglew32.a(glew.o):glew.c:(.text+0x20665): more undefined references to `wglGetProcAddress#4' follow
C:/Users/Onur/Documents/MEGA/workspace/cpp/Course/Dependencies/GLEW/libs\libglew32.a(glew.o):glew.c:(.text+0x26e21): undefined reference to `glGetString#4'
C:/Users/Onur/Documents/MEGA/workspace/cpp/Course/Dependencies/GLEW/libs\libglew32.a(glew.o):glew.c:(.text+0x26f31): undefined reference to `wglGetProcAddress#4'
C:/Users/Onur/Documents/MEGA/workspace/cpp/Course/Dependencies/GLEW/libs\libglew32.a(glew.o):glew.c:(.text+0x26f47): undefined reference to `wglGetProcAddress#4'
C:/Users/Onur/Documents/MEGA/workspace/cpp/Course/Dependencies/GLEW/libs\libglew32.a(glew.o):glew.c:(.text+0x26f60): undefined reference to `wglGetProcAddress#4'
C:/Users/Onur/Documents/MEGA/workspace/cpp/Course/Dependencies/GLEW/libs\libglew32.a(glew.o):glew.c:(.text+0x26f7b): undefined reference to `wglGetProcAddress#4'
C:/Users/Onur/Documents/MEGA/workspace/cpp/Course/Dependencies/GLEW/libs\libglew32.a(glew.o):glew.c:(.text+0x26f8f): undefined reference to `wglGetProcAddress#4'
C:/Users/Onur/Documents/MEGA/workspace/cpp/Course/Dependencies/GLEW/libs\libglew32.a(glew.o):glew.c:(.text+0x26fa3): more undefined references to `wglGetProcAddress#4' follow
Seems like cmake can't find glew (but I told it where glew is?):
Edit:
Adding ${OPENGL_LIBRARIES} at the end of target_link_libraries worked
cmake_minimum_required(VERSION 3.6)
project(Course)
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -std=gnu++11")
find_package(OpenGL REQUIRED)
include_directories(${CMAKE_CURRENT_SOURCE_DIR}/Dependencies/GLFW/include)
link_directories(${CMAKE_CURRENT_SOURCE_DIR}/Dependencies/GLFW/libs)
include_directories(${CMAKE_CURRENT_SOURCE_DIR}/Dependencies/GLEW/include/GL)
link_directories(${CMAKE_CURRENT_SOURCE_DIR}/Dependencies/GLEW/libs)
set(SOURCE_FILES main.cpp Window.cpp Window.h)
add_executable(Course ${SOURCE_FILES})
target_link_libraries(Course glfw3.a libglew32.a ${OPENGL_LIBRARIES})
I am trying to build my project using CMake but I am having error linking required libraries. I have this CMakeLists.txt in the root folder of my project:
cmake_minimum_required(VERSION 2.6)
project(test)
add_subdirectory(src)
And in my src folder, alongside my source files I have this CMakeLists.txt:
set (CMAKE_CXX_FLAGS "Wall -std=c++11" )
set (CMAKE_EXE_LINKER_FLAGS "-lSDL2 -lGL" )
file (GLOB SRCS *.cpp *.h )
add_executable(engine ${SRCS} )
I then go into the build folder and do cmake .. and it runs without any errors. When I do make, the compilation runs without any errors as well, but when it gets to the linking part, I get these errors:
CMakeFiles/test.dir/Application.cpp.o: In function `Application::onExecute()':
Application.cpp:(.text+0x41): undefined reference to `SDL_GetTicks'
Application.cpp:(.text+0x4e): undefined reference to `SDL_GetTicks'
Application.cpp:(.text+0xd7): undefined reference to `SDL_PollEvent'
CMakeFiles/test.dir/Application.cpp.o: In function `Application::render()':
Application.cpp:(.text+0x17b): undefined reference to `glClearColor'
Application.cpp:(.text+0x185): undefined reference to `glClear'
Application.cpp:(.text+0x194): undefined reference to `SDL_GL_SwapWindow'
CMakeFiles/test.dir/Application.cpp.o: In function `Application::cleanUp()':
Application.cpp:(.text+0x1b2): undefined reference to `SDL_GL_DeleteContext'
Application.cpp:(.text+0x1c1): undefined reference to `SDL_DestroyWindow'
Application.cpp:(.text+0x1c6): undefined reference to `SDL_Quit'
CMakeFiles/test.dir/Application.cpp.o: In function `Application::initialize()':
Application.cpp:(.text+0x1de): undefined reference to `SDL_Init'
Application.cpp:(.text+0x1ea): undefined reference to `SDL_GetError'
Application.cpp:(.text+0x22b): undefined reference to `SDL_CreateWindow'
Application.cpp:(.text+0x243): undefined reference to `SDL_GetError'
Application.cpp:(.text+0x25a): undefined reference to `SDL_Quit'
Application.cpp:(.text+0x270): undefined reference to `SDL_GL_SetAttribute'
Application.cpp:(.text+0x27f): undefined reference to `SDL_GL_SetAttribute'
Application.cpp:(.text+0x28e): undefined reference to `SDL_GL_SetAttribute'
Application.cpp:(.text+0x29d): undefined reference to `SDL_GL_CreateContext'
Application.cpp:(.text+0x2af): undefined reference to `glGetString'
collect2: error: ld returned 1 exit status
make[2]: *** [src/test] Error 1
make[1]: *** [src/CMakeFiles/test.dir/all] Error 2
make: *** [all] Error 2
I have the correct includes in my header files and I was able to compile and run using only make so I think the linker flags I tell CMake aren't being passed to the compiler. How can I fix this?
You have to use the cmake command target_link_libraries to reference SDL libs.