Tags

Code::Blocks (http://www.codeblocks.org/) is an alternative C++ IDE for Ubuntu platform. It is a free C++ IDE and you do not need to configure Wine to get Visual C++ runs on your Linux OS. Although the user interface probably will be slightly different from Visual C++ but the features and main functionalities are almost the same.

However, CodeBlocks seems having problem in getting the header file if the .cpp file includes the header file for compilation as well. For example, in the PatientAccount.cpp file:

#include "PatientAccount.h"

You will get the following error when compiling the PatientAccount.cpp file:

/home/yee/CodeBlocks/Assignment1/src/PatientAccount.cpp|1|fatal error: PatientAccount.h: No such file or directory

Workaround

You need to provide the absolute path to tell the compiler where to find the header file:

#include "/home/yee/CodeBlocks/Assignment1/include/PatientAccount.h"

Solution

You have to configure the project build and add the directory where the header file is located. The steps are as below:-

  1. Project > Build options > Search Directories tab
  2. Choose the Policy dropdown list with the option: Prepend target options to project options”
  3. Click the button ‘Add’ to search and add the directory (e.g. ‘include’ directory)
  4. Another popup with the question “Keep this as a relative path?” and click ‘Yes’ to add the directory.

Note: The location of the settings probably varies depending on the Code::Blocks version. The workaround and solution is applicable for version 10.05.

Advertisement