User forums > Help

Codeblocks cant find include files

(1/3) > >>

LeslieS:
Hello, I am new to CodeBlocks and C++. 

I am trying out QT5 (on Ubuntu) following https://zetcode.com/gui/qt5/introduction/ and can't figure out how to point CodeBlocks to the header files.   

--- Code: ---#include <QtCore>
#include <iostream>

int main() {
   
    std::cout << "Qt version: " << qVersion() << std::endl;
}
--- End code ---
I get "no such file or directory" on the #include <QtCore> line.
If I type it in manually CodeBlocks auto completes the include and I can see many QT headers available such as QVersionNumber
When I try to run this code the header file named in qversionnumber.h  "<QtCore/qnamespace.h>" is not found.

--- Code: ---#include <qt5/QtCore/QVersionNumber>
int main() {
    return 0;
}


--- End code ---
   
I used "whereis qt5" and added all (3) the directories to link libraries and to search directories but it didn't fix the issue.   
I know I am missing something. 
How do I get CodeBlocks to see these headers?


AndrewCot:
1. Either:
*    A) Right Click on your project in the Management window and select the "Build Options..."
*     B) In the Project menu select the "Build Options..."2.Then click on the "Search directories" tab
3. In the Compiler Tab add the directory where the includes files are.

If you get stuck have a look at the following page:http://www.kerrywong.com/2008/07/12/codeblocks-settings-for-qt-development/

LeslieS:
I follow your directions and add the QT directories to the compiler tab of search directories and the same problem persists. 
No such file or directory. 
 
 

AndrewCot:
Sound like you should be using the "File->New Project" menu to create a project as C::B uses projects to build "things" (DLL, Plugins, exe etc) and then projects can be combined into workspaces. I would suggest having a quick/skim read of the C::B manual, even though it is IMHO missing allot of bits it is better then nothing. The manual is not currently included in the Linux release, but is available from the following page:
https://www.codeblocks.org/user-manual/
If you ever do any wxWidget work then the C::B manual is IMHO for C:B & wxwidget is available from https://github.com/PBfordev/wxpbguide.You can use SDL2 in QT as well if you want, but unfortunately there is no manual for this and I cannot remember where I found the relevant info.

LeslieS:
Unfortunately I spoke too soon.   
I did create a project and tried your solution but it doesn't work for me.     
I can get this to run because their is no dependancies in the header file.

--- Code: ---#include <qt5/QtCore/QtCoreVersion>
//#include <qt5/QtCore/QVersionNumber>
#include <iostream>
int main() {
    std::cout << QTCORE_VERSION_STR;

}

--- End code ---
 
But as soon as a header file has an include then it is not found.   
I think it has something to do with the fact that the header files are prefixed with qt5 whereas the dependant files don't have the prefix.   

Navigation

[0] Message Index

[#] Next page

Go to full version