Compile PHP extension on 64bit debian installation to 32bit PHP
I am trying to compile a PHP extension for a 32 bit PHP installation on a 64 bit system. However, when restarting apache, the following warning appears:
Warning: PHP Startup: Unable to load dynamic library '/opt/lampp/lib/php/extensions/no-debug-non-zts-20090626/spotify.so' - /opt/lampp/lib/php/extensions/no-debug-non-zts-20090626/spotify.so: wrong ELF class: ELFCLASS64 in Unknown on line 0
I will compile everything using this command:
/opt/lampp/bin/phpize; CFLAGS=-m32 CPPFLAGS=-m32 CCASFLAGS=-m32 ./configure --enable-spotify --with-php-config=/opt/lampp/bin/php-config; make && make install
The flags need to make sure they compile to 32 bits. I have installed gcc-multilib
andg++-multilib
When compilation is done (this log: http://pastebin.com/MqgGgyzv ) I execute the following command:
file /opt/lampp/lib/php/extensions/no-debug-non-zts-20090626/spotify.so
and it returns
/opt/lampp/lib/php/extensions/no-debug-non-zts-20090626/spotify.so: ELF 64-bit LSB shared object, x86-64, version 1 (SYSV), dynamically linked, not stripped
So it clearly doesn't compile it correctly, but I can't see what I am doing wrong.
source to share
You compile OK, but the linker inadvertently creates a 64-bit .so.
The solution is to include "-m32" in your LDFLAGS as well:
https://askubuntu.com/questions/85978/building-a-32-bit-app-in-64-bit-ubuntu
source to share