I am currently trying to install the SDL library with C++ and Clion. I watched many youtube videos and googled the errors but still cannot find a way to fix this error.
"C:\Program Files\JetBrains\CLion 2021.1.2\bin\cmake\win\bin\cmake.exe" --build D:\Programing\C++\School\HackClub\Day2\cmake-build-debug --target Day2 -- -j 6
[ 50%] Linking CXX executable Day2.exe
C:/PROGRA~1/MINGW-~1/X86_64~1.0-P/mingw64/bin/../lib/gcc/x86_64-w64-mingw32/8.1.0/../../../../x86_64-w64-mingw32/bin/ld.exe: cannot find -lSDL2main
C:/PROGRA~1/MINGW-~1/X86_64~1.0-P/mingw64/bin/../lib/gcc/x86_64-w64-mingw32/8.1.0/../../../../x86_64-w64-mingw32/bin/ld.exe: cannot find -lSDL2
collect2.exe: error: ld returned 1 exit status
mingw32-make.exe[3]: *** [CMakeFiles\Day2.dir\build.make:95: Day2.exe] Error 1
mingw32-make.exe[2]: *** [CMakeFiles\Makefile2:82: CMakeFiles/Day2.dir/all] Error 2
mingw32-make.exe[1]: *** [CMakeFiles\Makefile2:89: CMakeFiles/Day2.dir/rule] Error 2
mingw32-make.exe: *** [Makefile:123: Day2] Error
Here is my CMAKE file.
project(Day2)
set(CMAKE_CXX_STANDARD 14)
set(SDL2_INCLUDE_DIR D:\\Programing\\C++\\libs\\SDL\\include)
set(SDL2_LIBRARY D:\\Programing\\C++\\libs\\SDL\\lib\\x86)
include_directories(${SDL2_INCLUDE_DIR})
add_executable(${PROJECT_NAME} main.cpp)
target_link_libraries(${PROJECT_NAME} ${SDL2_LIBRARY})
target_link_libraries(${PROJECT_NAME} SDL2main SDL2)
Related
I use c++ project with opencv and dlib libraries. I have CMakeLists.txt:
cmake_minimum_required(VERSION 3.20.0)
project(project1)
find_package(OpenCV REQUIRED)
include(FetchContent)
FetchContent_Declare(dlib
GIT_REPOSITORY https://github.com/davisking/dlib.git
GIT_TAG v19.18
)
FetchContent_MakeAvailable(dlib)
add_executable(project1 main.cpp)
target_link_libraries(project1 ${OpenCV_LIBS} dlib::dlib)
target_compile_options(project1 PUBLIC "$<$<CONFIG:RELEASE>:${MY_RELEASE_OPTIONS}>")
I write in cygwin cmake .. -G "Unix Makefiles". I use "Unix Makefiles" to create makefile that use to command "make". After this I write make, but as a result I get error:
collect2: error: ld execution ended with return code 1
make[2]: *** [CMakeFiles/project1.dir/build.make:123: project1.exe] Error 1
make[1]: *** [CMakeFiles/Makefile2:115: CMakeFiles/project1.dir/all] Error 2
make: *** [Makefile:91: all] Error 2
What I need to do to fix this problem?
im learning boost,i want to link boost_thread.lib,so here are my CMakeLists:
cmake_minimum_required(VERSION 3.19)
project(boost)
set(CMAKE_CXX_STANDARD 20)
include_directories(${PROJECT_SOURCE_DIR}/include)
link_directories(${PROJECT_SOURCE_DIR}/lib)
aux_source_directory(. DIR_SRCS)
add_executable(main ${DIR_SRCS})
target_link_libraries(main boost_thread pthread)
here are myproject structure
enter image description here
error:
C:/PROGRA~1/MINGW-~1/mingw64/bin/../lib/gcc/x86_64-w64-mingw32/8.1.0/../../../../x86_64-w64-mingw32/bin/ld.exe: cannot find -lboost_thread
collect2.exe: error: ld returned 1 exit status
mingw32-make.exe[3]: *** [CMakeFiles\main.dir\build.make:105: ../bin/main.exe] Error 1
mingw32-make.exe[2]: *** [CMakeFiles\Makefile2:94: CMakeFiles/main.dir/all] Error 2
mingw32-make.exe[1]: *** [CMakeFiles\Makefile2:101: CMakeFiles/main.dir/rule] Error 2
mingw32-make.exe: *** [Makefile:136: main] Error 2
where are wrong?thank for help
I have been pulling out of my hair because of CMakelists.txt. I would like to create a C++ application with GLFW, GLEW libraries, using MinGW and CLion IDE.
Here is my CMakeLists.txt:
cmake_minimum_required(VERSION 3.17.3)
project(imguiTask)
set(CMAKE_CXX_STANDARD 17)
add_compile_options(-DGLEW_NO_GLU)
add_executable(${PROJECT_NAME}
src/main.cpp
src/imgui.cpp
src/imgui_draw.cpp
src/imgui_widgets.cpp
)
target_include_directories(${PROJECT_NAME} PUBLIC includes)
add_library(libraries STATIC IMPORTED)
target_link_libraries(${PROJECT_NAME} glfw3)
I placed the needed libraries in the libraries folder as you can see in the picture. The folder is located in the project root. It is giving me the following error:
d:/mingw/bin/../lib/gcc/mingw32/9.2.0/../../../../mingw32/bin/ld.exe: cannot find -lglfw3
collect2.exe: error: ld returned 1 exit status
mingw32-make.exe[3]: *** [imguiTask.exe] Error 1
mingw32-make.exe[2]: *** [CMakeFiles/imguiTask.dir/all] Error 2
mingw32-make.exe[1]: *** [CMakeFiles/imguiTask.dir/rule] Error 2
mingw32-make.exe: *** [imguiTask] Error 2
It seeems to me, that it does not search in the folder I specified. I don't know why.
I've been trying to get SDL2 to link with my project but I think my cmake file is no good. I get this error
====================[ Build | Chip_8_Interpreter | Debug ]======================
"C:\Program Files\JetBrains\CLion 2018.3.4\bin\cmake\win\bin\cmake.exe" --build "D:\Dropbox\Programming\Chip-8 Interpreter\cmake-build-debug" --target Chip_8_Interpreter -- -j 4
[ 50%] Linking CXX executable Chip_8_Interpreter.exe
c:/mingw/bin/../lib/gcc/mingw32/6.3.0/../../../libmingw32.a(main.o):(.text.startup+0xa0): undefined reference to `WinMain#16'
collect2.exe: error: ld returned 1 exit status
mingw32-make.exe[3]: *** [Chip_8_Interpreter.exe] Error 1
CMakeFiles\Chip_8_Interpreter.dir\build.make:87: recipe for target 'Chip_8_Interpreter.exe' failed
mingw32-make.exe[2]: *** [CMakeFiles/Chip_8_Interpreter.dir/all] Error 2
CMakeFiles\Makefile2:71: recipe for target 'CMakeFiles/Chip_8_Interpreter.dir/all' failed
mingw32-make.exe[1]: *** [CMakeFiles/Chip_8_Interpreter.dir/rule] Error 2
CMakeFiles\Makefile2:83: recipe for target 'CMakeFiles/Chip_8_Interpreter.dir/rule' failed
mingw32-make.exe: *** [Chip_8_Interpreter] Error 2
Makefile:117: recipe for target 'Chip_8_Interpreter' failed
And currently my CMakeLists.txt looks like this
cmake_minimum_required(VERSION 3.14)
project(Chip_8_Interpreter)
set(CMAKE_CXX_STANDARD 14)
# include cmake/FindSDL2.cmake
set(SDL2_PATH "C:\\SDL2-2.0.12\\i686-w64-mingw32")
set(CMAKE_MODULE_PATH ${PROJECT_SOURCE_DIR}/cmake)
find_package(SDL2 REQUIRED)
include_directories(${SDL2_INCLUDE_DIR})
add_executable(Chip_8_Interpreter main.cpp)
target_link_libraries(Chip_8_Interpreter ${SDL2_LIBRARY} -lmingw32 -lSDL2main -lSDL2 -mwindows)
And my main.cpp is just the basic SDL example. I've also recently installed MinGW and SDL2, so they should both be the newest stable release.
I have Clion IDE on Kubuntu 15.04. I have problem, when i build my application there is this problem :
/home/pierre/Bureau/CLion/bin/cmake/bin/cmake --build /home/pierre/.CLion12/system/cmake/generated/2a804d19/2a804d19/Debug --target WCPLauncher -- -j 4
Scanning dependencies of target WCPLauncher
[ 50%] Linking CXX executable WCPLauncher
/home/pierre/Qt5.0.2/5.0.2/gcc/lib/libQt5Widgets.so.5.0.2: error adding symbols: Fichier dans un mauvais format
collect2: error: ld returned 1 exit status
CMakeFiles/WCPLauncher.dir/build.make:97: recipe for target 'WCPLauncher' failed
make[3]: *** [WCPLauncher] Error 1
CMakeFiles/Makefile2:67: recipe for target 'CMakeFiles/WCPLauncher.dir/all' failed
make[2]: *** [CMakeFiles/WCPLauncher.dir/all] Error 2
CMakeFiles/Makefile2:79: recipe for target 'CMakeFiles/WCPLauncher.dir/rule' failed
make[1]: *** [CMakeFiles/WCPLauncher.dir/rule] Error 2
Makefile:118: recipe for target 'WCPLauncher' failed
make: *** [WCPLauncher] Error 2
This is my cmake.txt :
cmake_minimum_required(VERSION 3.2)
project(WCPLauncher)
set(CMAKE_INCLUDE_CURRENT_DIR ON)
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -std=c++11")
set(SOURCE_FILES main.cpp)
add_executable(WCPLauncher ${SOURCE_FILES})
find_package( Qt5Core REQUIRED )
find_package( Qt5Widgets REQUIRED )
find_package( Qt5Gui REQUIRED )
qt5_use_modules( WCPLauncher Core Widgets Gui )
Thanks !