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

10,320

Solution 1

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.

Solution 2

Just check if you have included the path to Cocos2d-x headers folder in your project properties? If not right click on your project -> Properties -> C/C++ General -> Paths and Symbols -> Includes tab -> Assembly -> Add -> PATH_TO_YOUR_COCOS2DX/cocos2dx/include and also in GNU C++ tab

where you must replace PATH_TO_YOUR_COCOS2DX by the actual absolute path to where you downloaded the cocos2dx

Share:
10,320
pktangyue
Author by

pktangyue

$ mkdir my_profile $ cd my_profile $ vi README.md i I'm an Engineer from China. Favorite: vim, bash, git Work on: python, java, javascript, html, css ESC:wq $ git init $ git add . $ git commint -m 'introduce myself'

Updated on August 07, 2022

Comments

  • pktangyue
    pktangyue over 1 year

    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.

  • user1169079
    user1169079 over 11 years
    @pktangyue : Check your build_native.sh inside proj.android ...change the path of ndk and cocos2d-x source inside it
  • JavaRunner
    JavaRunner about 11 years
    I don't have "C/C++ General" item in the properties. Don't you know why? :) I've imported built game in the Eclipse but have two errors: "Cocos2dxActivity cannot be resolved to a type" and "The import org.cocos2dx.lib cannot be resolved".
  • pktangyue
    pktangyue about 11 years
    @JavaRunner do you import the related project in cocos2dx/platform/android/java
  • pktangyue
    pktangyue about 11 years
    @JavaRunner for why you don't have "C/C++ General" item, have you already install CDT plugins?
  • JavaRunner
    JavaRunner about 11 years
    thanks! I've just imported cocos2dx/platform/android/java and it works now! :)
  • burseaner
    burseaner over 9 years
    I tried all your suggestions on Windows 7 machine but I still have the same error. I don't quite understand what you meant in 1. of the list. When I browse to cocos2dx I got an error "The folder 'cocos2dx' already exists. Therefore, it could not be right. Any further tips to get cocos2d-2.0-rc2-x-2.0.1 running on Windows 7?