Enabling libxml2 with LLVM module map

When I try to create the Swift package that I created that uses the LLVM module map to enable libxml2 from /usr/include/libxml2/ , I get the following error:

 Compiling Swift Module 'foo' (1 sources) <module-includes>2:9: note: in file included from <module-includes>:2: #import "/usr/include/libxml2/libxml/catalog.h" /usr/include/libxml2/libxml/catalog.h:22:10: error: 'libxml/xmlversion.h' file not found 

This is my module map:

 module Clibxml2 [system] { umbrella "/usr/include/libxml2" export * } 

My dummy main.swift file is only trying to import the module now:

 import Clibxml2 

It compiles when I try to use a different header path / umbrella (e.g. /usr/include/CommonCrypto ). I checked that xmlversion.h exists in /usr/include/libxml2/libxml . Did I miss something?

+5
source share
1 answer

Swift now has the -Xcc option , which can be used to pass additional compiler flags:

 swift build -Xcc -I/usr/include/libxml2 
+1
source

Source: https://habr.com/ru/post/1237623/


All Articles