这个错误是因为在Cocos2d-x 3.17版本中,tinyxml2的位置发生了变化。在2.0版本中,tinyxml2的头文件位于support/tinyxml2/tinyxml2.h,但在3.17版本中,它被移动到external/tinyxml2/tinyxml2.h。

要解决这个错误,你需要做以下步骤:

  1. 打开你的项目中的AppDelegate.cpp文件。
  2. 在文件开头处添加以下代码:
#if (CC_TARGET_PLATFORM == CC_PLATFORM_WINRT) || (CC_TARGET_PLATFORM == CC_PLATFORM_WP8)
#include "external/tinyxml2/tinyxml2.h"
#else
#include "tinyxml2/tinyxml2.h"
#endif
  1. 然后,在AppDelegate.cpp文件中的applicationDidFinishLaunching()方法的开头添加以下代码:
#if (CC_TARGET_PLATFORM == CC_PLATFORM_WINRT) || (CC_TARGET_PLATFORM == CC_PLATFORM_WP8)
    FileUtils::getInstance()->addSearchPath("external");
#else
    FileUtils::getInstance()->addSearchPath("cocos2d");
#endif

这样,你的项目就能够找到正确的tinyxml2头文件了。

注意:如果你之前在项目中使用了tinyxml2,你还需要将相关的代码更新为新版本的API,因为tinyxml2在Cocos2d-x 3.x版本中有一些API的变化

cocos2dx-20升级为cocos2dx-317后 fatal error supporttinyxml2tinyxml2h file not found

原文地址: https://www.cveoy.top/t/topic/igKD 著作权归作者所有。请勿转载和采集!

免费AI点我,无需注册和登录