"cocos2d.h" not found

"cocos2d.h" not found


I just have installed Cocos2d-x successfully on Ubuntu 18.04 LTS and also successfully ran the cpp-tests. Now I tried to create a cocos project with the cocos command line tool using this command:
cocos new -p -l -d
This also worked, but then CodeBlocks (the IDE I’m using for C and C++ programming) told me after compiling the main.cpp file that the cocos2d.h header file couldn’t be found. Does anyone know what I did wrong and how I can fix this? Thanks in advance.


I use Linux and code blocks but I don’t compile from code blocks. I use it as the ide and still compile from the command-line.

There are many threads on code blocks. Perhaps one of them will help: https://discuss.cocos2d-x.org/search?context=topic&context_id=45973&q=Codeblocks&skip_context=true

Netbeans works well I have heard


The IDE in which I’m working isn’t the problem. I tried compiling from the command line and I had the same error like before. The problem is, that the header files can’t be found and they also aren’t in the directory where AppDelegate.h is.


Show me please. I use Linux as my primary os and I don’t experience issues usually.


Of cource it aren’t in the directory where AppDelegate.h is, it lies in projectDir->cocos2d->cocos. It looks like you need to setup search path for CodeBlocks.


cocos2d.h not found means you don’t have header search path configured correctly.


The header search paths were the problem. After I set them to the right directory everything worked as it should. Thank you very much for the help!


Awesome. Can you please post a screenshot so future developers can benefit?


I just had to go to Settings->Compiler->Search directories and then I clicked the Add Button and added the path to the header files. Sorry for not sending a screenshot but I’m quite new to Ubuntu (I came from Windows and only used Snipping Tool) and I don’t know how to make a screenshot on Ubuntu. Anyway it’s not difficult to find and I’m quite sure that everyone who wants to find it will find it with this description.



You should have a screen capture tool installed if you did more than a minimal install

PM me if you have Linux questions , BTW.