Log file of ld linker? - linker

I have compiled on Linux 64 bit, with success, a test application with fpc (free pascal compiler).
Sadly, when linking, it does not work.
ld begin to work but after 3 minutes there is a message from ld:
"ld encounter a error. Linking aborted".
How to know what is the problem, is it possible to debug the linking process or do it exist a log file of the operations done by the ld linker ?
Many thanks.
Fre;D

Yep, ld --verbose parameter did the trick.
Fre;D

Related

Using bzlib in C on macOS Catalina - "ld: symbol(s) not found for architecture x86_64", "clang: error: linker command failed with exit code 1"

I am attempting to compile a C program on macOS Catalina. The program will make use of bzip2 decompression. My code includes the line
#include <bzlib.h>
and I am trying to call the function BZ2_bzBuffToBuffDecompress. However, when I run gcc myfile.c -o myfile.c.o, I get the following error:
ld: symbol(s) not found for architecture x86_64
clang: error: linker command failed with exit code 1
I am just using a plain text editor and gcc, no IDEs and no CMake files. I suspect I may need a CMake file for this but I am not really sure how to proceed. Any assistance with this is greatly appreciated!
You need to link in the bzip library. gcc myfile.c -o myfile -lbz2. That command assumes the lib is installed into the standard location. Also, you are compiling a final executable so (by strong convention) it should not have a .o suffix.

Building libc (newlib) results in "cannot find -lc"

I built a cross-compiler for sh3eb-elf targets. Now I need a libc implementation. However, when I want to build newlib, configure fails.
Running configure:
../newlib-cygwin/configure --host=sh3eb-elf
It fails. A quick look into config.log:
configure:4435: sh3eb-elf-gcc conftest.c >&5
[...]/sh3eb-elf/sh3eb-elf/lib/gcc/sh3eb-elf/8.1.0/../../../../sh3eb-elf/bin/ld: cannot find -lc
collect2: error: ld returned 1 exit status
configure:4439: $? = 1
Obviously the linker does not find libc which is what I am trying to build here in the first place. I am confused... Are the parameters of configure wrong?
I'm not sure why, but as Chrono Kitsune pointed out, using --target=sh3eb-elf does the trick.

Issue with JACK on Raspian

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.

linker error: what could be going on?

I know not many people have telepathic powers here, but I will try to give as much info as I can so someone can help me debug what I think is a linker error in some program I'm trying to compile.
So, the program is cilkprof (see here, warning: tgz file). Within it is a Makefile for which I only changed the var CXX = icpc to CXX = g++. All else is equal.
/usr/bin/ld: ../../3rdparty/pintool/intel64/lib/libpin.a(util_host_ia32e.os):
relocation R_X86_64_PC32 against symbol `DoXsave' can not be used when making a shared object; recompile with -fPIC
/usr/bin/ld: final link failed: Bad value
collect2: error: ld returned 1 exit status
make: *** [linux64/cilkprof.so] Error 1
I know I should be understanding that libpin.a should be recompiled with -fPIC, but the pin version I have is already compiled. Any idea what I may be doing wrong? Please ask if something is not clear. Thanks.
It seems to me that the Makefile is trying to build a shared library and link it to a static non-PIC library, which is AFAIK, something you can't do. So if you can not recompile the libray with -fPIC then the only solution I see is to modify the Makefile and build a static library instead.

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