[alsa-devel] Errors in application building
Hello all:
I am working on my first bit of application code for ALSA and am not sure how to properly compile it against the libs. I have to cross compile the application on my host machine i686 PC for use on a ARM development board. I copied the alsa include directory into my staging include directory (this is where the cross-compiler works from), which allowed the program to find alsa/asoundlib.h However, I am still getting some errors that indicate to me it cannot find everything it needs.
I am getting the following errors:
grhuser@pcL7:$ arm-linux-gcc -Wall -o grh_audio grh_audio.c grh_audio.c: In function 'grh_capture': grh_audio.c:113: warning: pointer targets in passing argument 3 of 'snd_pcm_hw_params_set_rate_near' differ in signedness grh_audio.c: In function 'grh_playback': grh_audio.c:208: warning: pointer targets in passing argument 3 of 'snd_pcm_hw_params_set_rate_near' differ in signedness /tmp/ccMn48zN.o: In function `grh_capture': grh_audio.c:(.text+0x16c): undefined reference to `snd_pcm_open' grh_audio.c:(.text+0x198): undefined reference to `snd_strerror' grh_audio.c:(.text+0x1c0): undefined reference to `snd_pcm_hw_params_malloc' grh_audio.c:(.text+0x1e4): undefined reference to `snd_strerror' grh_audio.c:(.text+0x214): undefined reference to `snd_pcm_hw_params_any' grh_audio.c:(.text+0x238): undefined reference to `snd_strerror' grh_audio.c:(.text+0x26c): undefined reference to `snd_pcm_hw_params_set_access' grh_audio.c:(.text+0x290): undefined reference to `snd_strerror' grh_audio.c:(.text+0x2c4): undefined reference to `snd_pcm_hw_params_set_format' grh_audio.c:(.text+0x2e8): undefined reference to `snd_strerror' grh_audio.c:(.text+0x324): undefined reference to `snd_pcm_hw_params_set_rate_near' grh_audio.c:(.text+0x348): undefined reference to `snd_strerror' grh_audio.c:(.text+0x380): undefined reference to `snd_pcm_hw_params_set_channels' grh_audio.c:(.text+0x3a4): undefined reference to `snd_strerror' grh_audio.c:(.text+0x3d4): undefined reference to `snd_pcm_hw_params' grh_audio.c:(.text+0x3f8): undefined reference to `snd_strerror' grh_audio.c:(.text+0x420): undefined reference to `snd_pcm_hw_params_free' grh_audio.c:(.text+0x42c): undefined reference to `snd_pcm_prepare' grh_audio.c:(.text+0x450): undefined reference to `snd_strerror' grh_audio.c:(.text+0x494): undefined reference to `snd_pcm_readi' grh_audio.c:(.text+0x4c0): undefined reference to `snd_strerror' grh_audio.c:(.text+0x500): undefined reference to `snd_pcm_close' /tmp/ccMn48zN.o: In function `grh_playback': grh_audio.c:(.text+0x5b8): undefined reference to `snd_pcm_open' grh_audio.c:(.text+0x5e4): undefined reference to `snd_strerror' grh_audio.c:(.text+0x60c): undefined reference to `snd_pcm_hw_params_malloc' grh_audio.c:(.text+0x630): undefined reference to `snd_strerror' grh_audio.c:(.text+0x660): undefined reference to `snd_pcm_hw_params_any' grh_audio.c:(.text+0x684): undefined reference to `snd_strerror' grh_audio.c:(.text+0x6b8): undefined reference to `snd_pcm_hw_params_set_access' grh_audio.c:(.text+0x6dc): undefined reference to `snd_strerror' grh_audio.c:(.text+0x710): undefined reference to `snd_pcm_hw_params_set_format' grh_audio.c:(.text+0x734): undefined reference to `snd_strerror' grh_audio.c:(.text+0x770): undefined reference to `snd_pcm_hw_params_set_rate_near' grh_audio.c:(.text+0x794): undefined reference to `snd_strerror' grh_audio.c:(.text+0x7cc): undefined reference to `snd_pcm_hw_params_set_channels' grh_audio.c:(.text+0x7f0): undefined reference to `snd_strerror' grh_audio.c:(.text+0x820): undefined reference to `snd_pcm_hw_params' grh_audio.c:(.text+0x844): undefined reference to `snd_strerror' grh_audio.c:(.text+0x86c): undefined reference to `snd_pcm_hw_params_free' grh_audio.c:(.text+0x878): undefined reference to `snd_pcm_prepare' grh_audio.c:(.text+0x89c): undefined reference to `snd_strerror' grh_audio.c:(.text+0x8e0): undefined reference to `snd_pcm_writei' grh_audio.c:(.text+0x90c): undefined reference to `snd_strerror' grh_audio.c:(.text+0x94c): undefined reference to `snd_pcm_close' collect2: ld returned 1 exit status
My application code is attached. If anyone could give me some pointers as to why these errors are occurring, I would appreciate it greatly.
Thanks.
Paul
On 7/3/07, Paul Kavan pkavan@gmail.com wrote:
grhuser@pcL7:$ arm-linux-gcc -Wall -o grh_audio grh_audio.c
You need to add -lasound to the gcc command line.
Lee
On 7/3/07, Lee Revell rlrevell@joe-job.com wrote:
On 7/3/07, Paul Kavan pkavan@gmail.com wrote:
grhuser@pcL7:$ arm-linux-gcc -Wall -o grh_audio grh_audio.c
You need to add -lasound to the gcc command line.
Lee
Thanks Lee. I was digging and just found that. When I tried, I lose all the other errors, still keep the warnings, but get a new error. The compile attempts looks like this:
arm-linux-gcc -lasound -Wall -o grh_audio grh_audio.c grh_audio.c: In function 'grh_capture': grh_audio.c:112: warning: pointer targets in passing argument 3 of 'snd_pcm_hw_params_set_rate_near' differ in signedness grh_audio.c: In function 'grh_playback': grh_audio.c:207: warning: pointer targets in passing argument 3 of 'snd_pcm_hw_params_set_rate_near' differ in signedness /home/grhuser/buildroot/build_arm/staging_dir/lib/gcc/arm-linux-uclibc/4.1.2/../../../../arm-linux-uclibc/bin/ld: cannot find -lasound collect2: ld returned 1 exit status
I guess I am not sure where lasound ought to be....do you know what file name I should be looking for and where it should be located for proper compiling?
On 7/3/07, Paul Kavan pkavan@gmail.com wrote:
On 7/3/07, Lee Revell rlrevell@joe-job.com wrote:
On 7/3/07, Paul Kavan pkavan@gmail.com wrote:
grhuser@pcL7:$ arm-linux-gcc -Wall -o grh_audio grh_audio.c
You need to add -lasound to the gcc command line.
Lee
Thanks Lee. I was digging and just found that. When I tried, I lose all the other errors, still keep the warnings, but get a new error. The compile attempts looks like this:
arm-linux-gcc -lasound -Wall -o grh_audio grh_audio.c grh_audio.c: In function 'grh_capture': grh_audio.c:112: warning: pointer targets in passing argument 3 of 'snd_pcm_hw_params_set_rate_near' differ in signedness grh_audio.c: In function 'grh_playback': grh_audio.c:207: warning: pointer targets in passing argument 3 of 'snd_pcm_hw_params_set_rate_near' differ in signedness /home/grhuser/buildroot/build_arm/staging_dir/lib/gcc/arm-linux-uclibc/4.1.2/../../../../arm-linux-uclibc/bin/ld: cannot find -lasound collect2: ld returned 1 exit status
I guess I am not sure where lasound ought to be....do you know what file name I should be looking for and where it should be located for proper compiling?
OK, my face is more than a little red. Was making that much more difficult than it needed to be. Moved the asound libs to my staging directory and the program compiles to an executable...although with the two warnings:
grhuser@pcL7:$ arm-linux-gcc -lasound -Wall -o grh_audio grh_audio.c grh_audio.c: In function 'grh_capture': grh_audio.c:112: warning: pointer targets in passing argument 3 of 'snd_pcm_hw_params_set_rate_near' differ in signedness grh_audio.c: In function 'grh_playback': grh_audio.c:207: warning: pointer targets in passing argument 3 of 'snd_pcm_hw_params_set_rate_near' differ in signedness
Which comes from the code:
112: if ((err = snd_pcm_hw_params_set_rate_near (capture_handle, hw_params, &sample_rate, 0)) < 0)
207: if ((err = snd_pcm_hw_params_set_rate_near (playback_handle, hw_params, &sample_rate, 0)) < 0)
I followed a piece of example code. I will look at this function to see if I can parse this warning out.
Paul
Hello all:
Just tried to run with the warnings:
grhuser@pcL7:$ arm-linux-gcc -lasound -Wall -o grh_audio grh_audio.c
grh_audio.c: In function 'grh_capture': grh_audio.c:112: warning: pointer targets in passing argument 3 of 'snd_pcm_hw_params_set_rate_near' differ in signedness grh_audio.c: In function 'grh_playback': grh_audio.c:207: warning: pointer targets in passing argument 3 of 'snd_pcm_hw_params_set_rate_near' differ in signedness
Which comes from the code:
112: if ((err = snd_pcm_hw_params_set_rate_near (capture_handle, hw_params, &sample_rate, 0)) < 0)
207: if ((err = snd_pcm_hw_params_set_rate_near (playback_handle, hw_params, &sample_rate, 0)) < 0)
However, I get a seg fault when I ran it. The strace of this is:
/usr/sbin $ strace grh_audio execve("/usr/sbin/grh_audio", ["grh_audio"], [/* 7 vars */]) = 0 mmap2(NULL, 20, PROT_READ|PROT_WRITE, MAP_PRIVATE|MAP_ANONYMOUS, -1, 0) = 0x40005000 stat("/etc/ld.so.cache", {st_mode=S_IFREG|0644, st_size=1150, ...}) = 0 open("/etc/ld.so.cache", O_RDONLY) = 3 mmap2(NULL, 1150, PROT_READ, MAP_SHARED, 3, 0) = 0x40006000 close(3) = 0 open("/usr/lib/libasound.so.2", O_RDONLY) = 3 fstat(3, {st_mode=S_IFREG|0755, st_size=762072, ...}) = 0 mmap2(NULL, 4096, PROT_READ|PROT_WRITE, MAP_PRIVATE|MAP_ANONYMOUS, -1, 0) = 0x40007000 read(3, "\177ELF\1\1\1a\0\0\0\0\0\0\0\0\3\0(\0\1\0\0\0x\367\1\000"..., 4096) = 4096 mmap2(NULL, 794624, PROT_NONE, MAP_PRIVATE|MAP_ANONYMOUS, -1, 0) = 0x4000e000 mmap2(0x4000e000, 745564, PROT_READ|PROT_EXEC, MAP_PRIVATE|MAP_FIXED, 3, 0) = 0x4000e000 mmap2(0x400cc000, 15508, PROT_READ|PROT_WRITE, MAP_PRIVATE|MAP_FIXED, 3, 0xb6) = 0x400cc000 close(3) = 0 munmap(0x40007000, 4096) = 0 open("/lib/libgcc_s.so.1", O_RDONLY) = 3 fstat(3, {st_mode=S_IFREG|0644, st_size=44167, ...}) = 0 mmap2(NULL, 4096, PROT_READ|PROT_WRITE, MAP_PRIVATE|MAP_ANONYMOUS, -1, 0) = 0x40007000 read(3, "\177ELF\1\1\1a\0\0\0\0\0\0\0\0\3\0(\0\1\0\0\0X\25\0\000"..., 4096) = 4096 mmap2(NULL, 65536, PROT_NONE, MAP_PRIVATE|MAP_ANONYMOUS, -1, 0) = 0x400d0000 mmap2(0x400d0000, 28800, PROT_READ|PROT_EXEC, MAP_PRIVATE|MAP_FIXED, 3, 0) = 0x400d0000 mmap2(0x400df000, 548, PROT_READ|PROT_WRITE, MAP_PRIVATE|MAP_FIXED, 3, 0x7) = 0x400df000 close(3) = 0 munmap(0x40007000, 4096) = 0 open("/lib/libc.so.0", O_RDONLY) = 3 fstat(3, {st_mode=S_IFREG|0644, st_size=309840, ...}) = 0 mmap2(NULL, 4096, PROT_READ|PROT_WRITE, MAP_PRIVATE|MAP_ANONYMOUS, -1, 0) = 0x40007000 read(3, "\177ELF\1\1\1a\0\0\0\0\0\0\0\0\3\0(\0\1\0\0\0000\253\0"..., 4096) = 4096 mmap2(NULL, 360448, PROT_NONE, MAP_PRIVATE|MAP_ANONYMOUS, -1, 0) = 0x400e0000 mmap2(0x400e0000, 302380, PROT_READ|PROT_EXEC, MAP_PRIVATE|MAP_FIXED, 3, 0) = 0x400e0000 mmap2(0x40132000, 5172, PROT_READ|PROT_WRITE, MAP_PRIVATE|MAP_FIXED, 3, 0x4a) = 0x40132000 mmap2(0x40134000, 16020, PROT_READ|PROT_WRITE, MAP_PRIVATE|MAP_FIXED|MAP_ANONYMOUS, -1, 0) = 0x40130 close(3) = 0 munmap(0x40007000, 4096) = 0 open("/lib/libm.so.0", O_RDONLY) = 3 fstat(3, {st_mode=S_IFREG|0644, st_size=45812, ...}) = 0 mmap2(NULL, 4096, PROT_READ|PROT_WRITE, MAP_PRIVATE|MAP_ANONYMOUS, -1, 0) = 0x40007000 read(3, "\177ELF\1\1\1a\0\0\0\0\0\0\0\0\3\0(\0\1\0\0\0t\22\0\000"..., 4096) = 4096 mmap2(NULL, 81920, PROT_NONE, MAP_PRIVATE|MAP_ANONYMOUS, -1, 0) = 0x40138000 mmap2(0x40138000, 41428, PROT_READ|PROT_EXEC, MAP_PRIVATE|MAP_FIXED, 3, 0) = 0x40138000 mmap2(0x4014a000, 4100, PROT_READ|PROT_WRITE, MAP_PRIVATE|MAP_FIXED, 3, 0xa) = 0x4014a000 close(3) = 0 munmap(0x40007000, 4096) = 0 open("/lib/libdl.so.0", O_RDONLY) = 3 fstat(3, {st_mode=S_IFREG|0644, st_size=8900, ...}) = 0 mmap2(NULL, 4096, PROT_READ|PROT_WRITE, MAP_PRIVATE|MAP_ANONYMOUS, -1, 0) = 0x40007000 read(3, "\177ELF\1\1\1a\0\0\0\0\0\0\0\0\3\0(\0\1\0\0\0(\10\0\000"..., 4096) = 4096 mmap2(NULL, 40960, PROT_NONE, MAP_PRIVATE|MAP_ANONYMOUS, -1, 0) = 0x4014c000 mmap2(0x4014c000, 5760, PROT_READ|PROT_EXEC, MAP_PRIVATE|MAP_FIXED, 3, 0) = 0x4014c000 mmap2(0x40155000, 4096, PROT_READ|PROT_WRITE, MAP_PRIVATE|MAP_FIXED, 3, 0x1) = 0x40155000 close(3) = 0 munmap(0x40007000, 4096) = 0 open("/lib/libpthread.so.0", O_RDONLY) = 3 fstat(3, {st_mode=S_IFREG|0644, st_size=63852, ...}) = 0 mmap2(NULL, 4096, PROT_READ|PROT_WRITE, MAP_PRIVATE|MAP_ANONYMOUS, -1, 0) = 0x40007000 read(3, "\177ELF\1\1\1a\0\0\0\0\0\0\0\0\3\0(\0\1\0\0\0D<\0\0004"..., 4096) = 4096 mmap2(NULL, 106496, PROT_NONE, MAP_PRIVATE|MAP_ANONYMOUS, -1, 0) = 0x40156000 mmap2(0x40156000, 40952, PROT_READ|PROT_EXEC, MAP_PRIVATE|MAP_FIXED, 3, 0) = 0x40156000 mmap2(0x40168000, 21732, PROT_READ|PROT_WRITE, MAP_PRIVATE|MAP_FIXED, 3, 0xa) = 0x40168000 mmap2(0x4016e000, 5788, PROT_READ|PROT_WRITE, MAP_PRIVATE|MAP_FIXED|MAP_ANONYMOUS, -1, 0) = 0x4016e0 close(3) = 0 munmap(0x40007000, 4096) = 0 open("/lib/libgcc_s.so.1", O_RDONLY) = 3 fstat(3, {st_mode=S_IFREG|0644, st_size=44167, ...}) = 0 close(3) = 0 open("/lib/libc.so.0", O_RDONLY) = 3 fstat(3, {st_mode=S_IFREG|0644, st_size=309840, ...}) = 0 close(3) = 0 open("/lib/libc.so.0", O_RDONLY) = 3 fstat(3, {st_mode=S_IFREG|0644, st_size=309840, ...}) = 0 close(3) = 0 open("/lib/libc.so.0", O_RDONLY) = 3 fstat(3, {st_mode=S_IFREG|0644, st_size=309840, ...}) = 0 close(3) = 0 open("/lib/libc.so.0", O_RDONLY) = 3 fstat(3, {st_mode=S_IFREG|0644, st_size=309840, ...}) = 0 close(3) = 0 open("/lib/libc.so.0", O_RDONLY) = 3 fstat(3, {st_mode=S_IFREG|0644, st_size=309840, ...}) = 0 close(3) = 0 munmap(0x40006000, 1150) = 0 stat("/lib/ld-uClibc.so.0", {st_mode=S_IFREG|0755, st_size=21096, ...}) = 0 mprotect(0x40132000, 4096, PROT_READ) = 0 mprotect(0x4014a000, 4096, PROT_READ) = 0 mprotect(0x40155000, 4096, PROT_READ) = 0 mprotect(0x40168000, 4096, PROT_READ) = 0 mprotect(0x4000c000, 4096, PROT_READ) = 0 ioctl(0, SNDCTL_TMR_TIMEBASE or TCGETS, {B115200 opost isig icanon echo ...}) = 0 ioctl(1, SNDCTL_TMR_TIMEBASE or TCGETS, {B115200 opost isig icanon echo ...}) = 0 getpid() = 756 getrlimit(RLIMIT_STACK, {rlim_cur=8192*1024, rlim_max=RLIM_INFINITY}) = 0 setrlimit(RLIMIT_STACK, {rlim_cur=2040*1024, rlim_max=RLIM_INFINITY}) = 0 rt_sigaction(SIGRTMIN, {0x4015fd70, [], 0x4000000 /* SA_??? */}, NULL, 8) = 0 rt_sigaction(SIGRT_1, {0x4015fc98, [RTMIN], 0x4000000 /* SA_??? */}, NULL, 8) = 0 rt_sigaction(SIGRT_2, {0x4015f2d0, [], 0x4000000 /* SA_??? */}, NULL, 8) = 0 rt_sigprocmask(SIG_BLOCK, [RTMIN], NULL, 8) = 0 rt_sigprocmask(SIG_UNBLOCK, [RT_1], NULL, 8) = 0 --- SIGSEGV (Segmentation fault) @ 0 (0) --- +++ killed by SIGSEGV +++ Process 756 detached
I am still trying to locate why those warnings are popping up, but as that part of the code is not called immediately, I am wondering why the seg fault is occurring. Any clues?
Paul
*************************************** Paul David Kavan Project Engineer GRH Electronics, Inc. 402-734-4900 pkavan@gmail.com ***************************************
participants (2)
-
Lee Revell
-
Paul Kavan