User forums > Help
CB/MinGW compiler doesn't include .h files although they're there
NameZero912:
Ok I got this problem:
I created a very easy C++ sample project where I define a function in one cpp file and also created a funcname.h file that declares the function so it can be used by other functions in other files. All cpp and h files are created using File->New->File and selecting the Source/header icon and creating it with that Wizard. When creating the header file I added it to the projects debug and release target, and it seems to be properly integrated in the project.
Anyway, when I want to compile it (doesn't matter if debug or release) it refuses to do so and gives this message:
--- Quote ---....main.cpp:3: funcname.h: No such file or directory
:: === Build finished: 1 errors, 0 warnings ===
--- End quote ---
This are the system specifications:
- Win XP SP2
- Codeblock SVN Revision 3865
- MinGW 5.1.3 installer that installed the "Current" GCC.
Any ideas ?
Another thing that I was wondering about: CB wouldn't recognize the MinGW compiler by default. I had to setup the compiler path manually (in the "Toolchain executables" dialog).
TDragon:
--- Quote from: NameZero912 on April 19, 2007, 07:15:36 pm ---Anyway, when I want to compile it (doesn't matter if debug or release) it refuses to do so and gives this message:
--- Quote ---....main.cpp:3: funcname.h: No such file or directory
:: === Build finished: 1 errors, 0 warnings ===
--- End quote ---
--- End quote ---
Please enable full command-line logging (Settings->Compiler and debugger->Global compiler settings->Other settings->Compiler logging), and post the entire output of the build log.
If funcname.h is not in the same directory as the file that includes it, or if your project uses the "Generate PCH in the object output dir" strategy (in the Project settings section of your project's Properties dialog), you will need to explicitly add the directory that contains funcname.h to your project's include paths (Project->Build options->Search directories->Compiler).
--- Quote ---Another thing that I was wondering about: CB wouldn't recognize the MinGW compiler by default. I had to setup the compiler path manually (in the "Toolchain executables" dialog).
--- End quote ---
Code::Blocks can currently only auto-detect MinGW if it is installed in the root of the main drive; i.e. C:\MinGW. All other locations require the path to be set manually as you have done.
NameZero912:
Ok. I enabled full logging, cleaned the project (right click on project and selected "Clean") and tried to build it again.
This comes up in the build log (not really any more information about the issue tbh):
--- Quote ----------------- Build: Debug in Aufgabe 2.8 ---------------
mingw32-g++.exe -Wall -fexceptions -g -ID:\Programme\MinGW\include -c "D:\Daten\FH\Info2 Practices Codeblock Projects\Aufgabe 2.8\printbits.cpp" -o obj\Debug\printbits.o
D:\Daten\FH\Info2 Practices Codeblock Projects\Aufgabe 2.8\printbits.cpp:1:23: printbits.h: No such file or directory
Process terminated with status 1 (0 minutes, 0 seconds)
1 errors, 0 warnings
--- End quote ---
As you can see, I setup the MinGW patch to "D:\Programme\MinGW". The project consists of main.cpp, printbits.cpp and printbits.h
Content of main.cpp:
--- Quote ---#include <iostream>
#include <printbits.h>
using namespace std;
int main()
{
int zahl = -5;
cout << "Teste Funktion printbits mit " << zahl << " -> Binaermuster: " << printbits(zahl) << endl;
return 0;
}
--- End quote ---
Content of printbits.cpp:
--- Quote ---include <printbits.h>
char* printbits(int zahl) {
//implementation of function
}
--- End quote ---
Content of printbits.h:
--- Quote ---#ifndef PRINTBITS_H_INCLUDED
#define PRINTBITS_H_INCLUDED
extern char* printbits(int zahl);
#endif
--- End quote ---
The project uses the default setting for that PCH thing btw. And the .h file does exist in the same directory as the .cpp file!
Any ideas what's wrong there?
rcoll:
Try changing that
#include <printbits.h>
to be
#include "printbits.h"
The angle brackets <> tell the compiler to look in the standard
(built-in) include directories, not your own source directory.
-- Ringo
TDragon:
What Ringo said. :)
Navigation
[0] Message Index
[#] Next page
Go to full version