为什么我的 .cpp 文件没有被处理?

发布于 2024-09-10 13:20:45 字数 1274 浏览 2 评论 0原文

我正在尝试编译(制作)游戏源,似乎我的 gRace.cpp 文件被排除在外,因为它不断为我的所有 gRace 类方法返回未定义的引用错误。

libtron.a(libtron_a-gGame.o): In function `gGame::StateUpdate()':
gGame.cpp:(.text+0x99e9): undefined reference to `gRace::Reset()'
libtron.a(libtron_a-gGame.o): In function `gGame::Analysis(float)':
gGame.cpp:(.text+0xad48): undefined reference to `gRace::Sync(int, int, int)'
gGame.cpp:(.text+0xad4d): undefined reference to `gRace::Done()'
gGame.cpp:(.text+0xad61): undefined reference to `gRace::Winner()'
gGame.cpp:(.text+0xb786): undefined reference to `gRace::End()'
libtron.a(libtron_a-gWinZone.o): In function `gWinZoneHack::OnEnter(gCycle*, float)':
gWinZone.cpp:(.text+0x9206): undefined reference to `gRace::ZoneHit(ePlayerNetID*)'
libtron.a(libtron_a-gWinZone.o): In function `gWinZoneHack::gWinZoneHack(eGrid*, eCoord const&, bool)':
gWinZone.cpp:(.text+0xda96): undefined reference to `gRace::NewZone(gWinZoneHack*)'
libtron.a(libtron_a-gWinZone.o): In function `gWinZoneHack::gWinZoneHack(eGrid*, eCoord const&, bool)':
gWinZone.cpp:(.text+0xdcc6): undefined reference to `gRace::NewZone(gWinZoneHack*)'
collect2: ld returned 1 exit status

我通过以下方式将 gRace.h 文件包含在两个文件中:

#include "gRace.h"

关于可能导致它无法处理的任何想法?

I'm trying to compile (make) a game source and it seems that my gRace.cpp file is being excluded or something because it keeps returning undefined reference errors for all my gRace class methods.

libtron.a(libtron_a-gGame.o): In function `gGame::StateUpdate()':
gGame.cpp:(.text+0x99e9): undefined reference to `gRace::Reset()'
libtron.a(libtron_a-gGame.o): In function `gGame::Analysis(float)':
gGame.cpp:(.text+0xad48): undefined reference to `gRace::Sync(int, int, int)'
gGame.cpp:(.text+0xad4d): undefined reference to `gRace::Done()'
gGame.cpp:(.text+0xad61): undefined reference to `gRace::Winner()'
gGame.cpp:(.text+0xb786): undefined reference to `gRace::End()'
libtron.a(libtron_a-gWinZone.o): In function `gWinZoneHack::OnEnter(gCycle*, float)':
gWinZone.cpp:(.text+0x9206): undefined reference to `gRace::ZoneHit(ePlayerNetID*)'
libtron.a(libtron_a-gWinZone.o): In function `gWinZoneHack::gWinZoneHack(eGrid*, eCoord const&, bool)':
gWinZone.cpp:(.text+0xda96): undefined reference to `gRace::NewZone(gWinZoneHack*)'
libtron.a(libtron_a-gWinZone.o): In function `gWinZoneHack::gWinZoneHack(eGrid*, eCoord const&, bool)':
gWinZone.cpp:(.text+0xdcc6): undefined reference to `gRace::NewZone(gWinZoneHack*)'
collect2: ld returned 1 exit status

I'm including the gRace.h file in both files via:

#include "gRace.h"

Any ideas on what might be causing it to not be processed?

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(3

十二 2024-09-17 13:20:45

不包含头文件会导致未定义函数编译器错误。这些是链接器错误,这意味着实际的源文件未与其他文件链接(也就是说,它与您是否在正确的位置包含 gRace.h 无关) 。检查您的构建脚本以确保正确链接 gRace.cpp

Not including the header file would cause undefined function compiler errors. These are linker errors, which means the actual source file isn't being linked with the other files (that is, it has nothing to do with whether or not you included gRace.h in the right places). Check your build script to ensure gRace.cpp is being linked in properly

混浊又暗下来 2024-09-17 13:20:45

如果它是一个 automake 项目,则您在 Makefile.am 的 _SOURCES 部分中缺少 gRace.cpp。

If it is an automake project you are missing gRace.cpp in your _SOURCES section in the Makefile.am.

回梦 2024-09-17 13:20:45

这似乎是链接错误而不是编译错误。最有可能的是,您缺少一些应该链接的外部库。

This apprears to be a linking error and not a compilation error. Most likely, you are missing some external libraries that you should be linking against.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文