0

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?

Martin Ueding
  • 8,245
  • 6
  • 46
  • 92

1 Answers1

1

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 of xml2-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:

cc test.c -L/path/to/libxml2/directory -lxml2 -lz -llzma -lm -ldl
John Bollinger
  • 160,171
  • 8
  • 81
  • 157
  • libxml2 is installed via the SUSE package on the system. This was likely compiled with GCC on the SUSE servers. It is installed at `/usr/lib64/libxml2.so.2.9.4` with appropriate symlinks without as many version number digits. I can use it just fine with GCC. The problem is just the Cray wrapped Cray and Intel compilers on the machine. – Martin Ueding Mar 19 '18 at 09:46
  • 1
    And you're sure, @MartinUeding, that `/usr/lib64` is in the library search path for your wrapped compilers? Did you try specifying it with an `-L` option, as I suggested? Or on the flip side, are you confident that the libraries installed in the usual system locations are meant to be used with your wrapped compilers at all? If the wrapped compilers worked similarly to typical cross-compilers, then they would intentionally ignore the system's standard libraries altogether. – John Bollinger Mar 19 '18 at 22:06