Say your standard include path is /usr/include. That's where all of the standard C header files go, among other things. Standard C++ header files tend to go in /usr/include/c++ (or some other variation). Header files for libraries go in their own folder typically; for example, SDL includes go in /usr/include/SDL; ncurses includes go in /usr/include/curses; and some OpenGL includes go in /usr/include/GL. I would think that gmp header files should go in, say, /usr/include/gmp. You could put the C++ header files in the same place.
If you did this, rather than going
in your code, consider adding /usr/include/gmp to the include path and just usingCode:#include <gmp/gmpxx.h>
You can add a path to the search path for header files with the gcc/g++ optionCode:#include "gmpxx.h"
The space between -I and the rest of the path is optional.Code:g++ -I /usr/include/gmp
Sticking "fdopen" into google gives you this page:Also, if i try to compile a simple program using the c++ gmp classes, g++ gives me an error in the header file gmpxx.h - "Calling fdopen: No such file or directory". This is the program i am trying to compile:This is getting to me, i've shown the compiler the way to both library files and header files, and i've added "-lgmp -lgmpxx" just as the GMP documentation states, so why on earth isn't it working?Code:#include <gmp.h> #include <gmpxx.h> int main() { mpz_class a, b, c; a = 1423354; return 0; }
Apparently you need <stdio.h>. gmpxx.h should include it, but perhaps they forgot to . . . .Code:NAME fdopen - associate a stream with a file descriptor SYNOPSIS #include <stdio.h> FILE *fdopen(int fildes, const char *mode);
Or maybe it's a runtime error. In which case, it's probably not something you've done wrong, because all of fdopen()'s (likely) errors seem to be programmer-related:
Unless you're using a lot of memory or opening a lot of streams, it's going to be either EBADF, in which case whatever file descriptor being passed to fdopen() is invalid, or the mode is invalid (which is really unlikely if they tested gmpxx even once!).Code:ERRORS The fdopen() function may fail if: [EBADF] The fildes argument is not a valid file descriptor. [EINVAL] The mode argument is not a valid mode. [EMFILE] {FOPEN_MAX} streams are currently open in the calling process. [EMFILE] {STREAM_MAX} streams are currently open in the calling process. [ENOMEM] Insufficient space to allocate a buffer.
So . . . maybe some file or another can't be opened. Does gmpxx have a runtime? Perhaps putting your header and library files in a standard place would help, although I don't see how it could . . .