Statically linking GMP

Steven Beeckman steven.beeckman at gmail.com
Fri Mar 30 00:31:15 CEST 2007


Hello,

I have made an application in C++ using GMP, but I need it to be
linked/compiled statically (needs to be run in a simulator called
SimIt-ARM). I'm doing the cross-compilation to ARM in scratchbox (
http://www.scratchbox.org). GMP has been compiled and installed in
Scratchbox.

The command
         g++ -lgmp -static -O3 -o rsa_keygen rsa_keygen.cpp
gives errors about undefined references to __gmpz_init, __gmpz_clear, ...

[sbox-MYTARGET: ~/rsa] > g++ -lgmp -static -O3 -o rsa_keygen rsa_keygen.cpp
/tmp/cckdV8OI.o: In function `initializeGMP()':
rsa_keygen.cpp:(.text+0x8): undefined reference to `__gmpz_init'
rsa_keygen.cpp:(.text+0x10): undefined reference to `__gmpz_init'
rsa_keygen.cpp:(.text+0x18): undefined reference to `__gmpz_init'
rsa_keygen.cpp:(.text+0x20): undefined reference to `__gmpz_init'
rsa_keygen.cpp:(.text+0x2c): undefined reference to `__gmpz_init'
/tmp/cckdV8OI.o: In function `clearGMP()':
rsa_keygen.cpp:(.text+0x4c): undefined reference to `__gmpz_clear'
rsa_keygen.cpp:(.text+0x54): undefined reference to `__gmpz_clear'
rsa_keygen.cpp:(.text+0x5c): undefined reference to `__gmpz_clear'
rsa_keygen.cpp:(.text+0x64): undefined reference to `__gmpz_clear'
rsa_keygen.cpp:(.text+0x70): undefined reference to `__gmpz_clear'
/tmp/cckdV8OI.o: In function `checkKeys()':
rsa_keygen.cpp:(.text+0x148): undefined reference to `__gmpz_set_str'
rsa_keygen.cpp:(.text+0x158): undefined reference to `__gmpz_set_str'
rsa_keygen.cpp:(.text+0x168): undefined reference to `__gmpz_set_str'
/tmp/cckdV8OI.o: In function `generateKeys()':
rsa_keygen.cpp:(.text+0x24c): undefined reference to `__gmpz_init'
rsa_keygen.cpp:(.text+0x254): undefined reference to `__gmpz_init'
rsa_keygen.cpp:(.text+0x2e8): undefined reference to `__gmpz_set_str'
rsa_keygen.cpp:(.text+0x2f8): undefined reference to `__gmpz_set_str'
rsa_keygen.cpp:(.text+0x304): undefined reference to `__gmpz_nextprime'
rsa_keygen.cpp:(.text+0x310): undefined reference to `__gmpz_nextprime'
rsa_keygen.cpp:(.text+0x324): undefined reference to `__gmpz_get_str'
rsa_keygen.cpp:(.text+0x338): undefined reference to `__gmpz_get_str'
rsa_keygen.cpp:(.text+0x348): undefined reference to `__gmpz_init'
rsa_keygen.cpp:(.text+0x364): undefined reference to `__gmpz_mul'
rsa_keygen.cpp:(.text+0x374): undefined reference to `__gmpz_get_str'
rsa_keygen.cpp:(.text+0x380): undefined reference to `__gmpz_init'
rsa_keygen.cpp:(.text+0x388): undefined reference to `__gmpz_init'
rsa_keygen.cpp:(.text+0x39c): undefined reference to `__gmpz_sub_ui'
rsa_keygen.cpp:(.text+0x3ac): undefined reference to `__gmpz_sub_ui'
rsa_keygen.cpp:(.text+0x3c8): undefined reference to `__gmpz_mul'
rsa_keygen.cpp:(.text+0x3d0): undefined reference to `__gmpz_init'
rsa_keygen.cpp:(.text+0x3f0): undefined reference to `__gmpz_gcd_ui'
rsa_keygen.cpp:(.text+0x3fc): undefined reference to `__gmpz_cmp_ui'
rsa_keygen.cpp:(.text+0x410): undefined reference to `__gmpz_set_ui'
rsa_keygen.cpp:(.text+0x420): undefined reference to `__gmpz_invert'
rsa_keygen.cpp:(.text+0x44c): undefined reference to `__gmpz_get_str'
rsa_keygen.cpp:(.text+0x4e4): undefined reference to `__gmpz_clear'
rsa_keygen.cpp:(.text+0x4ec): undefined reference to `__gmpz_clear'
rsa_keygen.cpp:(.text+0x4f4): undefined reference to `__gmpz_clear'
rsa_keygen.cpp:(.text+0x500): undefined reference to `__gmpz_clear'
rsa_keygen.cpp:(.text+0x508): undefined reference to `__gmpz_clear'
/tmp/cckdV8OI.o:rsa_keygen.cpp:(.text+0x510): more undefined references to
`__gmpz_clear' follow
/tmp/cckdV8OI.o: In function `main':
rsa_keygen.cpp:(.text+0x594): undefined reference to `__gmpz_init'
rsa_keygen.cpp:(.text+0x59c): undefined reference to `__gmpz_init'
rsa_keygen.cpp:(.text+0x5a4): undefined reference to `__gmpz_init'
rsa_keygen.cpp:(.text+0x5ac): undefined reference to `__gmpz_init'
rsa_keygen.cpp:(.text+0x5b4): undefined reference to `__gmpz_init'
rsa_keygen.cpp:(.text+0x5c8): undefined reference to `__gmpz_clear'
rsa_keygen.cpp:(.text+0x5d0): undefined reference to `__gmpz_clear'
rsa_keygen.cpp:(.text+0x5d8): undefined reference to `__gmpz_clear'
rsa_keygen.cpp:(.text+0x5e0): undefined reference to `__gmpz_clear'
rsa_keygen.cpp:(.text+0x5e8): undefined reference to `__gmpz_clear'
collect2: ld returned 1 exit status

What is the correct command to get my binary statically linked?

Thanks,

Steven
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://gmplib.org/list-archives/gmp-discuss/attachments/20070330/3fefffa5/attachment.html 


More information about the gmp-discuss mailing list