1

I am cross-compiling gpsd3.20 on my Ubuntu 16.04 for the ARM architecture. As you may know, gpsd uses Sconsctruct to compile the source codes. During my cross-compilation, the moment when it needs to create the libgps.so it shows an error unrecognized option '-Wl, -Bsymbolic'.

Before posting the question here, I have tried t check my toolchain binaries and I found out that if I run this line manually:

sudo ./arm-v7a-linux-gnueabihf-ld -o test/gpsd-3.20/libgps.so.25.0.0 -pthread -shared -Wl,-Bsymbolic-functions -Wl,-soname=libgps.so.25 test/gpsd-3.20/os_compat.os test/gpsd-3.20/rtcm2_json.os test/rtcm3_json.os test/gpsd-3.20/shared_json.os test/gpsd-3.20/timespec_str.os test/gpsd-3.20/libgpsmm.os -L. -lrt -lm -lrt

The above commands print out the exact error as I mentioned previously. However, if I run the exact command replacing ld with gcc, then there is no any errors.

sudo ./arm-v7a-linux-gnueabihf-gcc -o test/gpsd-3.20/libgps.so.25.0.0 -pthread -shared -Wl,-Bsymbolic-functions -Wl,-soname=libgps.so.25 test/gpsd-3.20/os_compat.os test/gpsd-3.20/rtcm2_json.os test/rtcm3_json.os test/gpsd-3.20/shared_json.os test/gpsd-3.20/timespec_str.os test/gpsd-3.20/libgpsmm.os -L. -lrt -lm -lrt

Upon checking the arm-v7a-linux-gnueabihf-gcc --help, I found out that, gcc support -Wloptions whereas in the arm-v7a-linux-gnueabihf-ld it doesn't support the -Wl options. So now I am not sure how to change the SConstruct file so that it doesn't execute ld instead I want it to execute gcc especially for the libgps.so part.

Raaj Lokanathan
  • 479
  • 3
  • 7
  • 19
  • Hi, to my knowledge, arm-v7a-linux-gnueabihf-ld is the linker, and arm-v7a-linux-gnueabihf-gcc is the compiler. Those are two different tools that serve two different purposes. For compilation, it seems more appropriate to use arm-v7a-linux-gnueabihf-gcc. It seems that your issue is linked to some options. Have you checked the documentation for options to use with gcc : https://gcc.gnu.org/onlinedocs/gcc/Option-Summary.html ? – oneshepherdssheep May 15 '20 at 16:57
  • -Wl is a directive to pass whatever's after the comma to the linker subprocess. So if you pass it directly to a linker, it will fail. In that case you'd need to pass '-Bsymbolic" instead. – bdbaddog May 17 '20 at 20:28

2 Answers2

0

(can't comment), so as answer: have you tried to set the env.-var.: export LD=arm-v7a-linux-gnuabihf-gcc

Gcc takes -Wl,XXX and passes XXX to the linker.

Rainer Keller
  • 355
  • 2
  • 9
0

I think you've got two combining problems here, though there's some guessing involved without looking into the build itself. First, scons shouldn't be adding the flag when building a library (https://github.com/SCons/scons/issues/3248 - fixed but, I believe, not part of a release). Second, "linking" should probably be done using gcc. If you call gcc to link, it still calls the linker behind the scenes - after dealing with options that are intended for gcc, which -Wl,-Bsymbolic is, it means pass -Bsymbolic on to the linking phase (indicated by -Wl, the 'l' meaning linker). So I'm supposing that the way you've told scons about the cross toolchain isn't quite right either, if it's calling ld directly you're probably going to have other issues as well.

Mats Wichmann
  • 800
  • 6
  • 6