【发布时间】:2019-02-22 02:47:16
【问题描述】:
我在 ubuntu 上,我已经安装了 gcc、cmake、libxml2-dev 并且我有这个 CMakeLists.txt 文件:
cmake_minimum_required(VERSION 2.8)
find_package(LIBXML2 CONFIG)
include_directories(${LIBXML2_INCLUDE_DIRS})
link_libraries(${LIBXML2_LIBRARY})
add_executable(testusage testusage.cpp)
我运行“cmake”。 OK,然后make VERBOSE=1 编译报错:
Scanning dependencies of target testusage
[ 50%] Building CXX object CMakeFiles/testusage.dir/testusage.cpp.o
/home/a/proj/mynet/mytest/cpp3p/useXml2/testusage.cpp:1:9: fatal error: libxml/parser.h: no such file or directory
#include<libxml/parser.h>
^~~~~~~~~~~~~~~~~
compilation terminated.
CMakeFiles/testusage.dir/build.make:62: recipe for target 'CMakeFiles/testusage.dir/testusage.cpp.o' failed
make[2]: *** [CMakeFiles/testusage.dir/testusage.cpp.o] Error 1
CMakeFiles/Makefile2:67: recipe for target 'CMakeFiles/testusage.dir/all' failed
make[1]: *** [CMakeFiles/testusage.dir/all] Error 2
Makefile:83: recipe for target 'all' failed
make: *** [all] Error 2
似乎“include_directories”没有在 Makefile 中添加任何“-I”选项。我该如何解决?
【问题讨论】:
标签: c++ cmake compilation include libxml2