Problem with linking against libexpat in Boost Build – for building graphml – Education Career Blog

On my system, expat is located at


So I export the required variables for boost to build graphml

export EXPAT_INCLUDE=/usr/include
export EXPAT_LIBPATH=/usr/lib

then I run (where $DIR and $BOOST generate the paths I want the includes and libs to go)

./configure --includedir=$DIR/$BOOST --libdir=$DIR/$BOOST/lib \ 

I get this error:

ld: library not found for -lexpat collect2: ld returned 1 exit status

which boost says is caused by the line:

g++ -dynamiclib -install_name "libboost_graph-mt-1_35.dylib" -L"/usr/lib" 
    -o "bin.v2/libs/graph/build/darwin/release/macosx-version-10.4/threading-multi/libboost_graph-mt-1_35.dylib" 
    -lexpat   -isysroot /Developer/SDKs/MacOSX10.4u.sdk -mmacosx-version-min=10.4 -Wl,-dead_strip -no_dead_strip_inits_and_terms

I don’t get how it’s not finding the expat library with -L"/usr/lib" and -lexpat as arguments? My understanding is that /usr/lib/libexpat.dylib is exactly referenced as -L"/usr/lib" and -lexpat.

The Jamfile for building graphml is here. If EXPAT_INCLUDE and EXPAT_LIBPATH aren’t set then it warns you (lines 39-41 of jamfile)

warning: Graph library does not contain optional GraphML reader.
note: to enable GraphML support, set EXPAT_INCLUDE and
note: directories containing the Expat headers and libraries, respectively.


Another update:
I don’t see an .so or a .a file in your list of where EXPAT is… doesn’t that seem a bit strange? Normally it will create an alias for the library name

for example /usr/lib/ -> /usr/lib/

Is dynalib some Macintoshism (I don’t use Macs much)

is .la the static version extension on this platform?


The quotes around the path seem troublesome…

Try changing this to -L/usr/lib and -L /usr/lib

Older stuff:

The directive for the linker to include paths during the link step is -L. You need to look for some linker flags to update to include -L path_to_expat. I don’t think the linker pays any attention to LD_LIBRARY_PATH. I am not sure what documentation you have read to set EXPAT_INCLUDE or EXPAT_LIBPATH.

Leave a Comment