herumi / mcl

a portable and fast pairing-based cryptography library
BSD 3-Clause "New" or "Revised" License
450 stars 152 forks source link

Symbol lookup error #80

Closed matilote closed 3 years ago

matilote commented 4 years ago

When trying to use shared library libmclbn256.so & libmclbn384_256 I got the symbol lookup error. Do I miss something during the build?

The active test run was aborted. Reason: Test host process crashed : /usr/share/dotnet/dotnet: symbol lookup error: /root/libmclbn384_256.so: undefined symbol: _ZN3mcl2fp2Op4initERK10__gmp_exprIA1_12__mpz_structS4_EmiNS0_4ModeEm

Build

git clone git://github.com/herumi/mcl
cd mcl
make -j4

ldd libmclbn256.so output: image

When building with cmake the library appears to work only on my local machine.

herumi commented 4 years ago

It seems the function of GMP. So could you install libgmp or build a library without gmp.

https://github.com/herumi/mcl#how-to-build-without-gmp

matilote commented 4 years ago

No luck without GMP:

The active test run was aborted. Reason: Test host process crashed : /usr/share/dotnet/dotnet: symbol lookup error: libmclbn384_256.so: undefined symbol: _ZN3mcl2fp2Op4initERKNS_5VintTINS_4vint6BufferImEEEEmiNS0_4ModeEm

It now complains about Vint. I wonder why does the cmaked shared lib work locally. When exported to some VM it crashes if mcl is not installed.

herumi commented 4 years ago

What OS and compiler do you use? On Ubuntu 18.04.4 + gcc 7.5.0

make clean
make lib/libmclbn384_256.so MCL_USE_GMP=0
g++ sample/pairing_c.c -L lib -I ./include/ lib/libmclbn384_256.so lib/libmcl.so
% ldd ./a.out
        linux-vdso.so.1 (0x00007ffcafbf5000)
        lib/libmclbn384_256.so (0x00007f0014c26000)
        lib/libmcl.so (0x00007f0014982000)
        libc.so.6 => /lib/x86_64-linux-gnu/libc.so.6 (0x00007f0014591000)
        libstdc++.so.6 => /usr/lib/x86_64-linux-gnu/libstdc++.so.6 (0x00007f0014208000)
        libgcc_s.so.1 => /lib/x86_64-linux-gnu/libgcc_s.so.1 (0x00007f0013ff0000)
        /lib64/ld-linux-x86-64.so.2 (0x00007f0015078000)
        libm.so.6 => /lib/x86_64-linux-gnu/libm.so.6 (0x00007f0013c52000)
./a.out
matilote commented 4 years ago

Btw. dll built on Windows machine works without any issues.

NAME="Ubuntu"
VERSION="18.04.4 LTS (Bionic Beaver)"
gcc (Ubuntu 7.5.0-3ubuntu1~18.04) 7.5.0
[mateusz@mateusz-TM1701 mcl]$ ldd ./a.out
        linux-vdso.so.1 (0x00007fff8c9eb000)
        lib/libmclbn384_256.so (0x00007f16e3e55000)
        lib/libmcl.so (0x00007f16e3bb1000)
        libc.so.6 => /lib/x86_64-linux-gnu/libc.so.6 (0x00007f16e37c0000)
        libstdc++.so.6 => /usr/lib/x86_64-linux-gnu/libstdc++.so.6 (0x00007f16e3437000)
        libgcc_s.so.1 => /lib/x86_64-linux-gnu/libgcc_s.so.1 (0x00007f16e321f000)
        /lib64/ld-linux-x86-64.so.2 (0x00007f16e42a7000)
        libm.so.6 => /lib/x86_64-linux-gnu/libm.so.6 (0x00007f16e2e81000)
[mateusz@mateusz-TM1701 mcl]$ ./a.out
123 x 456 = 56088
P = 1 d53dc985d379bac6142cbc8bbcf2d1017562af2c6b79a17f3780ade2bf85ae69d396ccb6f2adeac190fd44886befbbe 2bc3e19b5fed19facd08a60343f681164e62999471e11ef8634a577bdb368fcf7543e42e3a06e73cff46f46893b0d7a
Q = 1 c79f9de6659a5c2fc8a8ba34865875e120f29d8ac48c121cdfbe6210335c87072f2193e910e8f13bfcc4c6a0b376c47 142f4fff022124cae0d8be74eefd257aefc839a34027a52644ee2ade976acf687d6d42da7e99494ed77f943529eb3975 c8f41fcea61ea0cf0f125304ae840f7f0f2cf4a88cce60e2f8ff76ab0fdc7f0a4c510261455977199850cfd3b7219be 15870a8d311018c45f779958e1cf10ff8325411df4ba4d178152213b4ae63d2806dae81549a37061931481693cb16d24
e = 10f303ffa3a97bae498b73b256713e6ce70a51fabbace4a7ae9425c4990f628a2171a63c043064ad889946216b40b590 5797241e8fb340b552b639674672c7ea6def3c2124f3e3ce9784588205ea8c00b14f892d8cdd37c8ba7b7f5aaa9cc78 135b5b53c0a9724eda35ee02bec3d62e62479c5816da22f7030da8f56a797c9af655dc18e6f9ebdde28514f470978c9 e63608b29ae23116f8855ea43f4c3e5c811625d44d8699f38c15da9fa5d23696885b8022a35017096372429c3f7332e f1bae130654f428d5e0511afdd198ae6864500ce4292e57ffa859fa6673567da4b7b0596386001ebcf590a36c6bc747 7f877ad5107b4ab5dad9881c6af7089c3c360b74f31f99bf0cf073bc7acde7405de39f4d3218929f89ec961cb3e875b f1f9a5a42b8e7da9bcca864cf20d05dc3fbc588cc93d808b16e493f77f54c5ed46bbc878d64c4736c3d65d9c7d0b9 115a915e55f290d9160d4c4131fc0ab2e97a479fe58db1874a32ca0586f156b26861cc6bde0d34010b7feb0a4ac2e2a3 d0e8d5b7e1f678089b2a46388479c1c45ac61b09b300308352eb644529918859a948d5cb6e59a35b8ee6e5d2a24df60 b2203b90025d3698b37138c9acd722c7581d3cdd76333b760895a20b8659a3c12408f76c7801a5d9e645397606bd248 10720eab4947203ce683d8313f33bdb271eead30d2fc5307c0b304a340f6df48121d4dd48a2ae88b5439ad7538e5b653 19a23f338577a6264a0ccb28beb4d93ad573eaf94285efcf99111bb74edf41197d6e0f7ad00978905fb832534d0aea28
no err