Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Language IDEs » C / C++ IDE (CDT) » Undefined Reference to GMP(Building failed with GMP library in C project.)
Undefined Reference to GMP [message #990809] Fri, 14 December 2012 10:43 Go to next message
Leong Hui Yap is currently offline Leong Hui YapFriend
Messages: 3
Registered: December 2012
Junior Member
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.
Re: Undefined Reference to GMP [message #990884 is a reply to message #990809] Fri, 14 December 2012 16:12 Go to previous messageGo to next message
David Wegener is currently offline David WegenerFriend
Messages: 1348
Registered: July 2009
Senior Member
On 12/14/2012 07:56 AM, Leong Hui Yap wrote:
> 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.
Re: Undefined Reference to GMP [message #991031 is a reply to message #990884] Mon, 17 December 2012 06:47 Go to previous messageGo to next message
Leong Hui Yap is currently offline Leong Hui YapFriend
Messages: 3
Registered: December 2012
Junior Member
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.
Re: Undefined Reference to GMP [message #991163 is a reply to message #991031] Mon, 17 December 2012 15:18 Go to previous messageGo to next message
David Wegener is currently offline David WegenerFriend
Messages: 1348
Registered: July 2009
Senior Member
On 12/17/2012 12:47 AM, Leong Hui Yap wrote:
> 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.
Re: Undefined Reference to GMP [message #991709 is a reply to message #991163] Thu, 20 December 2012 02:52 Go to previous message
Leong Hui Yap is currently offline Leong Hui YapFriend
Messages: 3
Registered: December 2012
Junior Member
Yes, it worked like a charm.

Thanks David very much Laughing
Previous Topic:Eclipse debugger stops at dl_main
Next Topic:Error message from debugger back end
Goto Forum:
  


Current Time: Sun Nov 23 13:42:30 GMT 2014

Powered by FUDForum. Page generated in 0.11933 seconds
.:: Contact :: Home ::.

Powered by: FUDforum 3.0.2.
Copyright ©2001-2010 FUDforum Bulletin Board Software