• <small id='Euimf'></small><noframes id='Euimf'>

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

  • <tfoot id='Euimf'></tfoot>

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

        Cmake 链接库目标链接错误

        时间:2023-09-18
          • <small id='ZEvrC'></small><noframes id='ZEvrC'>

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

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

                  <legend id='ZEvrC'><style id='ZEvrC'><dir id='ZEvrC'><q id='ZEvrC'></q></dir></style></legend><tfoot id='ZEvrC'></tfoot>
                  本文介绍了Cmake 链接库目标链接错误的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

                  问题描述

                  我在使用 cmake 连接 Glfw 和其他库时遇到问题.从命令行我像这样编译

                  Hi I have problem with linkg Glfw and other libraries using cmake. From command line i compile like this

                  g++ main.cpp -lGL -lGLU -lGLEW -lglfw
                  

                  但我想使用 cmake 进行编译.我尝试使用 target_linkg_libraries 但这会产生错误

                  But I wanted to use cmake for compiling. I tried to use target_linkg_libraries but this produce error

                  CMakeLists.txt 中的 CMake 错误:18 (target_link_libraries):不能为不是由这个构建的目标GL"指定链接库
                  项目.

                  CMake Error at CMakeLists.txt:18 (target_link_libraries): Cannot specify link libraries for target "GL" which is not built by this
                  project.

                  我尝试使用添加定义来做到这一点.我没有看到错误,但这不会链接库.

                  I tried do this using add definitions. I dont see error but this don't link libraries.

                  cmake_minimum_required (VERSION 2.6)
                  project (test)
                  
                  find_package(OpenGL REQUIRED)
                  find_package(GLEW REQUIRED)
                  
                  ADD_DEFINITIONS(
                      -lGL
                      -lGLU
                      -lGLEW
                      -lglfw
                  )
                  
                  add_executable(test.out
                      main.cpp
                  )
                  
                  target_link_libraries(GL GLU GLEW glfw)
                  

                  推荐答案

                  target_link_libraries 的语法是:

                  target_link_libraries(your_executable_name libraries_list)
                  

                  而且您不必添加add_definition 语句(target_link_libraries 添加此选项)

                  And you don't have to add add_definition statements (target_link_libraries adds this options)

                  OpenGL 和 GLEW 包也提供了一些有用的变量.

                  There are also some useful variables provided by OpenGL and GLEW packages.

                  你的 CMakeLists.txt 应该是这样的:

                  Your CMakeLists.txt should be like:

                  cmake_minimum_required (VERSION 2.6)
                  project (test)
                  
                  find_package(OpenGL REQUIRED)
                  find_package(GLEW REQUIRED)
                  
                  include_directories(${OPENGL_INCLUDE_DIR} ${GLEW_INCLUDE_DIRS})
                  
                  add_executable(test
                      main.cpp
                  )
                  
                  target_link_libraries(test ${OPENGL_LIBRARIES} ${GLEW_LIBRARIES})
                  

                  要记住的一个重要细节是将target_link_libraries 放在 add_executable(或add_library)之后线.

                  One important detail to keep in mind is to place the target_link_libraries after the add_executable (or add_library) line.

                  这篇关于Cmake 链接库目标链接错误的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持html5模板网!

                  上一篇:强制机器使用专用显卡? 下一篇:为什么 glGetString(GL_VERSION) 返回空/零而不是 Open

                  相关文章

                  最新文章

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

                      <legend id='uMjpe'><style id='uMjpe'><dir id='uMjpe'><q id='uMjpe'></q></dir></style></legend><tfoot id='uMjpe'></tfoot>
                    1. <small id='uMjpe'></small><noframes id='uMjpe'>