Thank you very much for your replies, I now have 2 solutions to my problem! Both compiling on a virtual machine running debian wheezy, and using gcc to do the linking produced executables that would run on the cluster.

Compiling with the verbose flags for linker and compiler produced the following output:

failed gdc attempt: http://dpaste.com/0Z5V4PV

successful dmd attempt: http://dpaste.com/0S5WKJ5

successful use of gcc to link: http://dpaste.com/0YYR39V

It seems a bit of a mess, with various libraries in various places. I'll see if I can get to the bottom of it, I think it'll be a learning experience.

Thanks again for the swift and useful help and guidance.

Andrew

On Monday, 16 March 2015 at 19:22:18 UTC, Johannes Pfau wrote:
Am Mon, 16 Mar 2015 16:44:45 +0000
schrieb "Andrew Brown" <aabrow...@hotmail.com>:

Hi,

I'm trying to compile code which calls C and fortan routines from D on the linux cluster at work. I've managed to get it to work with all 3 compilers on my laptop, but LDC and GDC fail on the cluster (though DMD works perfectly). I'm using the precompiled compiler binaries on these systems, the cluster doesn't have the prerequistites for building them myself and I don't have admin rights.

For GDC the commands I run are:

gcc -c C_code.c Fortran_code.f
gdc D_code.d C_code.o Fortran_code.f -lblas -lgsl -lgslcblas -lm -lgfortran -o out


You could try to do the linking with the local compiler:

gdc D_code.d
gcc D_code.o C_code.o Fortran_code.o -lgphobos2 -lpthread -lblas -lgsl
-lgslcblas -lm -L path/to/x86_64-gdcproject-linux-gnu/lib/

The error messages are:

/software/lib64/libgsl.so: undefined reference to `memcpy@GLIBC_2.14' /software/lib64/libgfortran.so.3: undefined reference to `clock_gettime@GLIBC_2.17' /software/lib64/libgfortran.so.3: undefined reference to `secure_getenv@GLIBC_2.17'
collect2: error: ld returned 1 exit status


Seems like the binary GDC toolchain somehow picks up a wrong libc. The toolchains are built with GLIBC 2.14. But IIRC we don't ship the libc in the binary packages (for native compilers) and it should pick up the local libc. Please run gdc with the '-v' and '-Wl,--verbose' options and
post a link to the full output.

I can remove the gsl messages by statically linking to libgsl.a, but this doesn't solve the gfortran issues.

If anyone knows a way round these issues, I'd be very grateful. I'd also eventually like to find a way to easily share linux biniaries with people, so they can use this code without these kinds of headaches. If anyone has any advice for making this portable, that would also help me out a lot.


Usually the best option is to compile on old linux systems. Binaries often run on newer systems but not on older ones. You could setup
debian wheezy or an older version in a VM or using docker.

Or you use docker.io ;-) I personally think the docker approach is kind of overkill but avoiding compatibility issues is one of docker's main
selling points.

Reply via email to