【发布时间】:2020-07-29 02:34:52
【问题描述】:
我正在尝试使用 CMake 编译 C++ 程序。我正在使用与 Anaconda(特别是 miniconda3)一起安装的 CMake。编译时,Anaconda 无法找到 /usr/include/ 中包含的标头
我的主 CPP 文件如下所示:
// Include standard headers
#include <stdio.h>
#include <stdlib.h>
#include <iostream>
#include "dna.h"
#include <GLFW/glfw3.h>
int main() {
std::cout << "Version " << DNA_VERSION_MAJOR << "." << DNA_VERSION_MINOR << std::endl;
return 0;
}
具体来说,我正在尝试访问名为 GL/gl.h 的标头,该标头位于 /usr/include/GL/gl.h
我的CMakeList.txt 文件如下所示:
cmake_minimum_required(VERSION 3.11)
project(DNA VERSION 1.0)
# specify the C++ standard
set(CMAKE_CXX_STANDARD 11)
set(CMAKE_CXX_STANDARD_REQUIRED True)
configure_file(dna.h.in dna.h)
include_directories("/usr/include/")
add_executable(dna-viz main.cpp dna.h)
target_include_directories(
dna-viz PUBLIC
"${PROJECT_BINARY_DIR}"
"${CONDA_PREFIX}/include"
)
我运行mkdir build && cd build && cmake ..时的错误如下:
make[1]: Entering directory '/home/debesh/general/dna-vis/build'
make[2]: Entering directory '/home/debesh/general/dna-vis/build'
Scanning dependencies of target dna-viz
make[2]: Leaving directory '/home/debesh/general/dna-vis/build'
make[2]: Entering directory '/home/debesh/general/dna-vis/build'
[ 50%] Building CXX object CMakeFiles/dna-viz.dir/main.cpp.o
In file included from /home/debesh/general/dna-vis/build/dna.h:4:0,
from /home/debesh/general/dna-vis/main.cpp:6:
/home/debesh/miniconda3/include/GLFW/glfw3.h:210:12: fatal error: GL/gl.h: No such file or directory
#include <GL/gl.h>
^~~~~~~~~
compilation terminated.
make[2]: *** [CMakeFiles/dna-viz.dir/build.make:80: CMakeFiles/dna-viz.dir/main.cpp.o] Error 1
make[2]: Leaving directory '/home/debesh/general/dna-vis/build'
make[1]: *** [CMakeFiles/Makefile2:93: CMakeFiles/dna-viz.dir/all] Error 2
make[1]: Leaving directory '/home/debesh/general/dna-vis/build'
make: *** [Makefile:101: all] Error 2
这是因为GL/gl.h和GLFW/glfw3.h安装在不同的地方吗?
我已经使用conda install 安装了大量不同的xorg-* 和mesagl 软件包,但这仍然无法正常工作。
【问题讨论】: