0

I have a c++ project on Windows. I installed cygwin and set the environment variable PATH to cygwin directory. But I get this error:

fatal error: xlslib/xlslib.h: No such file or directory. Compilation terminated

But xlslib directory and xlslib.h exists in my project folder.

I get same error even if I compile the project on a Linux virtual machine. Everything works instead if I compile it on Linux vm using Netbeans IDE.

So I have two possibilities:

  1. Generate .exe using Netbeans on Linux. But, how?
  2. Generate .exe using cygwin on windows. but I need to solve the copilation error. What is missing? perhaps the xlslib folder position is wrong?? Perhaps another environment variable is missing?

Any suggestion?

Thank you

EDIT: I also tried with this command in cygwin:

g++ main.cpp -Ixlslib -o myPrj

and also

g++ main.cpp -IC:\cygwin64\home\xxx\yyy\xlslib -o myPrj

But I get always same errore even if the folder correctly exists: enter image description here

Ciccio
  • 1,920
  • 4
  • 27
  • 68
  • You should defined default path for searching ``. If those header files are beside your project, you can also use `#include "path_to_file/xlslib.h"` – masoud Oct 06 '20 at 11:00
  • I bet your netbeans IDE automatically adds the `-I.` flag, which tells the compiler where to look for header files. – Botje Oct 06 '20 at 11:01
  • I strongly suggest that you invest in a build system such as CMake or Makefiles, which will allow you to portably define how your program should be compiled. – Botje Oct 06 '20 at 11:02
  • Does this answer your question? [g++ cannot find header file](https://stackoverflow.com/questions/8736106/g-cannot-find-header-file) – Botje Oct 06 '20 at 11:02
  • @Botje I tryed with `g++ main.cpp -Ixlslib -o *****` but does not work... I also tried with absolute path... but no success – Ciccio Oct 06 '20 at 11:04
  • You need to point the `-I` flag to the directory that contains the xlslib directory (and that directory should of course contain xlslib.h) – Botje Oct 06 '20 at 11:05
  • @masoud yes, I tried but then on cascade I obtain same errors for all includes in `xlslib.h` library. That is not a my library – Ciccio Oct 06 '20 at 11:06
  • @Botje that link does not answer my question... yes `-I` poi to `xlslib`, and yes, inside it there is `xlslib.h`.... I update the question to let you see better – Ciccio Oct 06 '20 at 11:08
  • `-I` should point to the *parent directory* of `xlslib` – Botje Oct 06 '20 at 11:10
  • @Botje the parent directory is where `main.cpp` is.... however I tried... but nothing... I updated the question – Ciccio Oct 06 '20 at 11:14
  • Let us [continue this discussion in chat](https://chat.stackoverflow.com/rooms/222588/discussion-between-ciccio-and-botje). – Ciccio Oct 06 '20 at 11:15
  • With over 1k reputation you should be aware, that using *screenshots* for the code and for the error messages is discouraged on Stack Overflow. See also [ask]. – Tsyvarev Oct 06 '20 at 11:51
  • @Tsyvarev, ok I updated my question. Now do you have anything to suggest about the it? – Ciccio Oct 06 '20 at 12:30
  • 1
    If you have the header at ``C:\cygwin64\home\xxx\yyy\xlslib\xlslib.h``, then its inclusion via ``#include `` will work after adding ``C:\cygwin64\home\xxx\yyy`` as include directory. With the include directory ``C:\cygwin64\home\xxx\yyy\xlslib`` you cannot include the header in the above way, but you may do that by ``#include ``. – Tsyvarev Oct 06 '20 at 13:53
  • @Tsyvarev if I include `C:\cygwin64\home\xxx\yyy` it does not work – Ciccio Oct 06 '20 at 14:51

0 Answers0