Unable to link libxml2

Hi,

I am encountering a linking issue with a project for an iOS .NET MAUI application that I am developing using Visual Studio 17.11.4. This project includes a custom static library (.a). The custom static library (.a) depends on the libxml2 library. However, it appears that libxml2 is not included in Xcode 15.4 (Sonoma OS), resulting in the following error:

error : Undefined symbols for architecture arm64:
error : "_xmlBufferCreate", referenced from: ....

I have set the following additional arguments for compilation: -cxx -gcc_flags "-lz -lxml2".

Despite my efforts to install libxml2 using Homebrew, I have not been successful.

Could you please advise on how I can resolve this issue? Specifically, what is the path that Xcode uses to include libxml2?

libxml2 is a supported API on iOS. The stub library is in the standard place within the iOS SDK.

% ls -lh usr/lib/libxml2.*
-rw-r--r--  1 quinn  staff    52K  3 Aug 13:54 usr/lib/libxml2.2.tbd
lrwxr-xr-x  1 quinn  staff    13B 17 Sep 08:21 usr/lib/libxml2.tbd -> libxml2.2.tbd

I’m not sure why this isn’t working for you, but it sounds like your confused about how Apple’s tools work with platform SDKs and their stub libraries. I talk more about this in An Apple Library Primer; that’s a long post, so search for stub to find the relevant bit.

In Xcode you can add a stub library to your target in the Link Binary With Libraries build phase. I’m not sure how you set that up with your third-party tooling. My general advice on this front is to set up a small Xcode test project, configure it to do what you need to do, look at the build transcript to see how it did it, and then apply that technique to your third-party tools.

Share and Enjoy

Quinn “The Eskimo!” @ Developer Technical Support @ Apple
let myEmail = "eskimo" + "1" + "@" + "apple.com"

Unable to link libxml2
 
 
Q