<tfoot id='W8HmJ'></tfoot>

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

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

  • <legend id='W8HmJ'><style id='W8HmJ'><dir id='W8HmJ'><q id='W8HmJ'></q></dir></style></legend>

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

        在我的 Cmake 项目中使用 Eigen Lib?

        时间:2023-08-27

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

          • <bdo id='myJMa'></bdo><ul id='myJMa'></ul>
            <tfoot id='myJMa'></tfoot>

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

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

                    <tbody id='myJMa'></tbody>
                  本文介绍了在我的 Cmake 项目中使用 Eigen Lib?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着跟版网的小编来一起学习吧!

                  问题描述

                  我在我的 CMake 项目中使用仅标头库 (Eigen) 时遇到困难.当我删除与 Eigen 库相关的所有部分时,它会编译,但不确定如何使用 (Eigen) 进行构建.请注意,Eigen 在 Eigen 文件夹中有一个 CmakeLists.txt,它有/src 文件夹,其中包含与矩阵运算等相关的(*.h 和 *.cpp)...

                  I am having difficulty using a header-only library (Eigen) in my CMake project. When i take off all the portion related to Eigen library it compiles, but not sure how to build with (Eigen). Note that Eigen has a CmakeLists.txt in Eigen folder, and it has /src folder having (*.h and *.cpp) related to Matrix operation etc...

                  我的程序结构如下

                  Myproject(文件夹)由:

                  Myproject (folder) is composed of :

                  • CmakeLists.txt
                  • /构建
                  • /来源

                  Source 文件夹中有一堆我的文件(*.h 和 *.cpp)和/Eigen(文件夹).

                  The Source folder has bunch of my files (*.h and *.cpp) and the /Eigen (folder).

                  我所做的是:

                  FIND_PACKAGE(PkgConfig REQUIRED)
                  PKG_CHECK_MODULES(GTK3 REQUIRED gtk+-3.0)
                  LIST(APPEND CMAKE_CXX_FLAGS 
                      "-std=c++0x
                       -pthread 
                       ${CMAKE_CXX_FLAGS} 
                       -g 
                      -Wall -Wextra ")
                  
                  ADD_LIBRARY(Eigen ${CMAKE_SOURCE_DIR}/Eigen)
                  TARGET_INCLUDE_DIRECTORIES(Eigen INTERFACE
                   $<BUILD_INTERFACE:${CMAKE_CURRENT_SOURCE_DIR}/src>
                   $<INSTALL_INTERFACE:include/Eigen>
                  )
                  
                  INCLUDE_DIRECTORIES(${GTK3_INCLUDE_DIRS})
                  ADD_DEFINITIONS(${GTK3_CFLAGS_OTHERS})
                  INCLUDE_DIRECTORIES(include)
                  ADD_LIBRARY(RTT 
                          Def.cpp 
                          Def.h       
                          krnel.cpp 
                          krnel.h 
                          Mesh.cpp 
                          Mesh.h 
                          Mcom.cpp 
                          Mcom.h 
                          timer.h 
                          Identifier.h)       
                  
                  ADD_EXECUTABLE(Rdrtst main.cpp)
                  TARGET_LINK_LIBRARIES(Rdrtst RTT ${GTK3_LIBRARIES} Eigen)
                  

                  当我 cd 到/Build 并输入 (Cmake ../Source )

                  When i cd to /Build and type (Cmake ../Source )

                  我得到以下内容:

                  [/../Build]$ cmake ../Source
                  -- Configuring done
                  CMake Error: Cannot determine link language for target "Eigen".
                  CMake Error: CMake can not determine linker language for target:Eigen
                  -- Generating done
                  -- Build files have been written to: /../../MyProject/Build
                  

                  eigen 文件夹中有 CMakeLists.txt ,内容如下:

                  The eigen folder has the CMakeLists.txt with the following content :

                  include(RegexUtils)
                  test_escape_string_as_regex()
                  
                  file(GLOB Eigen_directory_files "*")
                  
                  escape_string_as_regex(ESCAPED_CMAKE_CURRENT_SOURCE_DIR "${CMAKE_CURRENT_SOURCE_DIR}")
                  
                  foreach(f ${Eigen_directory_files})
                    if(NOT f MATCHES "\.txt" AND NOT f MATCHES "${ESCAPED_CMAKE_CURRENT_SOURCE_DIR}/[.].+" AND NOT f MATCHES "${ESCAPED_CMAKE_CURRENT_SOURCE_DIR}/src")
                      list(APPEND Eigen_directory_files_to_install ${f})
                    endif()
                  endforeach(f ${Eigen_directory_files})
                  
                  install(FILES
                    ${Eigen_directory_files_to_install}
                    DESTINATION ${INCLUDE_INSTALL_DIR}/Eigen COMPONENT Devel
                    )
                  
                  add_subdirectory(src)
                  

                  推荐答案

                  您只需要 INCLUDE_DIRECTORIES 中的正确路径(还要确保包含正确的文件夹或子文件夹,具体取决于您在 C++ 文件中是否使用 #include Eigen/something.h 或 #include something.h )因此,删除行 ADD_LIBRARY(Eigen ... 和 TARGET_LINK_LIBRARIES Eigen.

                  You just need the correct path in INCLUDE_DIRECTORIES (also make sure to include the correct folder or subfolder, depending if in your c++ file you are using #include Eigen/something.h or #include something.h ) So, remove the lines ADD_LIBRARY(Eigen ... and TARGET_LINK_LIBRARIES Eigen.

                  为了排除故障,您还可以包含 Eigen 文件夹的绝对路径,然后当您运行时,将其转换为相对路径

                  For troubleshooting, you can also include the absolute path of the Eigen folder , and then when you get it working, transform it in a relative path

                  这篇关于在我的 Cmake 项目中使用 Eigen Lib?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持跟版网!

                  上一篇:CMake 是否总是为所有可能的项目配置生成配置? 下一篇:使用Makefile和CMake编译代码的区别

                  相关文章

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

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

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