未从 "HelloWorld" 场景开始时出现链接器错误
linker error when not starting with "HelloWorld" scene
我刚开始使用 Cocos2d-x c++(版本 3.4),我正在尝试为 Mac 构建一个简单的游戏,但是当我在 [=27] 中更改这一行时=]
auto scene = HelloWorld::createScene();
到我的自定义场景
auto scene = KeyboardScene::createScene();
我收到此链接器错误:
Undefined symbols for architecture x86_64:
"KeyboardScene::createScene()", referenced from:
AppDelegate::applicationDidFinishLaunching() in AppDelegate.o
ld: symbol(s) not found for architecture x86_64
clang: error: linker command failed with exit code 1 (use -v to see invocation).
我不知道我在这里遗漏了什么,感谢任何帮助,谢谢。
如果您想查看自定义 class 源代码,请访问:
这可能是两种情况之一的结果。
首先。您根本没有定义 KeyboardScene::createScene()
符号。检查 KeyboardScene.cpp
文件中是否确实有 KeyboardScene:: createScene()
的定义。您 KeyboardScene.cpp
应该包含这样的代码:
KeyboardScene::createScene() {
// function body here
}
其次。您不编译 KeyboardScene.cpp
或不 link 生成 KeyboardScene.o
到可执行文件中。检查是否包含 KeyboardScene.cpp
以构建应用程序目标集,如此处示例中所示。
我刚开始使用 Cocos2d-x c++(版本 3.4),我正在尝试为 Mac 构建一个简单的游戏,但是当我在 [=27] 中更改这一行时=]
auto scene = HelloWorld::createScene();
到我的自定义场景
auto scene = KeyboardScene::createScene();
我收到此链接器错误:
Undefined symbols for architecture x86_64:
"KeyboardScene::createScene()", referenced from:
AppDelegate::applicationDidFinishLaunching() in AppDelegate.o
ld: symbol(s) not found for architecture x86_64
clang: error: linker command failed with exit code 1 (use -v to see invocation).
我不知道我在这里遗漏了什么,感谢任何帮助,谢谢。
如果您想查看自定义 class 源代码,请访问:
这可能是两种情况之一的结果。
首先。您根本没有定义 KeyboardScene::createScene()
符号。检查 KeyboardScene.cpp
文件中是否确实有 KeyboardScene:: createScene()
的定义。您 KeyboardScene.cpp
应该包含这样的代码:
KeyboardScene::createScene() {
// function body here
}
其次。您不编译 KeyboardScene.cpp
或不 link 生成 KeyboardScene.o
到可执行文件中。检查是否包含 KeyboardScene.cpp
以构建应用程序目标集,如此处示例中所示。