Clion上的SFML无法编译窗口程序

时间:2018-12-23 08:38:57

标签: cmake compilation sfml clion

Key: Level Value: True
Key: LevelText Value: Level
Key: Stepped Value: False
Key: SteppedText Value: Stepped
Key: DifferentPropetyNameinFuture Value: False
Key: DifferentPropetyNameinFutureText Value: stringValue

我的CmakeList:

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

如果我想使用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() 编写窗口程序,则会出现此错误。我正在使用MinGW在Clion中工作。

我在项目编译中遇到的问题。这段代码:

RenderWindow

不与以上错误一起编译。

0 个答案:

没有答案