Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

undefined symbol: clock_gettime when running on ubuntu 12.04 64 bit #24

Open
jimthunderbird opened this issue Sep 17, 2012 · 19 comments
Open
Labels

Comments

@jimthunderbird
Copy link

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

@chobie
Copy link
Owner

chobie commented Sep 17, 2012

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.

@jimthunderbird
Copy link
Author

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
Copy link
Author

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
Copy link
Author

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

@chobie
Copy link
Owner

chobie commented Sep 17, 2012

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

@jimthunderbird
Copy link
Author

Great!

@chobie
Copy link
Owner

chobie commented Sep 17, 2012

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.

@lucian303
Copy link

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.

@jimthunderbird
Copy link
Author

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

@lucian303
Copy link

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

@lucian303
Copy link

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.

@chrsm
Copy link

chrsm commented Jan 6, 2013

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.

@chobie
Copy link
Owner

chobie commented Jan 7, 2013

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

@romainneutron
Copy link

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

@chobie
Copy link
Owner

chobie commented Mar 18, 2013

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) 

@romainneutron
Copy link

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

@xming
Copy link

xming commented Mar 19, 2013

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

@cboden
Copy link

cboden commented Mar 29, 2013

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
Copy link

cboden commented Apr 13, 2013

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!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

7 participants