Issue with JACK on Raspian - c

After a successful configuration, build and installation of JACK v.2 from source, I am trying to compile a simple JACK client example:
pi#raspberrypi:~/jack $ gcc -o simple_client simple_client.c -l jack
However, the compiler returns the following errors:
/usr/bin/ld: /tmp/cc7341zz.o: undefined reference to symbol 'sin##GLIBC_2.4'
//lib/arm-linux-gnueabihf/libm.so.6: error adding symbols: DSO missing from command line
collect2: error: ld returned 1 exit status
Are they probably due to the ARM processor architecture? Can you, please, suggest me some hint about how to solve them?
Source code of the simple_client.c file is available at this link. Furthermore, it has been successfully compiled and tested on macOS Sierra.

Related

mipsel-linux-gcc is throwing 'undefined reference to 'timer_create'' linking error even though -lrt is mentioned

I am using 'timer_create', 'timer_settime' apis in my program. My PC environment is Ubuntu and i am building application for my smart device whose architecture is MIPS 32 bit.
Following is the linking error i am facing while build my program:
'MyProgram.c:(.text+0x178): undefined reference to timer_create'
MyProgram.c:(.text+0x1c8): undefined reference totimer_settime'
collect2: ld returned 1 exit status'.
This is the command i used to build my program:
mipsel-linux-gcc MyProgram.c -L/home/buildroot-gcc342/lib -lrt -o MyProgram.o
'mipsel-linux-gcc' is the compiler for MIPS 32 platform.

DSO missing from command line although it is available

I am working with c++ code for a physics simulation, which uses a lot of external libraries (like GSL and cern`s ROOT). Trying to recompile project I encountered problems with linking. When running compilation of final file via:
g++ -fno-inline -O2 -fpic -o main.out ${ROOTINCS} main.o ext.o ${ROOTLIBS} $(objects2)
with :
objects2= many .o files made by us
ROOTLIBS=-L/usr/local/lib/root -lTree -lRIO -lNet -lHist -lMathCore -lCore -lGraf -lGraf3d -lGpad -lMatrix -lThread -lCint -lPhysics -lPostscript -lRint -lSpectrum -lg
ROOTINCS=-pthread -m64
I get annoying error:
/usr/bin/ld: /usr/local/lib/root/libHist.so: undefined reference to symbol 'gRandom'
/usr/local/lib/root/libMathCore.so: error adding symbols: DSO missing from command line
collect2: error: ld returned 1 exit status
The problem is nm -C run on libMathCore states 'gRandom' is declared there. Also -lMathCore is present in my command line.
When I run ld to check if it understands the flag:
ld -L/usr/local/lib/root -lMathCore --verbose 2>/dev/null
it does not complain and tries to link properly.
According to https://stackoverflow.com/a/24675715/3602168 order of libraries is correct in my linking (libHist uses libMathCOre and therefore is stated first).
Compilation runs under g++ 4.8.2 on ubuntu 14.04, 64 bit
Converting comment to answer:
Have you tried moving $(objects2) before ${ROOTLIBS}? I think the issue may be that you have libraries specified before the object files that use them.

Winsock Program in c language is not working

I've started another program to run Winsock in C language on Windows7.
I found this help on msdn:
http://msdn.microsoft.com/en-us/library/windows/desktop/ms737591%28v=vs.85%29.aspx
This program is not working and showing these errors:
$ gcc ak1.c -o ak1.exe -lwsock32 -lws2_32 -lAdvapi32 -lmswsock
C:\Users\rahul\AppData\Local\Temp\ccWqZC7C.o:ak1.c:(.text+0x109): undefined re
ference to `getaddrinfo'
C:\Users\rahul\AppData\Local\Temp\ccWqZC7C.o:ak1.c:(.text+0x1fa): undefined re
ference to `freeaddrinfo'
c:/mingw/bin/../lib/gcc/mingw32/4.7.2/../../../../mingw32/bin/ld.exe: C:\Users\a
mit\AppData\Local\Temp\ccWqZC7C.o: bad reloc address 0x20 in section `.eh_frame'
c:/mingw/bin/../lib/gcc/mingw32/4.7.2/../../../../mingw32/bin/ld.exe: final link
failed: Invalid operation
collect2.exe: error: ld returned 1 exit status
Is this error related to MICROSOFT SDK for Windows7, means these libraries are not added on my system.
I checked "Advapi32" is not under my micrsoft SDK.
Help please !!!
You're using GCC (presumably MinGW) which doesn't use Microsoft's SDK. getaddrinfo() and freeaddrinfo() are declared in MinGW's ws2tcpip.h implementation, but only if WinXP or later is targeted.
Add -D_WIN32_WINNT=0x0501 to your compiler command line to target XP.
the solution is to add "-lws2_32" at the end of the command to compile with gcc ;-)

program links properly on school machine, but not on personal one: undefined reference to log

I can ssh to my schools Ubuntu 11.04 server where I have to submit my code and this links fine:
ME#SCHOOL:~/309/project2$ make
gcc -lm treesort.c -o treesort
ME#SCHOOL:~/309/project2$
My local machine is running Ubuntu 12.04 and here is the compiler output for the same code, but using the NetBeans makefile:
gcc -lm -o dist/Release/GNU-Linux-x86/treesort build/Release/GNU-Linux-x86/sortFns.o build/Release/GNU-Linux-x86/treesort.o
build/Release/GNU-Linux-x86/treesort.o: In function `processargs':
treesort.c:(.text+0x144): undefined reference to `log'
collect2: ld returned 1 exit status
Using the command line on my local machine with the same code and makefile from the first example:
ME#MYCOMPUTER:~/Documents/CSCI/309/project2$ make
gcc -lm treesort.c -o treesort
/tmp/ccY5GqF1.o: In function `processargs':
treesort.c:(.text+0x2b5): undefined reference to `log'
collect2: ld returned 1 exit status
make: *** [all] Error 1
ME#MYCOMPUTER:~/Documents/CSCI/309/project2$
This is really quite irritating, and I can't figure out why it works on the server and not on my local machine. I found this question, but it didn't help.
Put -lm at the end of the link line. The order of sources,objects and (archive) libraries on the link line matters, and yours is wrong.
If putting -lm at the end of the link line doesn't help, you have some bogus library called libm.{a,so} somewhere on your system, and you should figure out where it came from, and get rid of it.
You cam find out which libm your linker is finding with gcc -Wl,-t ...

Program compiles on one server, doesn't on another

I'm getting this error when I try and compile my program on my school's external server.
Undefined first referenced
symbol in file
pow /var/tmp//ccWbipvM.o
sqrt /var/tmp//ccWbipvM.o
ld: fatal: Symbol referencing errors. No output written to assign1
collect2: ld returned 1 exit status
The problem is I don't get it when I compile it locally - it runs fine. Can anyone give me some advice as to what the problem is here?? Thanks!
PS: math.h has been included.
Try linking your program with the math library by using the -lm flag:
gcc -o prg -lm prg.c

Resources