We tried compiling a code - multiply1.c in the Linux environment
by giving the command gcc multiply1.c (we have renamed it) but its throwing
errors like :-
In function "main": undefined reference to '_gmpz_init_set_str'
We are getting 6 to 7 this type of errors.

Can you please let us know how to compile your code in Linux environment.

Recommended Answers

All 5 Replies

I assume you're including headers from the gnu multiple precision library?

If so you need to tell the linker the name of the library.. e.g.

gcc multiply1.c -lgmp

If that doesn't work.. make sure you have the library installed and in one of the "normal" library directories.. If it's not in one of the normal directories:

gcc multiply1.c -lgmp -L/directory/name/here

i tried the way you suggested but its not working.

Please post all of the "undefined reference" errors.

Did you get a different error when you tried with -lgmp?

You are using GMP, yes?

If so, did you compile GMP yourself, or use a packaged version?

Thank you Matt Evans the problem with your suggestion.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.