I have this code that compiles fine on my desktop, but when I try to compile it on the raspberry pi, I get this error
gcc -Wall -O2 -lGL -lGLU -lm -lSDL_image -lfftw3 -lftdi `sdl-config --cflags --libs` -c main.c
gcc -Wall -O2 -lGL -lGLU -lm -lSDL_image -lfftw3 -lftdi `sdl-config --cflags --libs` -c fft.c
gcc -Wall -O2 -lGL -lGLU -lm -lSDL_image -lfftw3 -lftdi `sdl-config --cflags --libs` -c draw.c
gcc -Wall -O2 -lGL -lGLU -lm -lSDL_image -lfftw3 -lftdi `sdl-config --cflags --libs` -c table.c
gcc -Wall -O2 -lGL -lGLU -lm -lSDL_image -lfftw3 -lftdi `sdl-config --cflags --libs` -c serial.c
gcc -Wall -O2 -lGL -lGLU -lm -lSDL_image -lfftw3 -lftdi `sdl-config --cflags --libs` main.o fft.o draw.o table.o serial.o -o main
/usr/bin/ld: Warning: size of symbol `table' changed from 2048 in
table.o to 204 in
//usr/lib/arm-linux-gnueabihf/pulseaudio/libpulsecommon-10.0.so
/usr/bin/ld: table.o: undefined reference to symbol 'table'
//usr/lib/arm-linux-gnueabihf/pulseaudio/libpulsecommon-10.0.so: error
adding symbols: DSO missing from command line collect2: error: ld
returned 1 exit status makefile:6: recipe for target 'main' failed
make: *** [main] Error 1
I've tried reinstalling libpulse0 and made sure pulseaudio was installed, and I can find the libpulsecommon-10.0.so when I search for it on the pi. So I'm not sure what to do from here.
libpulsecommon has a global symbol named table, and your code (probably table.c) also has a public symbol with this name. The symbols are colliding when linking. Rename that variable/function on your code.
Related
I run it on Linux with x86/64 and ubuntu 2204, gcc version 11.2.0, GNU ld version 2.38.
When I run env LIBLEVELDB=/usr/local make in simpleleveldb dir and get this error:
cc -I. -I../simplehttp/.. -I/usr/local/include -I/usr/local/include -Wall -g -O2 -MM -MT simpleleveldb -MF simpleleveldb.deps simpleleveldb.c str_list_set.c
cc -I. -I../simplehttp/.. -I/usr/local/include -I/usr/local/include -Wall -g -O2 -o simpleleveldb simpleleveldb.c str_list_set.c -L. -L../simplehttp -L/usr/local/lib -L/usr/local/lib -L/usr/local/lib -levent -ljson-c -lsimplehttp -lleveldb -lm -lstdc++ -lsnappy -lpthread
/usr/bin/ld: /usr/local/lib/libsimplehttp.a(request.o):/home/zhdi/simplehttp/simplehttp/request.h:12: multiple definition of `simplehttp_reqs'; /usr/local/lib/libsimplehttp.a(simplehttp.o):/home/zhdi/simplehttp/simplehttp/request.h:12: first defined here
collect2: error: ld returned 1 exit status
make: *** [Makefile:26: simpleleveldb] Error 1
before do it I just build simplehttp follow this repo https://github.com/bitly/simplehttp.
Anyone has some idea? thanks!
I'm trying to use the AMQPoverWebsockets-Client example from the C-SDK of Azure-iothub.
How do I link the specific libraries to the makefile to compile it successfully?
I tried to write the path down in my makefile. But it didn't work.
Here is my makefile so far:
SENSOR=mcp9808
SENSOR2=adxl345x
SENSOR3=init
SENSOR4=filestorage
IOT1=src/iothubtransporthttp.c.o
IOT2=src/iothub_client_ll.c.o
IOT3=src/iothub_message.c.o
IOT4=src/platform_linux.c.o
IOT5=src/crt_abstractions.c.o
all:
gcc -Wall -c $(SENSOR).c -o $(SENSOR).o -lm -lwiringPi -lrt
gcc -Wall -c $(SENSOR2).c -o $(SENSOR2).o -lm -lwiringPi -lrt
gcc -Wall -c $(SENSOR4).c -o $(SENSOR4).o -lm -lwiringPi -lrt
gcc -Wall -c $(SENSOR3).c -o $(SENSOR3).o -lm -lrt `pkg-config --cflags --libs glib-2.0`
#gcc -Wall $(IOT1) $(IOT2) $(IOT3) $(IOT4) $(IOT5) iothub_client_sample_http.c -o iot_client -lm -lrt
gcc -Wall $(SENSOR).o $(SENSOR2).o $(SENSOR3).o $(SENSOR4).o main.c -o main -lm -lwiringPi -lrt `pkg-config --cflags --libs glib-2.0`
clean:
rm *.o > /dev/null 2>&1 &
Command used to link:
**libtool --tag=CC --mode=link gcc -I/usr/include/libxml2 -I/home/ovsdpdk/rpmbuild/BUILD/openvswitch-2.4.0.1/openvswitch-2.4.0/include/ -I/home/ovsdpdk/rpmbuild/BUILD/openvswitch-2.4.0.1/openvswitch-2.4.0/lib/ -O3 -lxml2 -lnetconf -lopenvswitch -lovsdb -lpthread -lcrypto -lssl -lrt -laio -avoid-version -module -shared -export-dynamic --mode=link -o ietf-interfaces.la .obj/ietf-interfaces.lo .obj/ovs_mediation.lo -rpath /usr/local/lib**
Error:
libtool: link: gcc -shared -fPIC -DPIC .obj/.libs/ietf-interfaces.o .obj/.libs/ovs_mediation.o -lxml2 -lnetconf -lopenvswitch -lovsdb -lpthread -lcrypto -lssl -lrt -laio -O3 -Wl,-soname -Wl,ietf-interfaces.so -o .libs/ietf-interfaces.so
/usr/bin/ld: /usr/local/lib/libopenvswitch.a(ovsdb-idl.o): relocation R_X86_64_TPOFF32 against `var.7533' can not be used when making a shared object; recompile with -fPIC
/usr/local/lib/libopenvswitch.a: could not read symbols: Bad value
collect2: error: ld returned 1 exit status
install.packages("ncdf")
* installing source package ‘ncdf’ ...
** package ‘ncdf’ successfully unpacked and MD5 sums checked checking for nc-config... /usr/local/bin/nc-config configure: creating
./config.status config.status: creating src/Makevars
** libs gcc -std=gnu99 -I/usr/share/R/include -DNDEBUG -I/usr/local/include -fpic -g -O2 -fstack-protector --param=ssp-buffer-size=4 -Wformat -Wformat-security -Werror=format-security -D_FORTIFY_SOURCE=2 -g -c ncdf.c -o ncdf.o gcc -std=gnu99 -I/usr/share/R/include -DNDEBUG -I/usr/local/include
-fpic -g -O2 -fstack-protector --param=ssp-buffer-size=4 -Wformat -Wformat-security -Werror=format-security -D_FORTIFY_SOURCE=2 -g -c ncdf2.c -o ncdf2.o gcc -std=gnu99 -I/usr/share/R/include -DNDEBUG
-I/usr/local/include -fpic -g -O2 -fstack-protector --param=ssp-buffer-size=4 -Wformat -Wformat-security -Werror=format-security -D_FORTIFY_SOURCE=2 -g -c ncdf3.c -o ncdf3.o gcc -std=gnu99 -shared -L/usr/lib/R/lib -Wl,-Bsymbolic-functions
-Wl,-z,relro -o ncdf.so ncdf.o ncdf2.o ncdf3.o -L/usr/local/lib -lnetcdf -L/usr/lib/R/lib -lR /usr/bin/ld: /usr/local/lib/libnetcdf.a(attr.o): relocation R_X86_64_32 against
`.rodata' can not be used when making a shared object; recompile with
-fPIC /usr/local/lib/libnetcdf.a: error adding symbols: Bad value collect2: error: ld returned 1 exit status make: *** [ncdf.so] Error 1
ERROR: compilation failed for package ‘ncdf’
* removing ‘/home/ayesha/R/x86_64-pc-linux-gnu-library/3.2/ncdf’
The downloaded source packages are in
'/tmp/RtmpSrzd8P/downloaded_packages'
I am trying to compile the code which is available online Non-Local Means Denoising
When I compile the source, the following errors appear that I suppose are mainly due to libpng:
g++ -L/opt/local/lib/ -L/usr/local/lib/ -L/usr/lib/x86_64-linux-gnu/ -fopenmp -lpng
-o nlmeans_ipol nlmeans_ipol.o io_png.o libauxiliar.o libdenoising.o mt19937ar.o
io_png.o: In function `io_png_write_raw':
io_png.c:(.text+0xe0): undefined reference to `png_create_write_struct'
io_png.c:(.text+0xf6): undefined reference to `png_create_info_struct'
io_png.c:(.text+0x12b): undefined reference to `png_init_io'
io_png.c:(.text+0x194): undefined reference to `png_set_IHDR'
io_png.c:(.text+0x1a6): undefined reference to `png_write_info'
io_png.c:(.text+0xb36): undefined reference to `png_write_image'
io_png.c:(.text+0xb48): undefined reference to `png_write_end'
io_png.c:(.text+0xb62): undefined reference to `png_destroy_write_struct'
io_png.c:(.text+0xbcc): undefined reference to `png_destroy_write_struct'
io_png.c:(.text+0xc1f): undefined reference to `png_destroy_read_struct'
io_png.c:(.text+0xe6a): undefined reference to `png_destroy_write_struct'
io_png.c:(.text+0xe80): undefined reference to `png_destroy_write_struct'
I have followed the following threads and placed the file "libpng.a" at many locations but it does not help.
I have seen a similar libpng problem here but does not help.
I am using ubuntu 12.04.
Could anyone please tell what could actually go wrong?
EDIT 1
The complete call is as follows
g++ -O3 -funroll-loops -fomit-frame-pointer -fno-tree-pre -falign-loops -ffast-math -ftree-vectorize -Wall -Wextra -Wno-write-strings -Wno-deprecated -ansi -fopenmp -c -o nlmeans_ipol.o nlmeans_ipol.cpp
cc -c -o io_png.o io_png.c -O3 -funroll-loops -fomit-frame-pointer -fno-tree-pre -falign-loops -ffast-math -ftree-vectorize -Wall -Wextra -Wno-write-strings -ansi -I/opt/local/include/ -I/usr/local/include/
g++ -c -o libauxiliar.o libauxiliar.cpp -O3 -funroll-loops -fomit-frame-pointer -fno-tree-pre -falign-loops -ffast-math -ftree-vectorize -Wall -Wextra -Wno-write-strings -Wno-deprecated -ansi -fopenmp -I/opt/local/include/ -I/usr/local/include/
g++ -c -o libdenoising.o libdenoising.cpp -O3 -funroll-loops -fomit-frame-pointer -fno-tree-pre -falign-loops -ffast-math -ftree-vectorize -Wall -Wextra -Wno-write-strings -Wno-deprecated -ansi -fopenmp -I/opt/local/include/ -I/usr/local/include/
cc -c -o mt19937ar.o mt19937ar.c -O3 -funroll-loops -fomit-frame-pointer -fno-tree-pre -falign-loops -ffast-math -ftree-vectorize -Wall -Wextra -Wno-write-strings -ansi -I/opt/local/include/ -I/usr/local/include/
g++ -lpng -lm -fopenmp -L/opt/local/lib/ -L/usr/local/lib/ -L/usr/lib/ -L/usr/lib/x86_64-linux-gnu/ -fopenmp -lpng -lpngwriter -lz -lfreetype -o nlmeans_ipol nlmeans_ipol.o io_png.o libauxiliar.o libdenoising.o mt19937ar.o
this is the complete call. Its a make file, The dump above in the copy of what appears at the command prompt.
Try just changing the sequence of parameters in your g++ call and have -lpng behind the object files. The linker evalueates the arguments in the sequence they are given so when it gets -lpng it has not yet knowledge of io_png.o and so it doesn't link the neccessary code from the library
Edit:
The last command of what your makefile executes is:
g++ -lpng -lm -fopenmp -L/opt/local/lib/ -L/usr/local/lib/ -L/usr/lib/ -L/usr/lib/x86_64-linux-gnu/ -fopenmp -lpng -lpngwriter -lz -lfreetype -o nlmeans_ipol nlmeans_ipol.o io_png.o libauxiliar.o libdenoising.o mt19937ar.o
If should be something like
g++ -L/opt/local/lib/ -L/usr/local/lib/ -L/usr/lib/ -L/usr/lib/x86_64-linux-gnu/ -o nlmeans_ipol nlmeans_ipol.o io_png.o libauxiliar.o libdenoising.o mt19937ar.o -lpng -lm -fopenmp -lpngwriter -lz -lfreetype
I don't know each of the libraries, maybe the sequence of the -l... parameters still isn't right