How to fix "No such file or directory" library error? I am using Mingw-w64 compiler and Netbeans IDE

Viewed 428

I want to create a a text based interface (TUI) software. I found FTXUI library in GitHub and want to use it, so I downloaded it to my computer. The project repository structure is:

FTXUI-master
├───.github
├───doc
├───examples
│   ├───component
│   ├───dom
│   ├───html
│   └───util
├───include
│   └───ftxui
│       ├───component
│       ├───dom
│       ├───screen
│       └───util
├───other
└───src
    └───ftxui
        ├───component
        ├───dom
        └───screen

I am using Netbeans 8.2 RC and Mingw-w64 compiler, first I tried to add the includes and the sources in Netbeans adding the "include" and "src" from FTXUI to the include and source file paths in Netbeans, like this:

CppApplication
│
│
├───HeaderFiles
│   └include
│    └───ftxui
│        ├───component
│        ├───dom
│        ├───screen
│        └───util
│
├───SourceFiles
│    └──main.cpp
│    └src
│     └───ftxui
│         ├───component
│         ├───dom
│         ├───screen
│         └───util
├───TestFiles
└───ImportantFiles

The main.cpp file content is:

#include <cstdlib>

#include "ftxui/dom/elements.hpp"
#include "ftxui/screen/screen.hpp"

#include <iostream>

using namespace std;


int main(int argc, char** argv) {

  using namespace ftxui;

  // Define the document
  Element document =
    hbox({
      text(L"left")   | border,
      text(L"middle") | border | flex,
      text(L"right")  | border,
    });
 
  auto screen = Screen::Create(
    Dimension::Full(),       // Width
    Dimension::Fit(document) // Height
  );
  Render(screen, document);
  std::cout << screen.ToString() << std::endl; 

    return 0;
}

The output I got was:

cd 'C:\Users\CurrentUser\Documents\NetBeansProjects\CppApplication_2'
C:\msys\1.0\bin\make.exe -f Makefile CONF=Debug
"/C/msys/1.0/bin/make.exe" -f nbproject/Makefile-Debug.mk QMAKE= SUBPROJECTS= .build-conf
make.exe[1]: Entering directory `/c/Users/CurrentUser/Documents/NetBeansProjects/CppApplication_2'
"/C/msys/1.0/bin/make.exe"  -f nbproject/Makefile-Debug.mk dist/Debug/MinGW-Windows/cppapplication_2.exe
make.exe[2]: Entering directory `/c/Users/CurrentUser/Documents/NetBeansProjects/CppApplication_2'
mkdir -p build/Debug/MinGW-Windows/_ext/3a58e87f
rm -f "build/Debug/MinGW-Windows/_ext/3a58e87f/checkbox.o.d"
g++    -c -g -MMD -MP -MF "build/Debug/MinGW-Windows/_ext/3a58e87f/checkbox.o.d" -o build/Debug/MinGW-Windows/_ext/3a58e87f/checkbox.o ../../../Desktop/FTXUI-master/FTXUI-master/src/ftxui/component/checkbox.cpp
../../../Desktop/FTXUI-master/FTXUI-master/src/ftxui/component/checkbox.cpp:5:10: fatal error: ftxui/component/checkbox.hpp: No such file or directory
 #include "ftxui/component/checkbox.hpp"
          ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
compilation terminated.
make.exe[2]: *** [build/Debug/MinGW-Windows/_ext/3a58e87f/checkbox.o] Error 1
make.exe[2]: Leaving directory `/c/Users/CurrentUser/Documents/NetBeansProjects/CppApplication_2'
make.exe[1]: *** [.build-conf] Error 2
make.exe[1]: Leaving directory `/c/Users/CurrentUser/Documents/NetBeansProjects/CppApplication_2'
make.exe": *** [.build-impl] Error 2

BUILD FAILED (exit value 2, total time: 2s)

Thanks in advance for the help.

2 Answers

You have this error because your g++ command line has no option to add any directory to the header search path. So the preprocessor will look for your header files (between quotes) only in the directory of the current compiled file and some pre-configured folders. To add a director to the search path an option like -Idir should be used( it is the most commonly used ).
With Netbeans, you can add a directory in:
Option->C/C++->Code Assistance-> C Compiler for gcc.
Option->C/C++->Code Assistance-> C++ Compiler for g++.

If you have an include directory in some non-standard location you have to tell NetBeans about that:

  • Right-click on the project name in the Projects pane.
  • Left-click on the Properties line in the drop-down menu (bottom line). The Properties pop-up window with a lot of settings for your project will come up.
  • Choose Build/C++ Compiler in the left pane. All the compilation settings will show up.
  • Find the line Include Directories (the top line). You can add any non-standard include directory to your project using the directory chooser - ... on this line.
  • Don't forget to click OK when you are done.

This pop-up window looks like this:

Properties

Related