<legend id='dzkhW'><style id='dzkhW'><dir id='dzkhW'><q id='dzkhW'></q></dir></style></legend>
      <bdo id='dzkhW'></bdo><ul id='dzkhW'></ul>

    1. <small id='dzkhW'></small><noframes id='dzkhW'>

      <i id='dzkhW'><tr id='dzkhW'><dt id='dzkhW'><q id='dzkhW'><span id='dzkhW'><b id='dzkhW'><form id='dzkhW'><ins id='dzkhW'></ins><ul id='dzkhW'></ul><sub id='dzkhW'></sub></form><legend id='dzkhW'></legend><bdo id='dzkhW'><pre id='dzkhW'><center id='dzkhW'></center></pre></bdo></b><th id='dzkhW'></th></span></q></dt></tr></i><div id='dzkhW'><tfoot id='dzkhW'></tfoot><dl id='dzkhW'><fieldset id='dzkhW'></fieldset></dl></div>
      1. <tfoot id='dzkhW'></tfoot>
      2. CMake 无法使用 C++ 确定链接器语言

        时间:2023-08-28
        <tfoot id='j51Xu'></tfoot>
            • <bdo id='j51Xu'></bdo><ul id='j51Xu'></ul>

                  <tbody id='j51Xu'></tbody>
                <i id='j51Xu'><tr id='j51Xu'><dt id='j51Xu'><q id='j51Xu'><span id='j51Xu'><b id='j51Xu'><form id='j51Xu'><ins id='j51Xu'></ins><ul id='j51Xu'></ul><sub id='j51Xu'></sub></form><legend id='j51Xu'></legend><bdo id='j51Xu'><pre id='j51Xu'><center id='j51Xu'></center></pre></bdo></b><th id='j51Xu'></th></span></q></dt></tr></i><div id='j51Xu'><tfoot id='j51Xu'></tfoot><dl id='j51Xu'><fieldset id='j51Xu'></fieldset></dl></div>
                <legend id='j51Xu'><style id='j51Xu'><dir id='j51Xu'><q id='j51Xu'></q></dir></style></legend>

                  <small id='j51Xu'></small><noframes id='j51Xu'>

                  本文介绍了CMake 无法使用 C++ 确定链接器语言的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着跟版网的小编来一起学习吧!

                  问题描述

                  我正在尝试使用 Visual Studio 2010 和 Cygwin 在 Windows 7 x64 上运行 cmake hello world 程序,但似乎两者都无法工作.我的目录结构如下:

                  I'm attempting to run a cmake hello world program on Windows 7 x64 with both Visual Studio 2010 and Cygwin, but can't seem to get either to work. My directory structure is as follows:

                  HelloWorld
                  -- CMakeLists.txt
                  -- src/
                  -- -- CMakeLists.txt
                  -- -- main.cpp
                  -- build/
                  

                  我做了一个 cd build 后跟一个 cmake ..,然后得到一个错误说明

                  I do a cd build followed by a cmake .., and get an error stating that

                  CMake Error: CMake can not determine linker language for target:helloworld
                  CMake Error: Cannot determine link language for target "helloworld".
                  

                  但是,如果我在我的文件系统和 src/CMakeLists.txt 中将 main.cpp 的扩展名更改为 main.c,一切都会按预期进行.这是从 Visual Studio 命令提示符(Visual Studio 解决方案生成器)和 Cygwin 终端(Unix Makefiles 生成器)运行的情况.

                  However, if I change the extension of main.cpp to main.c both on my filsystem and in src/CMakeLists.txt everything works as expected. This is the case running from both the Visual Studio Command Prompt (Visual Studio Solution Generator) and the Cygwin Terminal (Unix Makefiles Generator).

                  知道为什么这段代码不起作用吗?

                  Any idea why this code wouldn't work?

                  CMakeLists.txt

                  CMakeLists.txt

                  PROJECT(HelloWorld C)
                  cmake_minimum_required(VERSION 2.8)
                  
                  # include the cmake modules directory
                  set(CMAKE_MODULE_PATH ${HelloWorld_SOURCE_DIR}/cmake ${CMAKE_MODULE_PATH})
                  
                  add_subdirectory(src)
                  

                  src/CMakeLists.txt

                  src/CMakeLists.txt

                  # Include the directory itself as a path to include directories
                  set(CMAKE_INCLUDE_CURRENT_DIR ON)
                  
                  # Create a variable called helloworld_SOURCES containing all .cpp files:
                  set(HelloWorld_SOURCES main.cpp)
                  
                  # Create an executable file called helloworld from sources:
                  add_executable(hello ${HelloWorld_SOURCES })
                  

                  src/main.cpp

                  src/main.cpp

                  int main()
                  {
                    return 0;
                  }
                  

                  推荐答案

                  尝试改变

                  PROJECT(HelloWorld C)
                  

                  进入

                  PROJECT(HelloWorld C CXX)
                  

                  或者只是

                  PROJECT(HelloWorld)
                  

                  参见:http://www.cmake.org/cmake/help/v2.8.8/cmake.html#command:project

                  这篇关于CMake 无法使用 C++ 确定链接器语言的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持跟版网!

                  上一篇:如何告诉 CMake 在 Windows 上使用 Clang? 下一篇:CMake ExternalProject_Add() 和 FindPackage()

                  相关文章

                1. <legend id='FPFdG'><style id='FPFdG'><dir id='FPFdG'><q id='FPFdG'></q></dir></style></legend>

                      • <bdo id='FPFdG'></bdo><ul id='FPFdG'></ul>

                      <i id='FPFdG'><tr id='FPFdG'><dt id='FPFdG'><q id='FPFdG'><span id='FPFdG'><b id='FPFdG'><form id='FPFdG'><ins id='FPFdG'></ins><ul id='FPFdG'></ul><sub id='FPFdG'></sub></form><legend id='FPFdG'></legend><bdo id='FPFdG'><pre id='FPFdG'><center id='FPFdG'></center></pre></bdo></b><th id='FPFdG'></th></span></q></dt></tr></i><div id='FPFdG'><tfoot id='FPFdG'></tfoot><dl id='FPFdG'><fieldset id='FPFdG'></fieldset></dl></div>

                      <tfoot id='FPFdG'></tfoot>

                    1. <small id='FPFdG'></small><noframes id='FPFdG'>