Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Include path error in conan cmake configuration

Tags:

cmake

conan

conanfile.txt //i am using local repo

[requires]
libxml2/2.9.0@conan/stable

[generators]
cmake

CMakeLists.txt

 cmake_minimum_required(VERSION 3.4)
 project(testlibxml)

 include(${CMAKE_BINARY_DIR}/conanbuildinfo.cmake)
 conan_basic_setup()

 add_executable(test_xml_lib test_xml.cpp)

test_xml.cpp

 #include <libxml/xlink.h>

 int main(){

     return 0;
 }

I expect includes to be resolved properly, but i am getting below error

error: libxml/xlink.h: No such file or directory. 

It works if i add below line in CmakeLists.txt

include_directories(${CONAN_INCLUDE_DIRS}/libxml2)
like image 521
Ayub Avatar asked Jul 03 '26 05:07

Ayub


1 Answers

I don't know where are you getting that version of the libxml2 package, because it is not in conan-center:

$ conan search libxml* -r=conan-center
Existing package recipes:

libxml2/2.9.3@bincrafters/stable
libxml2/2.9.8@bincrafters/stable

So what you are using might be an old, stale, or broken version from somewhere else. Changing your conanfile.txt:

[requires]
libxml2/2.9.8@bincrafters/stable

[generators]
cmake

And I have checked it works (at least in Windows)

like image 106
drodri Avatar answered Jul 05 '26 01:07

drodri



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!