I need to use libxml2 in a project that I want to compile on a Cray machine. In principle it is installed, there is a xml2-config
program that gives me linker flags:
$ xml2-config --libs
-lxml2 -L/lib64 -lz -llzma -lm -ldl
I have a very simple test program:
$ cat test.c
int main() { return 0; }
Though in principle not needed, I can compile this with gcc test.c -lxml2 -L/lib64 -lz -llzma -lm -ldl
just fine. However, with the Cray compiler it does not work:
$ cc test.c -lxml2 -L/lib64 -lz -llzma -lm -ldl
/opt/cray/pe/cce/8.6.5/binutils/x86_64/x86_64-pc-linux-gnu/bin/ld: cannot find -lxml2
/opt/cray/pe/cce/8.6.5/binutils/x86_64/x86_64-pc-linux-gnu/bin/ld: cannot find -llzma
Same story with the Cray wrapped Intel compiler:
$ module swap PrgEnv-cray PrgEnv-intel
$ cc test.c -lxml2 -L/lib64 -lz -llzma -lm -ldl
ld: cannot find -lxml2
ld: cannot find -llzma
I need to use the Cray wrapped compiler in order to get proper MPI and hugepages into my program.
Is there anything I can do (besides trying to compile libxml2 myself, see my other question) to get this to link?
If libxml2 is indeed installed then it appears that
xml2-config
is lying to you. My best guess would be that libxml2 was installed in a different location than it was built for, or that it was moved after installation. In any case, the output ofxml2-config --libs
assumes that on your system, libxml2 is installed in the default library search path, and liblzma and the other needed libraries are installed either in the default library search path or in/lib64
(if that's not already in the search path). In fact, they're not.Rather than building the libraries from scratch, your best bet is to find where they are actually installed, and pass an corresponding
-L
option to the linker when you build your program: