gpt4 book ai didi

c++ - CMake:在 Windows 上找不到编译器

转载 作者:可可西里 更新时间:2023-11-01 10:33:19 25 4
gpt4 key购买 nike

当我运行它时:cmake -G "Visual Studio 15 2017 Win64"

我有这个输出:

-- The C compiler identification is unknown
-- The CXX compiler identification is unknown
CMake Error at CMakeLists.txt:2 (project):
No CMAKE_C_COMPILER could be found.

CMake Error at CMakeLists.txt:2 (project):
No CMAKE_CXX_COMPILER could be found.

-- Configuring incomplete, errors occurred!
See also "C:/Users/ce/type/CMakeFiles/CMakeOutput.log".
See also "C:/Users/ce/type/CMakeFiles/CMakeError.log".

这是我的CMakeLists(我已经删除了例子中无用的东西)

cmake_minimum_required(VERSION 3.4)
project(type)

option(BUILD_CLIENT "Build Client" ON)
option(BUILD_SERVER "Build Server" ON)

set(CLIENT_NAME "type_client")
set(SERVER_NAME "type_server")

set(CLIENT_SRCDIR "client/src/")
set(SERVER_SRCDIR "server/src/")

set(INC_DIR_CLIENT "client/includes")
set(INC_DIR_SERVER "server/includes")
set(INC_DIR_DLLOADER "DLLoader/")
set(INC_DIR_ECS "ecs/")
set(INC_DIR_PROTOCOL "protocol/")

set(LIB_LINKS "-ldl -lpthread")

set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS}")

set(CLIENT_SOURCE_FILES
${CLIENT_SRCDIR}main.cpp)

set(SERVER_SOURCE_FILES
${SERVER_SRCDIR}main.cpp)

set(SERVER_SOURCE_FILES_SYSTEMS)

set(CMAKE_MODULE_PATH "${CMAKE_SOURCE_DIR}/cmake_modules" ${CMAKE_MODULE_PATH})
if(WIN32)
set(SFML_ROOT "dependancies/windows/SFML-2.4.1")
elseif(UNIX)
set(SFML_ROOT "dependancies/linux/SFML-2.4.1")
endif()
find_package(SFML 2 REQUIRED system window graphics network audio)

install(TARGETS ${EXECUTABLE_NAME} DESTINATION bin)

if(WIN32)
include_directories(${INC_DIR_DLLOADER}/win)
elseif(UNIX)
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wall -Wextra")
include_directories(${INC_DIR_DLLOADER}/linux)

set(SFML_ROOT "dependancies/SFML-2.4.1")
endif()

include_directories(${SFML_INCLUDE_DIR})

if(BUILD_CLIENT)
add_executable(${CLIENT_NAME} ${CLIENT_SOURCE_FILES})
target_link_libraries(${CLIENT_NAME} ${SFML_LIBRARIES} ${LIB_LINKS})
endif()

if(BUILD_SERVER)
if(WIN32)
add_executable(${SERVER_NAME} ${SERVER_SOURCE_FILES}
${SERVER_SOURCE_FILES_SYSTEMS} ${SERVER_SOURCE_FILES_WIN})
target_link_libraries(${SERVER_NAME} -lws2_32)

elseif(UNIX)
add_executable(${SERVER_NAME} ${SERVER_SOURCE_FILES}
${SERVER_SOURCE_FILES_SYSTEMS} ${SERVER_SOURCE_FILES_LINUX})
target_link_libraries(${SERVER_NAME} ${LIB_LINKS})
endif()
endif()

我用 Visual Studio 安装了 C++ 编译器,所以我不明白为什么没有检测到编译器。

最佳答案

尝试用 cmake -G "Visual Studio 14 2015" 编译

关于c++ - CMake:在 Windows 上找不到编译器,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/41333539/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com