<bdo id='Omem0'></bdo><ul id='Omem0'></ul>

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

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

    1. CMake 无法确定目标的链接器语言

      时间:2023-08-28
        <bdo id='YgjHQ'></bdo><ul id='YgjHQ'></ul>

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

              • <i id='YgjHQ'><tr id='YgjHQ'><dt id='YgjHQ'><q id='YgjHQ'><span id='YgjHQ'><b id='YgjHQ'><form id='YgjHQ'><ins id='YgjHQ'></ins><ul id='YgjHQ'></ul><sub id='YgjHQ'></sub></form><legend id='YgjHQ'></legend><bdo id='YgjHQ'><pre id='YgjHQ'><center id='YgjHQ'></center></pre></bdo></b><th id='YgjHQ'></th></span></q></dt></tr></i><div id='YgjHQ'><tfoot id='YgjHQ'></tfoot><dl id='YgjHQ'><fieldset id='YgjHQ'></fieldset></dl></div>
                <tfoot id='YgjHQ'></tfoot>
                  <tbody id='YgjHQ'></tbody>
              • <legend id='YgjHQ'><style id='YgjHQ'><dir id='YgjHQ'><q id='YgjHQ'></q></dir></style></legend>
                本文介绍了CMake 无法确定目标的链接器语言的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着跟版网的小编来一起学习吧!

                问题描述

                首先,我查看了this 发布后找不到我的问题的解决方案.我正在尝试使用两个头文件在文件夹中设置一个库并与我的主程序链接,在我的文件夹 container 中,它包括:

                To start off, I've taken a look at this post and couldn't find a solution to my problem. I'm attempting to set up a library in a folder using two header files and link with my main program, in my folder container it includes:

                linkedStack.h
                linkedQueue.h
                

                我的容器文件夹中的 CMakeLists.txt 是

                the CMakeLists.txt in my container folder is

                add_library(container linkedQueue.h linkedStack.h)
                
                install (TARGETS container DESTINATION bin)
                install (FILES linkedQueue.h linkedStack.h DESTINATION include)
                

                而我在源目录中的 CMakeLists.txt 是:

                while my CMakeLists.txt in the source directory is:

                cmake_minimum_required(VERSION 2.6)
                project(wordLadder)
                
                # set version number
                set (MAJOR 1)
                set (MINOR 0)
                
                # configure header file to be placed in binary
                configure_file(
                        "${PROJECT_SOURCE_DIR}/ladderConfig.h.in"
                        "${PROJECT_BINARY_DIR}/ladderConfig.h"
                )
                
                # add binary tree to search path for include files
                # so we can find config
                include_directories("${PROJECT_BINARY_DIR}")
                
                #add container library
                include_directories ("${PROJECT_SOURCE_DIR}/container")
                add_subdirectory(container)
                
                #add executable
                add_executable(wordLadder ladderMain.cpp)
                target_link_libraries (wordLadder container)
                
                install (TARGETS wordLadder DESTINATION bin)
                install (FILES "${PROJECT_BINARY_DIR}/ladderConfig.h"
                         DESTINATION include)
                

                以及我得到的错误:

                CMake Error: Cannot determine link language for target "container".
                CMake Error: CMake can not determine linker language for target:container
                -- Generating done
                -- Build files have been written to: /home/gmercer/Linux_dev/wordLadder/build
                

                我不确定我在这里做错了什么,但我认为这与我的库 CMake 文件有关.

                I'm not sure what i'm doing wrong here, but I think it has something to do with my library CMake file.

                推荐答案

                您已添加用于创建 container 库的目标.该目标仅包含头文件.请参阅 CMake 文档

                You have added target for creating container library. That target contains only header files. See CMake documentation

                add_library:使用指定的源文件向项目添加库.

                add_library: Add a library to the project using the specified source files.

                add_library( [静态 | 共享 | 模块][EXCLUDE_FROM_ALL]source1 source2 ... sourceN)

                add_library( [STATIC | SHARED | MODULE] [EXCLUDE_FROM_ALL] source1 source2 ... sourceN)

                添加一个库目标,称为从命令调用中列出的源文件构建.对应于逻辑目标名称,并且必须在项目中全局唯一.构建的库的实际文件名是根据本机平台的约定(例如lib.a 或.lib)构建的.

                Adds a library target called to be built from the source files listed in the command invocation. The corresponds to the logical target name and must be globally unique within a project. The actual file name of the library built is constructed based on conventions of the native platform (such as lib.a or .lib).

                但是你不能只从没有任何 cpp 文件的头文件构建库.这就是为什么你会出现这样的错误.

                But you can not build library just from header files without any cpp file. That's why you got such error.

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

                上一篇:cmake 将头文件包含到每个源文件中 下一篇:在 CMake 中,如何测试编译器是否为 Clang?

                相关文章

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

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

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

                <tfoot id='KQJgb'></tfoot>