Bug 2637

Summary: ../src/config-store/model/xml-config.h:25:10: fatal error: 'libxml/xmlwriter.h' file not found #include <libxml/xmlwriter.h>
Product: ns-3 Reporter: John Abraham <john.abraham.in>
Component: build systemAssignee: Gustavo J. A. M. Carneiro <gjcarneiro>
Status: RESOLVED FIXED    
Severity: normal CC: dev, ns-bugs, tomh
Priority: P3    
Version: ns-3-dev   
Hardware: Mac Intel   
OS: Mac OS   
Attachments: config.log
patch to fix

Description John Abraham 2017-01-26 22:40:01 UTC
Created attachment 2764 [details]
config.log

[1457/2170] Compiling src/config-store/model/config-store.cc
In file included from ../src/config-store/model/xml-config.cc:21:
../src/config-store/model/xml-config.h:25:10: fatal error: 'libxml/xmlwriter.h' file not found
#include <libxml/xmlwriter.h>
         ^
1 error generated.

In file included from ../src/config-store/model/config-store.cc:31:
../src/config-store/model/xml-config.h:25:10: fatal error: 'libxml/xmlwriter.h' file not found
#include <libxml/xmlwriter.h>
         ^
1 error generated.


config.log will be attached

It appears that we might be trying to include  -I/usr/include/libxml2
But this path does not exist on my machine. 
bash-3.2# ls usr/include/libxml2
ls: usr/include/libxml2: No such file or directory

Xcode version: Version 8.2.1 (8C1002)
Comment 1 Tom Henderson 2018-01-04 16:10:02 UTC
John, is this still an issue with your current machine?  Would like to close if no longer bothering you.
Comment 2 Elias Rohrer 2018-01-12 05:38:40 UTC
I'm experiencing the same issue trying to build ns-3.27 on macOS 10.13.2.
Comment 3 Elias Rohrer 2018-01-12 05:51:49 UTC
(In reply to Elias Rohrer from comment #2)
> I'm experiencing the same issue trying to build ns-3.27 on macOS 10.13.2.

Correction: the issue only occurred because I did not install the current version of the Command Line Tools after upgrading Xcode. So, running

$ xcode-select --install

fixed the issue, ns-3.27 is building now. I assume OP had the same problem and this issue is not a bug of ns-3 and hence may be closed?!
Comment 4 Elias Rohrer 2018-11-07 03:57:34 UTC
Update: After upgrading to macOS Mojave, I encountered this problem again. This time, it wasn't sufficient to install the command line tools.

Afterwards, I had to install the legacy header package located at
/Library/Developer/CommandLineTools/Packages/macOS_SDK_headers_for_macOS_10.14.pkg
Comment 5 Tom Henderson 2018-11-07 11:31:43 UTC
I see that emacs project has a similar issue:
https://emacs.stackexchange.com/questions/34238/installing-emacs-from-source-make-fatal-error-libxml-tree-h-file-not-found

I suppose we need to disable libxml2 more gracefully for MacOS if header is not found, and provide more guidance on the 'installing Command Line Tools plus Legacy Headers' approach for MacOS users who want the XML features.  Any thoughts on this approach?

I will try to access a Mojave machine to experiment.
Comment 6 Elias Rohrer 2018-11-08 03:56:40 UTC
This would be nice. Is libxml2 really needed for ns-3's basic functionality? Could the respective components just get disabled when the library is not present?

However, notice that I now multiple times encountered that the configure script seemed to have found libxml2, but the build then failed at compile time..
Comment 7 Tom Henderson 2018-11-11 17:07:21 UTC
Created attachment 3210 [details]
patch to fix

I will commit this patch if it passes tests.
Comment 8 Tom Henderson 2018-11-11 17:13:42 UTC
The patch should append the right include path if the situation exists (pig-config declares that libxml2 is installed, but the headers exist elsewhere).  It should also not harm the case in which the user has already installed macOS_SDK_headers_for_macOS_10.14.pkg

This is somewhat of a homebrew issue to resolve in the long run (either by changing package configs or requiring users to install the SDK headers package).

In the meantime, I think we can recommend to users to take all three steps, with the third one optional, if they want to use the (optional) XML features:

1) install Xcode
2) install command-line tools
3) (optional) install the macOS_SDK_headers_for_macOS_10.14.pkg
Comment 9 Tom Henderson 2018-11-14 17:29:46 UTC
pushed in 13855:2c86757b4511, and wiki Installation page updated