1

I try to crosscompile this small program to my arm device, but get error:

arm-none-linux-gnueabi/bin/ld: cannot find -lasound
collect2: error: ld returned 1 exit status

Then i found libasound files in my target device and have copied to my folder /usr/lib but still no effect. I use the commands:

export CFLAGS="-I/usr/include -I/usr/lib"
$CC -o play sound_playback.c $CFLAGS -lasound

I have installed libasound2-dev package on my Ubuntu 14.04 x64 and be able to compile the program on my native computer without any errors.

UPDATE WITH SOLUTION
As Marc and John have said below, i just should use -L flag to set my library path. So my command line should be:

$CC -o play sound_playback.c $CFLAGS -L/usr/lib -lasound
Footniko
  • 2,682
  • 2
  • 27
  • 36
  • 2
    Er, I don't think putting arm files in /usr/lib on an x86_64 machine is a good idea... Also, you probably meant `-L/usr/lib` but that's useless. Did you look into multiarch? – Marc Glisse Oct 24 '14 at 18:41
  • 1
    Marc is right, you should use -L (for libraries) and -I (for header files). Check where is the libasound.so[.XXX] and add this directory to the -L list of your compilation command. Don't put "cross compiled files" in your /usr/lib/ directory, you may mess things up. – JohnTortugo Oct 24 '14 at 18:53
  • Oh, thank you guys! I just add -L/usr/lib to my command and it working! – Footniko Oct 24 '14 at 19:02

0 Answers0