Cpp error while compiling a plugin for cocos2d-x

I’m trying to write an Android plugin for cocos2dx. But I seem to have hit a (basic?) c++ obstacle.
I’m encountering the following error-see below: (shortVersion – “‘ProtocolAds’ does not name a type.”).

make.exe: Entering directory `C:/Android/Cocos2d/cocos2d-x-cocos2d-x-3.6/CocosPr
[armeabi] Compile++ thumb: cocos2dcpp_shared <= HelloWorldScene.cpp
[armeabi] StaticLibrary  : libcocos2d.a
[armeabi] StaticLibrary  : libcocostudio.a
[armeabi] StaticLibrary  : libcocosbuilder.a
[armeabi] StaticLibrary  : libcocos3d.a
[armeabi] StaticLibrary  : libspine.a
[armeabi] StaticLibrary  : libnetwork.a
[armeabi] StaticLibrary  : libui.a
[armeabi] StaticLibrary  : libaudioengine.a
[armeabi] StaticLibrary  : libcocosdenshion.a
[armeabi] StaticLibrary  : flatbuffers.a
[armeabi] StaticLibrary  : libextension.a
[armeabi] StaticLibrary  : libcocos2dxinternal.a
[armeabi] StaticLibrary  : libbox2d.a
[armeabi] StaticLibrary  : libcocos2dandroid.a
[armeabi] StaticLibrary  : libcpufeatures.a
[armeabi] Gdbserver      : [arm-linux-androideabi-4.9] libs/armeabi/gdbserver
[armeabi] Gdbsetup       : libs/armeabi/gdb.setup
jni/../../Classes/HelloWorldScene.cpp: In member function 'void HelloWorld::test
jni/../../Classes/HelloWorldScene.cpp:97:24: error: 'ProtocolAds' does not name
a type
  _woobi = dynamic_cast<ProtocolAds*>(PluginManager::getInstance()->loadPlugin("

To the best of my understanding, does not name a type is an error that comes when the linker does not know the object’s class (for any possible reason).

My Thoughts:

  • The error is “error: ‘ProtocolAds’ does not name a type”
  • The error happens in a .cpp file that has this line in: #include “ProtocolAds.h”
  • The header file for the above .cpp file has the same line: #include “ProtocolAds.h”. And a call for this line: cocos2d::plugin::ProtocolAds* _woobi; And it looks like this file has no problem with ProtocolAds. (since if i’m not calling ProtocolAds from the .cpp file, the .h compiles and links without error)

How is that possible? I’ve been reading and trying for a huge amount of time and no win. Can anyone please help?

Source: c++

Leave a Reply