简体   繁体   中英

cmake cannot find LibXml2

I am trying to build C++ project using Cmake and it cannot find the LibXml2 libraries (I believe) I have downloaded and installed correctly. This is on a Windows 10 machine with cmake 3.7.1.

Here is the relevant portion of the cmake configuration file:

find_package(LibXml2 REQUIRED)
include_directories(${LIBXML2_INCLUDE_DIR})
set(LIBS ${LIBS} ${LIBXML2_LIBRARIES})

Here are my environment variables:

LIBXML2_INCLUDE_DIR=C:\Program Files\libxml2\include
LIBXML2_LIBRARIES=C:\Program Files\libxml2\lib

And here are the contents of the C:\\Program Files\\libxml2 directory:

/mnt/c/Program Files/libxml2$ tree .
.
├── bin
│   ├── libxml2.dll
│   ├── xmlcatalog.exe
│   └── xmllint.exe
├── include
│   └── libxml
│       ├── c14n.h
│       ├── catalog.h
│       ├── chvalid.h
│       ├── debugXML.h
│       ├── dict.h
│       ├── DOCBparser.h
│       ├── encoding.h
│       ├── entities.h
│       ├── globals.h
│       ├── hash.h
│       ├── HTMLparser.h
│       ├── HTMLtree.h
│       ├── list.h
│       ├── nanoftp.h
│       ├── nanohttp.h
│       ├── parser.h
│       ├── parserInternals.h
│       ├── pattern.h
│       ├── relaxng.h
│       ├── SAX2.h
│       ├── SAX.h
│       ├── schemasInternals.h
│       ├── schematron.h
│       ├── threads.h
│       ├── tree.h
│       ├── uri.h
│       ├── valid.h
│       ├── xinclude.h
│       ├── xlink.h
│       ├── xmlautomata.h
│       ├── xmlerror.h
│       ├── xmlexports.h
│       ├── xmlIO.h
│       ├── xmlmemory.h
│       ├── xmlmodule.h
│       ├── xmlreader.h
│       ├── xmlregexp.h
│       ├── xmlsave.h
│       ├── xmlschemas.h
│       ├── xmlschemastypes.h
│       ├── xmlstring.h
│       ├── xmlunicode.h
│       ├── xmlversion.h
│       ├── xmlwriter.h
│       ├── xpath.h
│       ├── xpathInternals.h
│       └── xpointer.h
├── lib
│   ├── libxml2_a_dll.lib
│   ├── libxml2_a.lib
│   └── libxml2.lib
└── readme.txt

And the cmake output I receive is:

CMake Error at C:/Program Files/CMake/share/cmake-3.7/Modules/FindPackageHandleStandardArgs.cmake:138 (message): Could NOT find LibXml2 (missing: LIBXML2_LIBRARIES LIBXML2_INCLUDE_DIR) Call Stack (most recent call first): C:/Program Files/CMake/share/cmake-3.7/Modules/FindPackageHandleStandardArgs.cmake:378 (_FPHSA_FAILURE_MESSAGE) C:/Program Files/CMake/share/cmake-3.7/Modules/FindLibXml2.cmake:58 (FIND_PACKAGE_HANDLE_STANDARD_ARGS)

I've been wrestling with this one for a day or so now, can anyone give me a hint what I'm doing wrong?

运行CMake时,在via -D中定义变量并使用斜杠作为目录定界符(和退格符以转义目录名称中的空格)。

cmake .. -DLIBXML2_INCLUDE_DIR:PATH=C:/Program\ Files/libxml2/include -DLIBXML2_LIBRARIES:PATH=C:/Program\ Files/libxml2/lib

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM