Simple C++ Compile Error

Marc Glisse marc.glisse at normalesup.org
Tue Aug 12 02:43:26 CEST 2008


On Mon, 11 Aug 2008, Robert Evans wrote:

> In my first "hello world" type program, the one identical to that on page
> 75, g++ produces the following error:
> 
> bevans at revanslinux /home/bevans/gmp-4.2.3/bob> g++ Test1.cc -lgmpxx -lgmp
> /home/bevans/gmp-4.2.3/include/gmpxx.h: In destructor
> ?__gmp_alloc_cstring::~__gmp_alloc_cstring()?:
> /home/bevans/gmp-4.2.3/include/gmpxx.h:1367: error: ?mp_get_memory_functions?
> was not declared in this scope
> 
> I see the declaration of mp_get_memory_functions in gmp.xx, so am not
> sure what is wrong.
> 
> Source:
> #include </home/bevans/gmp-4.2.3/include/gmpxx.h>

This is not the right way to specify the location of the header file. You 
should have: #include <gmpxx.h>
and then on the command line, you add -I/home/.../include

gmpxx.h includes gmp.h. With what you have shown, the compiler should not 
be able to find gmp.h in /home/.../include. The fact that it does not 
complain means it has found a gmp.h file somewhere, likely some old 
version in /usr/include.

If that does not help, you'll need to add -E to the command line and look 
at the relevant parts of what it outputs.

-- 
Marc Glisse


More information about the gmp-bugs mailing list