If I want to compile a c source file that uses libxml, how do I setup libxml on mac osx so that my source file will just compile correctly and be ready to run?
I have been using XCode until now, but have switched to TextMate & Terminal, Do I need to create a makefile if I want to use libxml or how will this work?
Thanks
EDIT:
I use the current imports
#include <libxml/xmlmemory.h>
#include <libxml/parser.h>
The headers for the libxml2 distribution on 10.6 resides within /usr/include/libxml2/
. Unfortunately, just the /usr/include
part is within the system default header search path. Thus, you need to explicitly include it on the command line (or have your #includes
also include the additional libxml2 folder). The library itself resides at the usual /usr/lib/libxml2.dylib
.
Thus, use the following command to compile your program:
gcc source.c -I/usr/include/libxml2 -lxml2 -o output
No setup required. Add -lxml2
to your link command.
If you just have a simple single-source file "project":
gcc yourSourceFile.c -I/usr/include/libxml2 -lxml2 -o executableProgram
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With