Cocos2D-X for android, Symbol 'cocos2d' could not be resolved

pktangyue picture pktangyue · Jan 14, 2013 · Viewed 10.3k times · Source

I start with Cocos2D-X for android following http://www.raywenderlich.com/11283/cocos2d-x-for-ios-and-android-getting-started.

I run the demo in xcode and android with no problem, until I go to the ' Defining a Combined Java/C++ Project in Eclipse' part.

After I do all in this, I get the error Symbol 'cocos2d' could not be resolved for using namespace cocos2d; in jni/hellocpp/main.cpp and many other similar errors. And I find #include "cocos2d.h" missing in this file, so I add this line, but the error still exists.

I don't why, but I think it must be some libraries not be imported.

In my android project, there is a includes dir including NDK and $(COCOS2DX_HOME)/cocos2dx/include, but in $(COCOS2DX_HOME)/cocos2dx/include there are only 7 .h files(include cocos2d.h). I don't know if this is correct.

Does anybody can help me, thanks.

Answer

pktangyue picture pktangyue · Jan 17, 2013

I have solved this problem according to another article (http://www.cnblogs.com/young40/archive/2012/10/19/cocos2d-x-mac-os-x-android-xcode-ios-development-setup.html written by Chinese).

The important differences between http://www.raywenderlich.com/11283/cocos2d-x-for-ios-and-android-getting-started, I list below:

  1. right click project, and select Properties\C/C++ General\Paths and Symbols\Source location. Click Link Folder, check the Link to a folder in the file system checkbox, and browse to the cocos2dx directory inside the $COCOS2DX_HOME folder.( the same way as add Classes)

  2. right click project and select Properties\C/C++ General\Path and Symbols\GNU C++. Add $(COCOS2DX_HOME)/CocosDenshion/include

At first, I doubted not including cocos2dx class. And actually after I linked $COCOS2DX_HOME/cocos2dx into project, all wrongs gone away.