compiling pcre 3.38 as 64bit on Solaris 10 - wrong ELF class - 64-bit

I am trying to compile pcre 3.38 on Solaris 10 as a 64 bit binary. It starts to compile, and then at some point stops complaining about "wrong ELF class", and indeed, it turns out that some object files created are 32bit - allthough most are 64 bit as desired.
Here is what I have done:
./configure CFLAGS=-m64 LDFLAGS=-m64
Then
make
rm -f pcre_chartables.c
ln -s ./pcre_chartables.c.dist pcre_chartables.c
make all-am
make[1]: Entering directory `/local/src/pcre-8.38'
CC libpcre_la-pcre_byte_order.lo
CC libpcre_la-pcre_compile.lo
CC libpcre_la-pcre_config.lo
CC libpcre_la-pcre_dfa_exec.lo
CC libpcre_la-pcre_exec.lo
CC libpcre_la-pcre_fullinfo.lo
CC libpcre_la-pcre_get.lo
CC libpcre_la-pcre_globals.lo
CC libpcre_la-pcre_jit_compile.lo
CC libpcre_la-pcre_maketables.lo
CC libpcre_la-pcre_newline.lo
CC libpcre_la-pcre_ord2utf8.lo
CC libpcre_la-pcre_refcount.lo
CC libpcre_la-pcre_string_utils.lo
CC libpcre_la-pcre_study.lo
CC libpcre_la-pcre_tables.lo
CC libpcre_la-pcre_ucd.lo
CC libpcre_la-pcre_valid_utf8.lo
CC libpcre_la-pcre_version.lo
CC libpcre_la-pcre_xclass.lo
CC libpcre_la-pcre_chartables.lo
CCLD libpcre.la
CC libpcreposix_la-pcreposix.lo
CCLD libpcreposix.la
CXX libpcrecpp_la-pcrecpp.lo
CXX libpcrecpp_la-pcre_scanner.lo
CXX libpcrecpp_la-pcre_stringpiece.lo
CXXLD libpcrecpp.la
ld: fatal: file ./.libs/libpcre.so: wrong ELF class: ELFCLASS64
ld: fatal: file processing errors. No output written to .libs/libpcrecpp.so.0.0.1
collect2: ld returned 1 exit status
make[1]: *** [libpcrecpp.la] Error 1
make[1]: Leaving directory `/local/src/pcre-8.38'
make: *** [all] Error 2
Checking what was done so war, I see mostly 64 bit object files, but a few 32 bit ones, and I assume this is where the problem comes from:
file .libs/*
.libs/libpcre_la-pcre_byte_order.o: ELF 64-bit MSB relocatable SPARCV9 Version 1
.libs/libpcre_la-pcre_chartables.o: ELF 64-bit MSB relocatable SPARCV9 Version 1
.libs/libpcre_la-pcre_compile.o: ELF 64-bit MSB relocatable SPARCV9 Version 1
.libs/libpcre_la-pcre_config.o: ELF 64-bit MSB relocatable SPARCV9 Version 1
.libs/libpcre_la-pcre_dfa_exec.o: ELF 64-bit MSB relocatable SPARCV9 Version 1
.libs/libpcre_la-pcre_exec.o: ELF 64-bit MSB relocatable SPARCV9 Version 1
.libs/libpcre_la-pcre_fullinfo.o: ELF 64-bit MSB relocatable SPARCV9 Version 1
.libs/libpcre_la-pcre_get.o: ELF 64-bit MSB relocatable SPARCV9 Version 1
.libs/libpcre_la-pcre_globals.o: ELF 64-bit MSB relocatable SPARCV9 Version 1
.libs/libpcre_la-pcre_jit_compile.o: ELF 64-bit MSB relocatable SPARCV9 Version 1
.libs/libpcre_la-pcre_maketables.o: ELF 64-bit MSB relocatable SPARCV9 Version 1
.libs/libpcre_la-pcre_newline.o: ELF 64-bit MSB relocatable SPARCV9 Version 1
.libs/libpcre_la-pcre_ord2utf8.o: ELF 64-bit MSB relocatable SPARCV9 Version 1
.libs/libpcre_la-pcre_refcount.o: ELF 64-bit MSB relocatable SPARCV9 Version 1
.libs/libpcre_la-pcre_string_utils.o: ELF 64-bit MSB relocatable SPARCV9 Version 1
.libs/libpcre_la-pcre_study.o: ELF 64-bit MSB relocatable SPARCV9 Version 1
.libs/libpcre_la-pcre_tables.o: ELF 64-bit MSB relocatable SPARCV9 Version 1
.libs/libpcre_la-pcre_ucd.o: ELF 64-bit MSB relocatable SPARCV9 Version 1
.libs/libpcre_la-pcre_valid_utf8.o: ELF 64-bit MSB relocatable SPARCV9 Version 1
.libs/libpcre_la-pcre_version.o: ELF 64-bit MSB relocatable SPARCV9 Version 1
.libs/libpcre_la-pcre_xclass.o: ELF 64-bit MSB relocatable SPARCV9 Version 1
.libs/libpcre.a: current ar archive, 32-bit symbol table
.libs/libpcre.la: ascii text
.libs/libpcre.lai: ascii text
.libs/libpcre.so: ELF 64-bit MSB dynamic lib SPARCV9 Version 1, dynamically linked, not stripped, no debugging information available
.libs/libpcre.so.1: ELF 64-bit MSB dynamic lib SPARCV9 Version 1, dynamically linked, not stripped, no debugging information available
.libs/libpcre.so.1.2.6: ELF 64-bit MSB dynamic lib SPARCV9 Version 1, dynamically linked, not stripped, no debugging information available
.libs/libpcrecpp_la-pcre_scanner.o: ELF 32-bit MSB relocatable SPARC Version 1
.libs/libpcrecpp_la-pcre_stringpiece.o: ELF 32-bit MSB relocatable SPARC Version 1
.libs/libpcrecpp_la-pcrecpp.o: ELF 32-bit MSB relocatable SPARC Version 1
.libs/libpcreposix_la-pcreposix.o: ELF 64-bit MSB relocatable SPARCV9 Version 1
.libs/libpcreposix.a: current ar archive, 32-bit symbol table
.libs/libpcreposix.la: ascii text
.libs/libpcreposix.lai: ascii text
.libs/libpcreposix.so: ELF 64-bit MSB dynamic lib SPARCV9 Version 1, dynamically linked, not stripped, no debugging information available
.libs/libpcreposix.so.0: ELF 64-bit MSB dynamic lib SPARCV9 Version 1, dynamically linked, not stripped, no debugging information available
.libs/libpcreposix.so.0.0.3: ELF 64-bit MSB dynamic lib SPARCV9 Version 1, dynamically linked, not stripped, no debugging information available
Its unclear to my why 32 bit binaries are even built, CFLAGS=-m64 should take care of that.
Any idea how to debug this further?

After a good night's sleep I found the solution. All 32 bit files have cpp in their name, a hint that they have to do with c++ support. Also the output of make for the 32 bit object files indicates the use of the c++ compiler by prefixing the line with CXX.
So there are two ways to fix the problem. In case c++ support is needed, the fix is to instruct the c++ compiler to generate 64 binaries, by adding CXXFLAGS=-m64 to the configure line:
./configure CXXFLAGS=-m64 CFLAGS=-m64 LDFLAGS=-m64
The other option is to disable c++:
./configure --disable-cpp CFLAGS=-m64 LDFLAGS=-m64
In my case I am not sure yet what I want, but here are they ways to fix this problem.

Related

Error libc.so.6 version GLIBC_2.33 not found

I'm trying to execute a 32 bits binary, that is my scenario:
Host compiled: Kali (64 bits)
Host executed: Debian 7 (32 bits)
Host compiled is the machine where I'm compiled to 32 bits the .c
Host executed is the machine where I'm executing the 32 bits binary
I have the package gcc-multipart installed and compiled using this command: gcc -m32 binary.c -o program -pthread
File Result:
program: ELF 32 bits LSB pie executable, Intel 80386, version 1 (SYSV), dynamically linked, interpreter /lib/ld-linux.so.2
When a try to execute in Debian, this error ocurrs /lib/x86_64-linux-gnu/libc.so.6: version GLIBC_2.33' not found`
I'm looking for some solutions, try to re-install/upgrade the libc6, but did not work.

How to specify GNU / Linux version compiling dropbear

I have a compiled binary of Dropbear. When I do file dbclient I get the following :
dbclient: ELF 32-bit LSB executable, ARM, version 1 (SYSV),
dynamically linked (uses shared libs), stripped
When I am trying to compile it on my own (very beginner) with
./configure --host=arm-linux-gnueabi --prefix=/ --disable-zlib
CC=arm-linux-gnueabi-gcc LD=arm-linux-gnueabi-ld make make install
I get the following after it compiled
dbclient: ELF 32-bit LSB executable, ARM, version 1 (SYSV),
dynamically linked (uses shared libs), for GNU/Linux 2.6.31,
BuildID[sha1]=0x016ac7e729afb02d60248393619b41380379777d, not stripped
For the stripped part, I don't care I could strip it later.
But my question is how to specify the "for GNU/Linux 2.6.31". What does it mean and how do I change it to target Linux 3.10.49 armv5tejl?

How generate ARM object file on linux

I'm trying to generate ARM Object file under ubuntu using arm-none-eabi package but without success.
url describing this format:
http://infocenter.arm.com/help/index.jsp?topic=/com.arm.doc.dui0041c/BCEJDJBC.html
root#ubuntu:~/arm/blink# arm-none-eabi-as hello.S
root#ubuntu:~/arm/blink# file a.out
a.out: ELF 32-bit LSB relocatable, ARM, version 1 (SYSV), not stripped

android ndk prebuild shared library in 64 bit

I am working on link a pre-build shared library. I found my .so file is 64 bits and file information is shown below
li#cleanerSaddy:/usr/local/lib$ file libspd.so.3.0.0
libspd.so.3.0.0: ELF 64-bit LSB shared object, x86-64, version 1 (GNU/Linux), dynamically linked, BuildID[sha1]=0x1148c741ed5bf3568abd82ec33187b9cf9117cf5, not stripped
when I run ndk-build, it gave me "incomabpatible target". shown below
li#cleanerSaddy:~/Projects/spd-viewer-on-android$ ndk-build
[x86] Install : libspdio.so => libs/x86/libspdio.so
[x86] SharedLibrary : libhello-jni.so
/home/li/Android/adt-bundle-linux-x86_64-20131030/android-ndk-r9b/toolchains/x86-4.6/prebuilt/linux-x86_64/bin/../lib/gcc/i686-linux-android/4.6/../../../../i686-linux-android/bin/ld: error: ./obj/local/x86/libspdio.so: incompatible target
collect2: ld returned 1 exit status
make: *** [obj/local/x86/libhello-jni.so] Error 1
Here is my ABI APP_ABI := x86.
So, how do I solve this problem in order to compile that third party library successfully?
No Android system is 64 bit, your library should be compiled in 32 bits, preferably with Android NDK tool chain.

Link AMD acml in Linux

I need to link AMD acml library in a C++ project.
I tried to compile it in this way:
g++ mainConsole.cpp -L./acml/pgi64_int64/lib -lacml
but I get this error:
/usr/bin/ld: skipping incompatible ./acml/pgi64_int64/lib/libacml.so when searching for -lacml
/usr/bin/ld: skipping incompatible ./acml/pgi64_int64/lib/libacml.a when searching for -lacml
/usr/bin/ld: cannot find -lacml
What can I do in order to solve?
It seems the linker was told to use a 64 library when the compilation was done using 32 bits.
Your call to g++ will both compile and link. It's easier to debug if you split both. For example:
g++ -I./acml/pgi64_int64/include mainConsole.cpp -o mainConsole.o
g++ -L./acml/pgi64_int64/lib -lacml mainConsole.o -o mainConsole
You can verify the library using file. On my system I get:
$ file /usr/lib/acml/gfortran/libacml.so
/usr/lib/acml/gfortran/libacml.so: ELF 64-bit LSB shared object, x86-64, version 1 (SYSV), dynamically linked, stripped
The compiled object should be the same:
$ file mainConsole.o
mainConsole.o: ELF 64-bit LSB relocatable, x86-64, version 1 (SYSV), not stripped
The problem is either 32 bits compilation of your own project, or more probably your use of the "int64" verison of ACML. You can read more on int64 here. I suggest you try with the non-int64 version of ACML. For example, instead of downloading acml-5-3-1-pgi-64bit-int64.tgz, download acml-5-3-1-pgi-64bit.tgz.

Resources