php-uv icon indicating copy to clipboard operation
php-uv copied to clipboard

undefined symbol: clock_gettime when running on ubuntu 12.04 64 bit

Open jimthunderbird opened this issue 11 years ago • 19 comments

I tried to compile php-uv with gcc 4.6.3 on ubuntu 12.04 64 bit box, it compiled successfully but when i run uv_default_loop() in the code, it says: undefined symbol: clock_gettime

Best Regards, Jim

jimthunderbird avatar Sep 17 '12 01:09 jimthunderbird

hmm, it's strange. I've tested php-uv on Ubuntu 11.04 64bit box but I didn't meet the error.

clock_gettime depends librt and I specified it in config.m4.

https://github.com/chobie/php-uv/blob/master/config.m4#L71

for now, can you re-create php-uv module?

phpize --clean
phpize
./configure
make

I'll make ubuntu 12.04 64bit box and test this.

chobie avatar Sep 17 '12 04:09 chobie

I tried the solution above, it does not work.

The symptom is, the uv.so is recognized correctly in php -m, but when i run a script with a uv_default_loop function call, it said: symbol lookup error, ... undefined symbol: clock_gettime

jimthunderbird avatar Sep 17 '12 05:09 jimthunderbird

I just verified ubuntu 11.04 64bit works fine, so at this point, i think the issue is realted to either a ubuntu version difference or gcc version difference.

jimthunderbird avatar Sep 17 '12 06:09 jimthunderbird

For ubuntu 12.04 64 bit now, I did a hack to make it work by using gcc 4.4.7.

Here is what I did:

apt-get install gcc-4.4 ln -s /usr/bin/gcc-4.4 /usr/bin/cc ln -s /usr/bin/gcc-4.4 /usr/bin/gcc

After this recompile everything and things start working, but ideally, it should work for the latest gcc

jimthunderbird avatar Sep 17 '12 07:09 jimthunderbird

I see. I'll modify config.m4 for latest gcc.

chobie avatar Sep 17 '12 07:09 chobie

Great!

jimthunderbird avatar Sep 17 '12 07:09 jimthunderbird

I spend some hours to fix this. But I couldn't fix at this moment. for now, please use gcc-4.4.7. I have to learn libtool and autoconf more deeply. so this may take a long time.

chobie avatar Sep 17 '12 12:09 chobie

Even with gcc-4.4.7 I'm still getting this. I'll give it another shot and see if I can get it to compile with the older gcc. It's likely I'm missing something. Or perhaps other parts of the build chain need to be downgraded as well? It's a clean install of Ubuntu 12.04.01 64bit.

lucian303 avatar Sep 17 '12 18:09 lucian303

I did not try 10.04 64 bit yet, Di you try ubuntu 11.04 64bit?

jimthunderbird avatar Sep 17 '12 18:09 jimthunderbird

Oops, sorry, I meant 12.04. I'll edit.

lucian303 avatar Sep 17 '12 18:09 lucian303

I recompiled php-uv by hand with the older gcc (4.4) on ubuntu 12.04.01 64bit and I can verify it works on there.

lucian303 avatar Sep 17 '12 19:09 lucian303

Hi folks, just thought I'd drop this note here after struggling with the same thing.

After trying, for a while, unsuccessfully to get librt to be linked properly in the makefile, I went ahead and executed:

export LD_PRELOAD=/lib/x86_64-linux-gnu/librt.so.1

Prior to starting up my instance (i.e. if you're using apache/nginx or php5-fpm) and it works fine. It's a hack, but it works.

chrsm avatar Jan 06 '13 06:01 chrsm

@chrsm thank you. i'll re-construct my ubuntu box and try to improve config.m4 later.

chobie avatar Jan 07 '13 21:01 chobie

using export LD_PRELOAD=/lib/x86_64-linux-gnu/librt.so.1, compilation is OK, but I got a segfault when using uv_run_once() (in phpuv.c at line 3370)

I'll post a backtrace soon

romainneutron avatar Mar 14 '13 14:03 romainneutron

I compiled latest php-uv with gcc 4.6.3 but can not reproduce this problem. I'd like to fix this but i don't have good idea...

chobie:~/src/php-uv$ uname -a
Linux  3.2.0-35-generic #55-Ubuntu SMP Wed Dec 5 17:42:16 UTC 2012 x86_64 x86_64 x86_64 GNU/Linux

chobie:~/src/php-uv$ cat /etc/issue
Ubuntu 12.04.1 LTS \n \l

chobie:~/src/php-uv$ gcc -v
Using built-in specs.
COLLECT_GCC=/usr/bin/gcc-4.6.real
COLLECT_LTO_WRAPPER=/usr/lib/gcc/x86_64-linux-gnu/4.6/lto-wrapper
Target: x86_64-linux-gnu
Configured with: ../src/configure -v --with-pkgversion='Ubuntu/Linaro 4.6.3-1ubuntu5' --with-bugurl=file:///usr/share/doc/gcc-4.6/README.Bugs --enable-languages=c,c++,fortran,objc,obj-c++ --prefix=/usr --program-suffix=-4.6 --enable-shared --enable-linker-build-id --with-system-zlib --libexecdir=/usr/lib --without-included-gettext --enable-threads=posix --with-gxx-include-dir=/usr/include/c++/4.6 --libdir=/usr/lib --enable-nls --with-sysroot=/ --enable-clocale=gnu --enable-libstdcxx-debug --enable-libstdcxx-time=yes --enable-gnu-unique-object --enable-plugin --enable-objc-gc --disable-werror --with-arch-32=i686 --with-tune=generic --enable-checking=release --build=x86_64-linux-gnu --host=x86_64-linux-gnu --target=x86_64-linux-gnu
Thread model: posix
gcc version 4.6.3 (Ubuntu/Linaro 4.6.3-1ubuntu5) 

chobie avatar Mar 18 '13 13:03 chobie

heu @chobie , I think it requires GCC 4.7, available on ubuntu 12.10

I'm not at my office, I can confirm that later

romainneutron avatar Mar 18 '13 14:03 romainneutron

Do you have -lrt on the last linking line? Pasting the compiler/linker output may help.

xming avatar Mar 19 '13 23:03 xming

When I run a make test before installing php-uv all the tests fail with:

PHP Warning: PHP Startup: Unable to load dynamic library '/home/dev/php-uv/modules/uv.so' - /home/dev/php-uv/modules/uv.so: undefined symbol: clock_gettime in Unknown on line 0

Here is my system info:

dev@reactor:~$ uname -a
Linux reactor 3.5.0-18-generic #29-Ubuntu SMP Fri Oct 19 10:26:51 UTC 2012 x86_64 x86_64 x86_64 GNU/Linux
dev@reactor:~$ cat /etc/issue
Ubuntu 12.10 \n \l

dev@reactor:~$ gcc -v
Using built-in specs.
COLLECT_GCC=gcc
COLLECT_LTO_WRAPPER=/usr/lib/gcc/x86_64-linux-gnu/4.7/lto-wrapper
Target: x86_64-linux-gnu
Configured with: ../src/configure -v --with-pkgversion='Ubuntu/Linaro 4.7.2-2ubuntu1' --with-bugurl=file:///usr/share/doc/gcc-4.7/README.Bugs --enable-languages=c,c++,go,fortran,objc,obj-c++ --prefix=/usr --program-suffix=-4.7 --enable-shared --enable-linker-build-id --with-system-zlib --libexecdir=/usr/lib --without-included-gettext --enable-threads=posix --with-gxx-include-dir=/usr/include/c++/4.7 --libdir=/usr/lib --enable-nls --with-sysroot=/ --enable-clocale=gnu --enable-libstdcxx-debug --enable-libstdcxx-time=yes --enable-gnu-unique-object --enable-plugin --enable-objc-gc --disable-werror --with-arch-32=i686 --with-tune=generic --enable-checking=release --build=x86_64-linux-gnu --host=x86_64-linux-gnu --target=x86_64-linux-gnu
Thread model: posix
gcc version 4.7.2 (Ubuntu/Linaro 4.7.2-2ubuntu1)

I will install an older version of gcc, as proposed above, in the mean time.

cboden avatar Mar 29 '13 19:03 cboden

Tested with gcc/cpp 4.4, 4.6, and 4.7. Everything works on 4.4 but I get the above error on 4.6 and 4.7. Let me know if there's any debug info I can send you to help!

cboden avatar Apr 13 '13 14:04 cboden