Eclipse Community Forums - RDF feed
https://www.eclipse.org/forums/
Eclipse Community ForumsUndefined Reference to GMP
https://www.eclipse.org/forums/index.php/mv/msg/441538/990809/#msg_990809
I want to build a project with GMP library.
However, I get errors when building my project.
Errors:-
/cygdrive/d/workspace-cpp/gmp/Debug/../src/Test.c:11: undefined reference to `__imp____gmpz_init'
/cygdrive/d/workspace-cpp/gmp/Debug/../src/Test.c:12: undefined reference to `__imp____gmpz_init'
/cygdrive/d/workspace-cpp/gmp/Debug/../src/Test.c:13: undefined reference to `__imp____gmpz_init'
/cygdrive/d/workspace-cpp/gmp/Debug/../src/Test.c:15: undefined reference to `__imp____gmpz_set_str'
/cygdrive/d/workspace-cpp/gmp/Debug/../src/Test.c:16: undefined reference to `__imp____gmpz_set_str'
/cygdrive/d/workspace-cpp/gmp/Debug/../src/Test.c:18: undefined reference to `__imp____gmpz_mul'
/cygdrive/d/workspace-cpp/gmp/Debug/../src/Test.c:19: undefined reference to `__imp____gmp_printf'
/cygdrive/d/workspace-cpp/gmp/Debug/../src/Test.c:22: undefined reference to `__imp____gmpz_clear'
/cygdrive/d/workspace-cpp/gmp/Debug/../src/Test.c:23: undefined reference to `__imp____gmpz_clear'
/cygdrive/d/workspace-cpp/gmp/Debug/../src/Test.c:24: undefined reference to `__imp____gmpz_clear'
I'm using Cygwin to build my C project.
I am able to compile my class at Command Prompt with :-
gcc -o test test.c -lgmp
And it success to generate the result perfectly.
Any solution for me to solve it or any reference link I can investigate how to use GMP in Eclipse?
Is it maybe my own make.exe code incorrectly?
Thanks for replied first.]]>Leong Hui Yap2012-12-14T10:43:15-00:00Re: Undefined Reference to GMP
https://www.eclipse.org/forums/index.php/mv/msg/441538/990884/#msg_990884
> Hi all,
>
> I want to build a project with GMP library.
> However, I get errors when building my project.
>
> Errors:-
> /cygdrive/d/workspace-cpp/gmp/Debug/../src/Test.c:11: undefined
> reference to `__imp____gmpz_init'
> /cygdrive/d/workspace-cpp/gmp/Debug/../src/Test.c:12: undefined
> reference to `__imp____gmpz_init'
> /cygdrive/d/workspace-cpp/gmp/Debug/../src/Test.c:13: undefined
> reference to `__imp____gmpz_init'
> /cygdrive/d/workspace-cpp/gmp/Debug/../src/Test.c:15: undefined
> reference to `__imp____gmpz_set_str'
> /cygdrive/d/workspace-cpp/gmp/Debug/../src/Test.c:16: undefined
> reference to `__imp____gmpz_set_str'
> /cygdrive/d/workspace-cpp/gmp/Debug/../src/Test.c:18: undefined
> reference to `__imp____gmpz_mul'
> /cygdrive/d/workspace-cpp/gmp/Debug/../src/Test.c:19: undefined
> reference to `__imp____gmp_printf'
> /cygdrive/d/workspace-cpp/gmp/Debug/../src/Test.c:22: undefined
> reference to `__imp____gmpz_clear'
> /cygdrive/d/workspace-cpp/gmp/Debug/../src/Test.c:23: undefined
> reference to `__imp____gmpz_clear'
> /cygdrive/d/workspace-cpp/gmp/Debug/../src/Test.c:24: undefined
> reference to `__imp____gmpz_clear'
>
> I'm using Cygwin to build my C project.
> I am able to compile my class at Command Prompt with :-
> gcc -o test test.c -lgmp
> And it success to generate the result perfectly.
>
> Any solution for me to solve it or any reference link I can investigate
> how to use GMP in Eclipse?
>
> Is it maybe my own make.exe code incorrectly?
>
> Thanks for replied first.
You need to add the gmp library on the Paths and Symbols tab of your
project properties so that Eclipse can include the -lgmp to the command
line used to launch gcc.]]>David Wegener2012-12-14T16:12:09-00:00Re: Undefined Reference to GMP
https://www.eclipse.org/forums/index.php/mv/msg/441538/991031/#msg_991031
After I included the gmp lib into project.
Another errors was occurred.
Can you teach me how to solve this too?
**** Build of configuration Debug for project gmp ****
D:\workspace-cpp\gmp\make all
Building file: ../src/Test.c
Invoking: Cygwin C Compiler
gcc -I"D:\workspace-cpp\gmp\lib" -I"D:\workspace-cpp\gmp\src" -O0 -g3 -Wall -c -fmessage-length=0 -MMD -MP -MF"src/Test.d" -MT"src/Test.d" -o "src/Test.o" "../src/Test.c"
Finished building: ../src/Test.c
Building target: gmp.exe
Invoking: Cygwin C Linker
gcc -o "gmp.exe" ./src/Test.o -l"D:/workspace-cpp/gmp/lib/libgmp.a" -l"D:/workspace-cpp/gmp/lib/libgmp.la"
/usr/lib/gcc/i686-pc-cygwin/4.3.4/../../../../i686-pc-cygwin/bin/ld: cannot find -lD:/workspace-cpp/gmp/lib/libgmp.a
/usr/lib/gcc/i686-pc-cygwin/4.3.4/../../../../i686-pc-cygwin/bin/ld: cannot find -lD:/workspace-cpp/gmp/lib/libgmp.la
collect2: ld returned 1 exit status
make: *** [gmp.exe] Error 1
**** Build Finished ****
Thanks you.
]]>Leong Hui Yap2012-12-17T06:47:56-00:00Re: Undefined Reference to GMP
https://www.eclipse.org/forums/index.php/mv/msg/441538/991163/#msg_991163
> Thanks so much. After I included the gmp lib into project.
> Another errors was occurred.
>
> Can you teach me how to solve this too?
>
> **** Build of configuration Debug for project gmp ****
>
> D:\workspace-cpp\gmp\make all Building file: ../src/Test.c
> Invoking: Cygwin C Compiler
> gcc -I"D:\workspace-cpp\gmp\lib" -I"D:\workspace-cpp\gmp\src" -O0 -g3
> -Wall -c -fmessage-length=0 -MMD -MP -MF"src/Test.d" -MT"src/Test.d" -o
> "src/Test.o" "../src/Test.c"
> Finished building: ../src/Test.c
>
> Building target: gmp.exe
> Invoking: Cygwin C Linker
> gcc -o "gmp.exe" ./src/Test.o -l"D:/workspace-cpp/gmp/lib/libgmp.a"
> -l"D:/workspace-cpp/gmp/lib/libgmp.la"
> /usr/lib/gcc/i686-pc-cygwin/4.3.4/../../../../i686-pc-cygwin/bin/ld:
> cannot find -lD:/workspace-cpp/gmp/lib/libgmp.a
> /usr/lib/gcc/i686-pc-cygwin/4.3.4/../../../../i686-pc-cygwin/bin/ld:
> cannot find -lD:/workspace-cpp/gmp/lib/libgmp.la
> collect2: ld returned 1 exit status
> make: *** [gmp.exe] Error 1
>
> **** Build Finished ****
>
> Thanks you.
>
You don't define the library with the full path. You just need to add
gmp as the library name. The linker should then find the correct
library file.]]>David Wegener2012-12-17T15:18:41-00:00Re: Undefined Reference to GMP
https://www.eclipse.org/forums/index.php/mv/msg/441538/991709/#msg_991709
Thanks David very much ]]>Leong Hui Yap2012-12-20T02:52:15-00:00