Skip to content

MCPL related issue on Ubuntu 17.04

Erik B Knudsen edited this page Dec 17, 2017 · 2 revisions

This may be relevant on other platforms as well. The problem was reported in issue #547 (now closed).

You may experience compilation errors when using MCPL component(s) similar to the following:

/usr/bin/ld: /usr/share/mcstas/2.4.1/libs/mcpl/libmcpl.a(mcpl.c.o): relocation R_X86_64_32 against `.rodata' can not be used when making a shared object; recompile with -fPIC
/usr/bin/ld: final link failed: Nonrepresentable section on output
collect2: error: ld returned 1 exit status
** Error exit **

This is probably caused by your system default compiler being newer than what the shipped mcpl-library was compiled with. On Ubuntu 17.04 the default is version 6.4, whereas McStas 2.4.1 was built using version 5 (on a debian stable system). There is a simple workaround for this issue as we also ship the source code for mcpl with McStas. Simply build the mcpl-library on your target system. For instance by:

mkdir tmp; cd tmp
cp /usr/share/mcstas/2.4.1/libs/mcpl/mcpl.* .
gcc -c -I. mcpl.c
ar -r libmcpl.a mcpl.o
[sudo] cp libmcpl.a /usr/share/mcstas/2.4.1/libs/

This assumes that McStas was installed in /usr/share/mcstas

You should now be able run as normal.

Clone this wiki locally