gmpxx.h: no such file or directory
Asked Answered
N

4

6

I just installed a brand new copy of mingw (32 bit) downloading it from the official project page from Sourceforge. I installed everything in the package, all compilers and so on. Then I downloaded from here gmp for MinGW. I extracted gmp-5.0.1-1-mingw32-src.tar.lzma somewhere into my mingw folder, then ran ./pkgbuild from there. It went on running for some minutes, then printed out something like COMPLETED EVERYTHING OK, EVERYTHING PASS.

Then I wrote down this simple example, to check if it was going to work:

#include <gmpxx.h>

int main (void)
{
  mpz_class a, b, c;

  a = 1234;
  b = "-5678";
  c = a+b;
  cout << "sum is " << c << "\n";
  cout << "absolute value is " << abs(c) << "\n";

  return 0;
}

And then compiled it using g++ mycxxprog.cc -lgmpxx -lgmp. The only answer I get is:

Fatal error: gmpxx.h: No such file or directory.

Does anybody have any hint? I don't really know what should I do...

Nonexistence answered 30/8, 2011 at 23:53 Comment(0)
G
3

You need to make sure the is among the directories searched for headers. Find the place where the gmpxx.h header resides and add -I /path/to/header/ on your g++ line.

Graehme answered 31/8, 2011 at 4:19 Comment(3)
I am facing the same problem here and I don't find the file: I run sudo find / -iname gmpxx.h and it returns nothing. :sStearne
@VitorLima: Are you sure that you have the necessary packages installed?Graehme
I came back to the gmp's site and I found out that I have to pass the flag --enable-cxx to the configure script. So, I recompiled the gmp lib and ran ldconfig. Now, it works fine, I don't need even to use the -I option to compile my programs. (:Stearne
S
18

gmpxx.h header file is included in the libgmp-dev package

You can install it on Ubuntu based machines with this command:

$ sudo apt-get install libgmp-dev
Symphonious answered 16/4, 2015 at 18:41 Comment(2)
The problem is on MinGW, so it's quite useless to tell here what to do on Ubuntu machines...Josi
So where is it located after running that?Bluefish
A
7

If you are building gmp from source, you need to add the --enable-cxx flag to the configure command.

Authoritative answered 8/7, 2018 at 12:16 Comment(0)
F
4

You can also copy that to the path"/usr/include/", the system will find it.

Floristic answered 31/12, 2012 at 9:32 Comment(0)
G
3

You need to make sure the is among the directories searched for headers. Find the place where the gmpxx.h header resides and add -I /path/to/header/ on your g++ line.

Graehme answered 31/8, 2011 at 4:19 Comment(3)
I am facing the same problem here and I don't find the file: I run sudo find / -iname gmpxx.h and it returns nothing. :sStearne
@VitorLima: Are you sure that you have the necessary packages installed?Graehme
I came back to the gmp's site and I found out that I have to pass the flag --enable-cxx to the configure script. So, I recompiled the gmp lib and ran ldconfig. Now, it works fine, I don't need even to use the -I option to compile my programs. (:Stearne

© 2022 - 2024 — McMap. All rights reserved.