【问题标题】:How to build my project with Clion Remote?如何使用 Clion Remote 构建我的项目?
【发布时间】:2020-08-05 05:34:36
【问题描述】:

我在 CLion 中成功设置了一个远程项目。它可以识别编译器和远程主机上的所有内容,并同步更改。
现在解决我的问题:
当我尝试构建和运行项目时,它给我一个错误,它找不到某个库:

fatal error: Eigen/SparseCore: No such file or directory
 #include <Eigen/SparseCore> 

但是当我通过 ssh 登录到服务器时,我可以进入同步目录,运行 make 并且编译没有错误。然后我可以运行编译的应用程序没有问题。

这是 CMakeLists.txt:

cmake_minimum_required(VERSION 3.10)
project(projectName)

set(CMAKE_CXX_STANDARD 14)

include_directories(/usr/local/PRIV)
include_directories(/usr/local/PRIV/Includes)
include_directories(/usr/local/PRIV/Includes/SubDir)
include_directories(/usr/local/PRIV/Includes/SubDir/eigen3)
include_directories(/usr/local/PRIV/Includes/SubDir/eigen3/Eigen/)
include_directories(/usr/local/PRIV/Includes/SubDir/qhull)

add_executable(
        Example/MyTopTen/Makefile
        Example/MyTopTen/MyTopTen.cc
        Example/MyTopTen/MyTopTen.h
        Example/MyTopTen/Readme.txt
        Example/Makefile
        Example/Example.cc
        )

我对 cmake 项目和 Stackoverflow 非常陌生,所以如果我能改进这个问题,请告诉我!

【问题讨论】:

    标签: c++ cmake remote-debugging clion


    【解决方案1】:

    请遵循 Eigen 指南如何将其与 CMake 一起使用 https://eigen.tuxfamily.org/dox/TopicCMakeGuide.html

    在这种情况下,您的 CMakeLists.txt 应该如下所示

    cmake_minimum_required(VERSION 3.10)
    project(projectName)
    
    set(CMAKE_CXX_STANDARD 14)
    
    find_package (Eigen3 3.3 REQUIRED NO_MODULE)
    include_directories(${EIGEN3_INCLUDE_DIR})
    
    add_executable(myTargetName
            Example/MyTopTen/MyTopTen.cc
            Example/MyTopTen/MyTopTen.h
            Example/Example.cc
            )
    target_link_libraries (myTargetName Eigen3::Eigen)
    

    之后通过Tools | CMake | Reset Cache and Reload Project 在 CLion 中重新加载 CMake 项目。

    【讨论】:

      猜你喜欢
      • 2018-03-26
      • 2014-11-28
      • 2021-06-25
      • 2021-02-09
      • 2021-10-06
      • 1970-01-01
      • 2018-08-13
      • 2020-07-24
      • 1970-01-01
      相关资源
      最近更新 更多