0

I am working in eclipse with MinGw (g++) compiler.

So my problem is when I import .h file from library I have downloaded and I try to build(compile) my project, error is "no such file or directory" for that .h file you can see on picture but still the class from that header file is recognised in the code! Another strange thing is if I make intentional error in that .h file #import is succesfull and the error from that .h file is shown, that means it trys to compile that .h file. So it does not know where the file is but it still compiles it ??? what???

cmd line:

g++ -Ic:D:\Documents\cpp_testing\bignum_testing\lib Main.cpp

error:

Main.cpp:10:22: fatal error: Cbignums.h: No such file or directory
 #include "Cbignums.h"
                      ^
compilation terminated.

I hope somone will know how to fix this and that it will help other people!

Picture without error in .h file: enter image description here

Picture with intentional error in .h file! enter image description here

Pixelchemist
  • 24,090
  • 7
  • 47
  • 71
Robert
  • 43
  • 1
  • 6
  • 2
    Don't show images. Show the *command* used to run `gcc` or `g++` and the resulting *diagnostic messages*; both are text and should be shown as text (with four spaces before each line); you might be interested by the `-I` and `-H` [preprocessor options](https://gcc.gnu.org/onlinedocs/gcc/Preprocessor-Options.html) of `g++` – Basile Starynkevitch Jan 08 '16 at 14:32
  • BTW, I would suggest to compile with [GNU make](http://www.gnu.org/software/make/). You can find several examples of `Makefile` here (e.g. [this](http://stackoverflow.com/a/14180540/841108)...). – Basile Starynkevitch Jan 08 '16 at 14:36
  • Thanks, did you understand my problem and if you did do you know the solution I'v had this same problem with other libraries and it is very frustrating I have read alot of other peoples problems on forums but I could not find this type of problem and fix for it ! – Robert Jan 08 '16 at 14:47
  • You have the wrong mindset. You are using a command line tool, `g++`. So run it in a terminal! The fancy IDE is obscuring your mind. So show the compilation commands! – Basile Starynkevitch Jan 08 '16 at 14:48
  • You probably don't realize it yet, but it looks that Eclispe is making you lose a *lot* of time. Did you consider using some other editor (e.g. `emacs` or perhaps `notepad++` if your system has it) and compiling on the command line - in a terminal? – Basile Starynkevitch Jan 08 '16 at 14:56
  • You still don't show the `g++` command that you have run. You should **edit your question** to show it. I guess that you could remove the useless figures (which I am not able to see clearly). – Basile Starynkevitch Jan 08 '16 at 15:12
  • Ok so I did it with cmd: command: g++ -Ic:D:\Documents\cpp_testing\bignum_testing\lib Main.cpp error: Main.cpp:10:22: fatal error: Cbignums.h: No such file or directory #include "Cbignums.h" ^ compilation terminated. – Robert Jan 08 '16 at 15:14
  • I will put it in the original post – Robert Jan 08 '16 at 15:14

2 Answers2

0

EOF is mostly a C thing from <cstdio> (or <stdio.h> form the C standard library, not the C++ one) which you probably forgot to include (e.g. by commenting its //#include <cstdio>)

Try compiling with appropriate -I and -H preprocessor options to g++ (of course, take time to read the documentation to find what they are doing).

BTW, you could ask for the preprocessed form with g++ -C -E Cbignums.cpp > Cbignums.ii then look, with some editor or pager, into the generated Cbignums.ii file.

I strongly recommend you to read a good book about Programming using C++ and to read the GCC documentation. In general, read the documentation of everything you are using for development (tools, e.g. compilers, and libraries)

PS. Every free software C++ compiler I know (GCC & Clang/LLVM...) are command line tools, so run them in a terminal, perhaps thru GNU make. Notice that Eclipse is not a compiler (it is an editor, self-glorified as an IDE), and you probably are not using it cleverly. Don't forget to pass -Wall -g to g++

Basile Starynkevitch
  • 223,805
  • 18
  • 296
  • 547
0

I suspect that you should

#include "lib/Cbignums.h"

in bignum_testing.cpp if that is the path of the Cbignums.h - relative to the source file.

The IDE recognizes the type because you have the header in your project but the red lines indicate that the include will fail.

Pixelchemist
  • 24,090
  • 7
  • 47
  • 71