tags:

views:

108

answers:

2

Hi,

I was writing some codes in linux using c. When tried to compiled, I got this response:

/tmp/ccW8mQDx.o: In function `main':
server.c:(.text+0x3e): undefined reference to `__gmpz_set_str'
server.c:(.text+0x5a): undefined reference to `__gmpz_set_str'

In fact, all the functions of gmp that I used couldn't be found.

Seems there are some problem with the gmp.

Could anyone please tell me how to solve it? Thanks in advance!

+4  A: 

The undefined reference errors appear when you forgot to link your application with the library, GMP in this case. Read in the documentation of GMP the name of the library to link and use the -l compiler switch to link it.

Have you tried -lgmp ?

If that doesn't work you can look for the libgmp.a library:

cd /usr
find . -name libgmp.a -print
Eli Bendersky
if that doesn't work, also add `-L/path/to/directory/containing/libgimp.so` which adds to the Library search path
cobbal
-lgmp works, thanks a lot
A: 

Add -l option ,when you compile the code. It will add the library files.

pavun_cool