I have written my own .c and am trying to link it to the necessary files in rabbitmq-c, but am unable to do so.
I have rabbitmq-c and its examples running properly.
I am using a centos 7 machine.
I have tried the advice of the answer on the post Build against rabbitmq-c
However,
When issuing the last step from that page
gcc -Llibrabbitmq/.libs -g -Wall -o test test.o -lrabbitmq
I get the error
"collect2: error: ld returned 1 exit status" and then a list of undefined references. The undefined references all begin with "die" if it has to do with me missing something specific.
Help would be greatly appreciated
Related
I'm a beginner of programming. I am using Eclipse CDT for C programming. When I build any program, the console window shows the below message. Please tell me a specific way so that I could solve this problem.
Console window:
Info: Configuration "Debug" uses tool-chain "MinGW GCC" that is unsupported on this system, attempting to build anyway.
Info: Internal Builder is used for build
gcc -O0 -g3 -Wall -c -fmessage-length=0 -o test.o "..\\test.c"
gcc -o test.exe test.o
c:/mingw/bin/../lib/gcc/i686-pc-mingw32/4.9.2/../../../../i686-pc-mingw32/bin/ld.exe: cannot open output file test.exe: Permission denied
collect2.exe: error: ld returned 1 exit status
00:33:35 Build Finished (took 2s.385ms)
USUALLY(in my experience), LD errors result from you not including the libraries or linkers necessary. Go to your project, right click, select properties, under C build go to settings, GCC C compiler and includes and add the libraries.
Your operating system simply does not allow to modify a file while it is in use, so the compilation fails, because compiler can't remove the old executable and place a new one. To solve this, simply restart eclipse program.
I was searching for a way to create mocking objects with c-code until I stumbled upon cmockery.
For me it seems to be the best mocking software available since it doesn't have a lot of dependencies.
I'm working in ubuntu and downloaded the tarball cmockery from https://code.google.com/p/cmockery/downloads/list
I ran the ./configure, make and make install.
I am able to execute the given examples but I just can't figure out how to get it working on my own projects. I had a look at the configure and makefile to try and find out how they did it, but that was no success. I think it's the linking that's causing my problems.
Files of cmockery can be find at:
/usr/local/include/google/cmockery.h
/usr/local/lib/libcmockery.la
/usr/local/lib/libcmockery.a
/usr/local/lib/libcmockery.so.0.0.0
/usr/local/lib/libcmockery.so.0
/usr/local/lib/libcmockery.so
I tried copying the example files calculator.c and calculater_test.c to a separate directory and compile them there.
This is what I did:
gcc -c -o calculator.o calculator.c
gcc -c -o calculator_test.o calculator_test.c -I /usr/local/include/google/
gcc -o run *.o -L /usr/local/lib/
At the last step I got a lot of undefined references to all functions specific to cmockery and the error:
collect2: error: ld returned 1 exit status
I guess I'm messing things up with the linker but I can't find anywhere how it should be done correctly.
You are missing -lcmockery:
gcc -o run *.o -L /usr/local/lib/ -lcmockery
I tried to compile tcc for ARM using gcc 4.6.3 . but I got following error while compiling in both shared/static lib mod :
root#localhost:/p/tcc/tcc# make
gcc -o tcc tcc.o libtcc.so.1.0 -lm -ldl -Wall -g -O2 -fno-strict-aliasing -Wno-pointer-sign -Wno-sign-compare -D_FORTIFY_SOURCE=0 -Wl,-rpath,"/usr/local/lib" libtcc.so.1.0: undefined reference to `vrotb'
collect2: ld returned 1 exit status
make: *** [tcc] Error 1
I am using lastest branch from tcc github
Just checked it on raspberry pi (ARMv6 CPU). https://github.com/TinyCC/TinyCC repository, removed static qualifier from vrotb function in tccgen.c (line 945). It builds and passes 'hello world'.
Since that's obvious mistake likely to be introduced by some change that they forgot to adapt for ARM - i suggest performing further tests to ensure it works as intended. Bug report should be filed - probably on github.
I know it is little confusing, but your problem is that you are using wrong repository. Fabrice Bellard does not work any more on TinyCC (see http://bellard.org/tcc/). He keeps his repositories for personal/historical reasons. However all development has moved to http://repo.or.cz/w/tinycc.git. To confuse things even more the 0.9.26 release from Fabrice's web site is actually from the http://repo.or.cz/w/tinycc.git repository, and not Fabrice's own. But this is all just communication issue. In short you should use new repository. On the repository web site is a link to a mailing list where you should report any problems in case the new repo code does not compile.
I am trying to install pngnq, which relies on libpng >= 1.2.8. I have installed libpng 1.5.7 via ./configure, make, sudo make install (without problems), because the libpng version in the Software Center was too old. I am now trying to install pngnq via ./configure, make, sudo make install (again, because Software Center version is too old), but am getting stuck at the make step on error messages which I believe pertain to libpng linking. A small sample of the error messages:
undefined reference to `png_destroy_write_struct'
undefined reference to `png_convert_from_time_t'
undefined reference to `png_set_PLTE'
I have limited experience with installing software manually on Linux, and so am not really sure what the next step is in diagnosing the problem. I've done substantial searching, but haven't really found anything targeted at the issue I'm having. Based on a forum post on a similar-ish issue I've done an ls on /usr/local/lib directory and found:
libpng15.a libpng15.so.15 libpng.la libpng15.la
libpng15.so.15.7.0 libpng.so libpng15.so libpng.a
though I don't know if that's actually any use in diagnosing/ruling out certain problems. Can anyone advise what might be wrong, keeping in my my minimal experience with compiling code on Linux?
Edit:
As requested, here is a sample of the trace beginning at the make call:
bryce#whatever:~/Downloads/pngnq-1.1$ make
Making all in src
make[1]: Entering directory `/home/bryce/Downloads/pngnq-1.1/src'
make all-am
make[2]: Entering directory `/home/bryce/Downloads/pngnq-1.1/src'
gcc `libpng-config --I_opts` -Wall --pedantic -std=gnu99 -g -O2 `libpng-config
--ldflags` -lz -o pngnq pngnq.o neuquant32.o rwpng.o -lm -lz
pngnq.o: In function `pngnq':
/home/bryce/Downloads/pngnq-1.1/src/pngnq.c:518: undefined reference to `png_get_gAMA'
Sounds like includes don't match the library. Double check to see if you've got png.h in /usr/include or libpng* in /usr/lib/.
Also show the gcc line that shows up before you see the error. That might point to the issue.
I'm trying to compile SNNS (Stuttgart Neural Network Simulator) is a software simulator for neural networks on Unix, but I got the following error message:
Ignore possible error messages for the following command:
ranlib libfunc.a
END OF COMMANDS THAT MAY FAIL
make[3]: Leaving directory `/home/fer/Desktop/SNNSv4.3/kernel/sources'
end of (re)making kernel libraries
gcc snns2c.o snns2clib.o ../../kernel/sources/libkernel.a ../../kernel/sources/libfunc.a -lm -ll -o snns2c
/usr/bin/ld: cannot find -ll
collect2: ld returned 1 exit status
But I don't know what I need to install, do you have an idea about this problem?
I think -ll is referring to the lex library libl, as per this message. You may need to modify that make file to link against flex.
I solved this problem after installing flex from the distro's official repository.