0

Hallo I'm new in Ubuntu.

I'm now using Lubuntu 15.04. arm-linux-gcc and gsl has been installed and I can use gcc to compile exe file with gsl. But when I trying to use arm-linux-gcc to compile exe files I got a error

"/usr/local/arm/4.3.2/bin/../lib/gcc/arm-none-linux-gnueabi/4.3.2/../../../../arm-none-linux-gnueabi/bin/ld: cannot find -lgsl"

This is the code I used for cross compiling.

 $ arm-linux-gcc -o fft_test fft_test.c -L/home/peter/gsl/lib -I/home/peter/gsl/include -lgsl -lgslcblas -lm
  • Did you already install appropriate arm versions of gsl and blas into /home/peter/gsl? If so, how exactly? – steeldriver Mar 2 '16 at 15:24
  • Thank you.Yes. I do following a youtube youtube.com/watch?v=JrvnJaj7Ogk. But I can only compile this source code with gcc compiler. – Rui Sun Mar 3 '16 at 14:51
  • Could you please specify which ARM platform and distro on that platfrom you are using? Cross-compilation is very depend on such info, because even if you build your app on your PC it couldn't run on your ARM device due to ABI incompatibility used in ARM distro. – stunpix Mar 3 '16 at 16:01
  • Thank you. I use arm7. which compiler I can use for this platform? – Rui Sun Mar 6 '16 at 18:10
0

Seems you didn't installed libgsl in your system, since path /home/peter/gsl is not a path where Ubuntu installs binaries. I can only suppose you have only downloaded sources of libgls from GNU server and did unpack them to /home/peter/gsl. This isn't canonical way. You don't need to download libgsl manually, because Ubuntu already delivers thousands of libraries and tools in packages from its own online repositories. To manage packages (download, install and remove) you should use apt-get tool.

UPD: As suggested in comments, you are trying to cross-compile your application to run on ARM platform. This requires some additional steps. I suppose that linux distro installed on your ARM device is 32bit and is using armhf/hard-float ABI (btw, official Ubuntu doesn't provide soft-float binaries).

Add new architectures and online repositories to your Ubuntu:

REL=$(lsb_release -sc)
sudo dpkg --add-architecture armhf

sudo add-apt-repository "deb [arch=armhf] http://ports.ubuntu.com/ ${REL} main universe multiverse restricted"
sudo add-apt-repository "deb [arch=armhf] http://ports.ubuntu.com/ ${REL}-updates main universe multiverse restricted"
sudo add-apt-repository "deb [arch=armhf] http://ports.ubuntu.com/ ${REL}-security main universe multiverse restricted"
sudo add-apt-repository "deb [arch=armhf] http://ports.ubuntu.com/ ${REL}-restricted main universe multiverse restricted"
sudo add-apt-repository "deb [arch=armhf] http://ports.ubuntu.com/ ${REL}-backports main universe multiverse restricted"

sudo apt-get update

Now you can install tools for cross-compilation and ARM version of libgsl:

sudo apt-get install crossbuild-essential-armhf libgsl0-dev:armhf

Then you can try to compile your app:

arm-linux-gnueabihf-gcc -o fft_test fft_test.c -lgsl -lgslcblas -lm

Note, there are no -L or -I parameters, since all libgsl files were installed at places reachable by compiler.

  • Won't that just install the native versions of the libraries? – steeldriver Mar 2 '16 at 15:22
  • thank you. I use ./config --prefix= to change the path of install, because under default install it said "usr/local/include/gsl" is not safe... I also installed the libgsl0-dev. The problem is I can use "gcc -o fft_test fft_test.c -lgsl -lgslcblas -lm". – Rui Sun Mar 3 '16 at 14:53
  • sometimes I think maybe gsl can not be cross compile by arm-linux-gcc or I need do someting more? – Rui Sun Mar 3 '16 at 14:57
  • The error is "/usr/local/arm/4.3.2/bin/../lib/gcc/arm-none-linux-gnueabi/4.3.2/../../../../arm-none-linux-gnueabi/bin/ld: warning: library search path "/usr/local/lib" is unsafe for cross-compilation" – Rui Sun Mar 3 '16 at 15:30
  • @steeldriver Good point. I've updated my answer. – stunpix Mar 3 '16 at 16:22

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.