eclipse Cocos2D-X for android,符号“cocos2d”无法解析

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/14313349/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-09-19 19:48:06  来源:igfitidea点击:

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

androideclipsemacosandroid-ndkcocos2d-x

提问by pktangyue

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

我从http://www.raywenderlich.com/11283/cocos2d-x-for-ios-and-android-getting-started开始使用 Cocos2D-X for android 。

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.

我在 xcode 和 android 中运行演示没有问题,直到我转到“在 Eclipse 中定义组合的 Java/C++ 项目”部分。

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

我做的一切在这之后,我得到了错误Symbol 'cocos2d' could not be resolvedusing namespace cocos2d;jni/hellocpp/main.cpp和许多其他类似的错误。我发现#include "cocos2d.h"这个文件中丢失了,所以我添加了这一行,但错误仍然存​​在。

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

我不知道为什么,但我认为一定是某些库没有被导入。

In my android project, there is a includesdir 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.

在我的android项目中,有一个includes包含NDK和$(COCOS2DX_HOME)/cocos2dx/include的目录,但在$(COCOS2DX_HOME)/cocos2dx/include中只有7个.h文件(包括cocos2d.h)。我不知道这是否正确。

Does anybody can help me, thanks.

有没有人可以帮帮我,谢谢。

回答by pktangyue

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.htmlwritten by Chinese).

我根据另一篇文章(http://www.cnblogs.com/young40/archive/2012/10/19/cocos2d-x-mac-os-x-android-xcode-ios-development-setup. html是 CN 人写的)。

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

http://www.raywenderlich.com/11283/cocos2d-x-for-ios-and-android-getting-started之间的重要区别,我在下面列出:

  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 cocos2dxdirectory inside the $COCOS2DX_HOMEfolder.( 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

  1. 右键单击项目,然后选择 Properties\C/C++ General\Paths and Symbols\Source location。点击链接文件夹,选中链接到文件系统中的复选框的文件夹,并浏览到cocos2dx里面目录$ COCOS2DX_HOME文件夹。(方式与添加类相同)

  2. 右键单击项目并选择 Properties\C/C++ General\Path and Symbols\GNU C++。添加$(COCOS2DX_HOME)/CocosDenshion/include

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

起初,我怀疑不包括cocos2dx类。实际上,在我链接$COCOS2DX_HOME/cocos2dx到项目之后,所有错误都消失了。

回答by user1169079

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

只需检查您的项目属性中是否包含 Cocos2d-x headers 文件夹的路径?如果不是右键单击您的项目 -> 属性 -> C/C++ 常规 -> 路径和符号 -> 包含选项卡 -> 程序集 -> 添加 -> PATH_TO_YOUR_COCOS2DX/cocos2dx/include 以及 GNU C++ 选项卡

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

您必须用下载 cocos2dx 的实际绝对路径替换 PATH_TO_YOUR_COCOS2DX