ALSA Lib 1.1.2 Compilation error - c

I am trying to cross compile ALSA Lib application for linux-arm based processor. I am using eclipse to do the build for me. The build phase of the application is successful but I get errrors when the gcc linker tries to complete.
I get the following errors
Building target: sound
Invoking: Cross GCC Linker
arm-linux-gnueabihf-gcc -L/proc/asound -L/srv/nfs/rootfs/usr/lib -Wl,-rpath-link,/srv/nfs/rootfs/usr/lib -L/srv/nfs/rootfs/lib -Wl,-rpath-link,/srv/nfs/rootfs/lib -o "sound" ./play.o
./play.o: In function main':
/home/neonws/sound/Debug/../play.c:13: undefined reference tosnd_pcm_open'
makefile:29: recipe for target 'sound' failed
/home/neonws/sound/Debug/../play.c:14: undefined reference to snd_strerror'
/home/neonws/sound/Debug/../play.c:20: undefined reference tosnd_pcm_hw_params_malloc'
/home/neonws/sound/Debug/../play.c:21: undefined reference to snd_strerror'
/home/neonws/sound/Debug/../play.c:26: undefined reference tosnd_pcm_hw_params_any'
/home/neonws/sound/Debug/../play.c:27: undefined reference to snd_strerror'
/home/neonws/sound/Debug/../play.c:32: undefined reference tosnd_pcm_hw_params_set_access'
/home/neonws/sound/Debug/../play.c:33: undefined reference to snd_strerror'
/home/neonws/sound/Debug/../play.c:38: undefined reference tosnd_pcm_hw_params_set_format'
/home/neonws/sound/Debug/../play.c:39: undefined reference to snd_strerror'
/home/neonws/sound/Debug/../play.c:44: undefined reference tosnd_pcm_hw_params_set_rate_near'
/home/neonws/sound/Debug/../play.c:45: undefined reference to snd_strerror'
/home/neonws/sound/Debug/../play.c:50: undefined reference tosnd_pcm_hw_params_set_channels'
/home/neonws/sound/Debug/../play.c:51: undefined reference to snd_strerror'
/home/neonws/sound/Debug/../play.c:56: undefined reference tosnd_pcm_hw_params'
/home/neonws/sound/Debug/../play.c:57: undefined reference to snd_strerror'
/home/neonws/sound/Debug/../play.c:62: undefined reference tosnd_pcm_hw_params_free'
/home/neonws/sound/Debug/../play.c:64: undefined reference to snd_pcm_prepare'
/home/neonws/sound/Debug/../play.c:65: undefined reference tosnd_strerror'
/home/neonws/sound/Debug/../play.c:71: undefined reference to snd_pcm_writei'
/home/neonws/sound/Debug/../play.c:72: undefined reference tosnd_strerror'
/home/neonws/sound/Debug/../play.c:78: undefined reference to `snd_pcm_close'
collect2: error: ld returned 1 exit status
make: *** [sound] Error 1
11:15:58 Build Finished (took 75ms)
I am using the Sample Playback Program from ASLA-LIB api.
I am wondering what is causing the linker to fail?

You're missing an asound library linkage, add -lasound to your linking flags (see this question which tells where to do that properly in Eclipse). And probably remove -L/proc/asound, I don't think you have your libraries there.

Related

Eclipse MinGW undefined reference to SDL functions

So I've been searching for nigh on two hours now, haven't found a single working solution. I'm using SDL 2.0.4, and all the libraries are for the x64 architecture. I don't get the errors with SDL v1, but I need some of the newer functions. Here's what's coming up:
Info: Internal Builder is used for build
gcc -o Winchester.exe "src\\Winchester.o" -lmingw32 -lSDL2
src\Winchester.o: In function `SDL_main':
C:\Users\inigo\workspace\Winchester\Debug/../src/Winchester.c:17: undefined reference to `SDL_Init'
C:\Users\inigo\workspace\Winchester\Debug/../src/Winchester.c:20: undefined reference to `SDL_CreateWindow'
C:\Users\inigo\workspace\Winchester\Debug/../src/Winchester.c:22: undefined reference to `SDL_Quit'
C:\Users\inigo\workspace\Winchester\Debug/../src/Winchester.c:26: undefined reference to `SDL_CreateRenderer'
C:\Users\inigo\workspace\Winchester\Debug/../src/Winchester.c:28: undefined reference to `SDL_DestroyWindow'
C:\Users\inigo\workspace\Winchester\Debug/../src/Winchester.c:29: undefined reference to `SDL_Quit'
C:\Users\inigo\workspace\Winchester\Debug/../src/Winchester.c:36: undefined reference to `SDL_PollEvent'
C:\Users\inigo\workspace\Winchester\Debug/../src/Winchester.c:39: undefined reference to `SDL_DestroyRenderer'
C:\Users\inigo\workspace\Winchester\Debug/../src/Winchester.c:40: undefined reference to `SDL_DestroyWindow'
c:/mingw/bin/../lib/gcc/mingw32/4.8.1/../../../libmingw32.a(main.o):(.text.startup+0xa7): undefined reference to `WinMain#16'
collect2.exe: error: ld returned 1 exit status
Any help?

Cplex library gcc compilation link error

gcc -I/opt/cplex-studio-125/cplex/include -lcplex -L/opt/cplex-studio-125/cplex/lib/x86-64_sles10_4.1/static_pic mipex1.c
I'm trying to compile an example from cplex. -I option is fine. The -L option seems to be corrupt, since it can't find the function names.
Where is the error? In the specifiec link there is a libcplex.a.
/tmp/ccf5sKky.o: In function `main':
mipex1.c:(.text+0x9f): undefined reference to `CPXopenCPLEX'
mipex1.c:(.text+0xee): undefined reference to `CPXgeterrorstring'
mipex1.c:(.text+0x125): undefined reference to `CPXsetintparam'
mipex1.c:(.text+0x222): undefined reference to `CPXcreateprob'
mipex1.c:(.text+0x2e1): undefined reference to `CPXcopylp'
mipex1.c:(.text+0x334): undefined reference to `CPXcopyctype'
mipex1.c:(.text+0x380): undefined reference to `CPXmipopt'
mipex1.c:(.text+0x3cc): undefined reference to `CPXgetstat'
mipex1.c:(.text+0x403): undefined reference to `CPXgetobjval'
mipex1.c:(.text+0x474): undefined reference to `CPXgetnumrows'
mipex1.c:(.text+0x490): undefined reference to `CPXgetnumcols'
mipex1.c:(.text+0x4be): undefined reference to `CPXgetx'
mipex1.c:(.text+0x51c): undefined reference to `CPXgetslack'
mipex1.c:(.text+0x5f9): undefined reference to `CPXwriteprob'
mipex1.c:(.text+0x64d): undefined reference to `CPXfreeprob'
mipex1.c:(.text+0x697): undefined reference to `CPXcloseCPLEX'
mipex1.c:(.text+0x6e3): undefined reference to `CPXgeterrorstring'
collect2: error: ld returned 1 exit status
The order of appearance of the library matters. Change your compilation statement to
gcc -I/opt/cplex-studio-125/cplex/include mipex1.c L/opt/cplex-studio-125/cplex/lib/x86-64_sles10_4.1/static_pic -lcplex
(Generic version)
gcc -I/<path> -L<path> <source.c> -l<lib>
to put the library after the source file, so that, linker will search the library for the function called from the source file.

hiredis "undefined reference to" compiler error

I want to compile the client for redis in C. I've downloaded and installed the libevent library and the hiredis files. I've used this command:
gcc -I/home/tasos/Dropbox/lists/hiredis example-libevent.c -levent
but I get these errors:
/tmp/ccxoerYJ.o: In function `redisLibeventReadEvent':
example-libevent.c:(.text+0x28): undefined reference to `redisAsyncHandleRead'
/tmp/ccxoerYJ.o: In function `redisLibeventWriteEvent':
example-libevent.c:(.text+0x56): undefined reference to `redisAsyncHandleWrite'
/tmp/ccxoerYJ.o: In function `getCallback':
example-libevent.c:(.text+0x2d2): undefined reference to `redisAsyncDisconnect'
/tmp/ccxoerYJ.o: In function `main':
example-libevent.c:(.text+0x393): undefined reference to `redisAsyncConnect'
example-libevent.c:(.text+0x3f3): undefined reference to `redisAsyncSetConnectCallback'
example-libevent.c:(.text+0x404): undefined reference to `redisAsyncSetDisconnectCallback'
example-libevent.c:(.text+0x45d): undefined reference to `redisAsyncCommand'
example-libevent.c:(.text+0x47d): undefined reference to `redisAsyncCommand'
collect2: ld returned 1 exit status
why isn't this working?
Use -levent and -lhiredis compile option in command.

Compiling libjpeg on Windows using cygwin?

Which is the best way to compile libjpeg on a Windows machine? Should I use Microsoft Visual Studio or can I use something else like Cygwin?
Note: when I use Cygwin and copy makefile.vc to Makefile, jconfig.vc to jconfig.h and run this sample code: http://www.cim.mcgill.ca/~junaed/code/libjpeg_sample.tar.gz
then the compiler produces the following errors:
$ gcc main.c
C:\cygwin\tmp\ccwChyeY.o:main.c:(.text+0x5a): undefined reference to `jpeg_std_error'
C:\cygwin\tmp\ccwChyeY.o:main.c:(.text+0x7e): undefined reference to `jpeg_CreateDecompress'
C:\cygwin\tmp\ccwChyeY.o:main.c:(.text+0x93): undefined reference to `jpeg_stdio_src'
C:\cygwin\tmp\ccwChyeY.o:main.c:(.text+0xa9): undefined reference to `jpeg_read_header'
C:\cygwin\tmp\ccwChyeY.o:main.c:(.text+0xb7): undefined reference to `jpeg_start_decompress'
C:\cygwin\tmp\ccwChyeY.o:main.c:(.text+0x11b): undefined reference to `jpeg_read_scanlines'
C:\cygwin\tmp\ccwChyeY.o:main.c:(.text+0x178): undefined reference to `jpeg_finish_decompress'
C:\cygwin\tmp\ccwChyeY.o:main.c:(.text+0x186): undefined reference to `jpeg_destroy_decompress'
C:\cygwin\tmp\ccwChyeY.o:main.c:(.text+0x1f6): undefined reference to `jpeg_std_error'
C:\cygwin\tmp\ccwChyeY.o:main.c:(.text+0x21a): undefined reference to `jpeg_CreateCompress'
C:\cygwin\tmp\ccwChyeY.o:main.c:(.text+0x22f): undefined reference to `jpeg_stdio_dest'
C:\cygwin\tmp\ccwChyeY.o:main.c:(.text+0x269): undefined reference to `jpeg_set_defaults'
C:\cygwin\tmp\ccwChyeY.o:main.c:(.text+0x27f): undefined reference to `jpeg_start_compress'
C:\cygwin\tmp\ccwChyeY.o:main.c:(.text+0x2c7): undefined reference to `jpeg_write_scanlines'
C:\cygwin\tmp\ccwChyeY.o:main.c:(.text+0x2e5): undefined reference to `jpeg_finish_compress'
C:\cygwin\tmp\ccwChyeY.o:main.c:(.text+0x2f3): undefined reference to `jpeg_destroy_compress'
collect2.exe: error: ld returned 1 exit status
Well, if you just want the .dll it is already compiled.
https://cygwin.com/cgi-bin2/package-grep.cgi?grep=libjpeg&arch=x86_64

Compilation error in GCC on Linux

I am trying to compile my code for GnuTLS, but on compiling it gives the following errors.
I have checked gnutls.h is present on my system in /usr/include/gnutls/.
What else can be the cause?
gcc -o tls.o tls.c
/tmp/ccfyZ1Bd.o: In function `main':
tls.c:(.text+0x1c): undefined reference to `gnutls_global_init'
tls.c:(.text+0x28): undefined reference to `gnutls_anon_allocate_client_credentials'
tls.c:(.text+0x3c): undefined reference to `gnutls_init'
tls.c:(.text+0x58): undefined reference to `gnutls_priority_set_direct'
tls.c:(.text+0x74): undefined reference to `gnutls_credentials_set'
tls.c:(.text+0x79): undefined reference to `tcp_connect'
tls.c:(.text+0x91): undefined reference to `gnutls_transport_set_ptr'
tls.c:(.text+0x9d): undefined reference to `gnutls_handshake'
tls.c:(.text+0xdc): undefined reference to `gnutls_perror'
tls.c:(.text+0x109): undefined reference to `gnutls_record_send'
tls.c:(.text+0x125): undefined reference to `gnutls_record_recv'
tls.c:(.text+0x154): undefined reference to `gnutls_strerror'
tls.c:(.text+0x1e6): undefined reference to `gnutls_bye'
tls.c:(.text+0x1f2): undefined reference to `tcp_close'
tls.c:(.text+0x1fe): undefined reference to `gnutls_deinit'
tls.c:(.text+0x20a): undefined reference to `gnutls_anon_free_client_credentials'
tls.c:(.text+0x20f): undefined reference to `gnutls_global_deinit'
collect2: ld returned 1 exit status
This is a linking error. You need to include some library with the -l flag. Taking a wild guess without knowing your setup, I would try -lgnutls

Resources