Error:
CMakeFiles\Aqu.dir/objects.a(main.cpp.obj): In function main':
C:/Users/Admin/CLionProjects/Aqu/main.cpp:5: undefined reference to sf::String::String(char const*, std::locale const&)'
C:/Users/Admin/CLionProjects/Aqu/main.cpp:5: undefined reference to sf::VideoMode::VideoMode(unsigned int, unsigned int, unsigned int)'
C:/Users/Admin/CLionProjects/Aqu/main.cpp:5: undefined reference to sf::RenderWindow::RenderWindow(sf::VideoMode, sf::String const&, unsigned int, sf::ContextSettings const&)'
C:/Users/Admin/CLionProjects/Aqu/main.cpp:6: undefined reference to sf::Window::display()'
C:/Users/Admin/CLionProjects/Aqu/main.cpp:5: undefined reference to sf::RenderWindow::~RenderWindow()'
C:/Users/Admin/CLionProjects/Aqu/main.cpp:5: undefined reference to sf::RenderWindow::~RenderWindow()'
collect2.exe: error: ld returned 1 exit status
mingw32-make.exe[3]: *** [CMakeFiles\Aqu.dir\build.make:105: Aqu.exe] Error 1
mingw32-make.exe[2]: *** [CMakeFiles\Makefile2:72: CMakeFiles/Aqu.dir/all] Error 2
mingw32-make.exe[1]: *** [CMakeFiles\Makefile2:84: CMakeFiles/Aqu.dir/rule] Error 2
mingw32-make.exe: *** [Makefile:117: Aqu] Error 2
Мои списки CmakeLists:
cmake_minimum_required(VERSION 3.12)
project(Aqu)
set(CMAKE_CXX_STANDARD 17)
set(CMAKE_EXE_LINKER_FLAGS "-static -static-libgcc")
set(SFML_STATIC_LIBRARIES TRUE)
add_executable(Aqu main.cpp)
set(SFML_ROOT "C:/Program Files/SFML-2.4.2")
set(CMAKE_MODULE_PATH "${SFML_ROOT}/cmake/Modules")
find_package(SFML 2 REQUIRED graphics network audio window system)
if(SFML_FOUND)
include_directories(${SFML_INCLUDE_DIR})
target_link_libraries(${PROJECT_NAME} ${SFML_LIBRARIES}
${SFML_DEPENDENCIES})
endif()
Если я хочу написать оконную программу, используя RenderWindow
, я получаю эту ошибку.Я работаю в Clion, используя MinGW.
Моя проблема при компиляции проекта.Этот код:
#include <iostream>
#include <SFML/Graphics.hpp>
#include <SFML/System.hpp>
using namespace sf;
int main(){
RenderWindow window(VideoMode(200, 300), "11");
window.display();
return 0;
}
не компилируется с вышеуказанной ошибкой.