getting following error with the command g++ -o test -L . -l pq
libpq.so: file not recognized: File format not recognized
#file libpq.so
libpq.so: ELF 64-bit LSB shared object, x86-64, version 1 (SYSV), not stripped
gcc version 4.1.2 20070115 (SUSE Linux)
I am getting the same error if I try to use -l dbodbc
instead of -l pq
.
Note that test.c
is a simple hello world program.
Thanks in Advance.
file /usr/bin/g++
tells you that g++
itself is a 64-bit executable, i.e. it runs on a 64-bit machine, it doesn't tell you that g++ can compile 64-bit code (it's very unlikely but it could be a cross compiler for a completely different processor!) Use g++ -v
or g++ -dumpmachine
to find out what target it generates executables for.
G++ doesn't actually use that library, it just passes the -l
option to the linker, so the error is coming from the linker, ld
If ld
and objdump
are both saying they can't recognize the library but the same file is fine on a different machine, I would try updating or reinstalling the binutils
package, which provides both ld
and objdump
.
You might have a 32-bit binutils
installed, so its ld
and objdump
wouldn't understand the x86_64 library. Ensure you have the 64-bit (i.e. x86_64) binutils RPM installed.