gpt4 book ai didi

iphone - c/objective-c问题

转载 作者:太空宇宙 更新时间:2023-11-04 07:41:42 25 4
gpt4 key购买 nike

我打算在我的 objective-c 类中的 .c 文件中使用 c 函数。我已经导入了 c 文件的 header 。但我仍然遇到问题,我的程序无法编译。

undefined symbol :

“gluUnProject(float, float, float, float const*, float const*, int const*, float*, float*, float*)”,引用自: -[GLView checkCollission:object:] in GLView.old:未找到符号collect2: ld 返回 1 个退出状态

知道如何解决这个问题吗?任何帮助当然不胜感激。古泰巴

最佳答案

此错误是由链接器而不是编译器发出的。这通常是由于代码被编译为 C 并从 C++ 或其他方式包含。

您通常可以通过在头文件中添加以下内容来确保头文件中的函数定义强制任何 C++ 编译器使用 C 语法来解决此问题:

#ifdef __cplusplus
extern "C" {
#endif

... definitions goes here ...

#ifdef __cplusplus
}
#endif

此方法还确保 .c 文件本身将函数定义视为 C,而不是意外地编译为 C++。

如果你不想改变头部,你可以用同样的方式封装#include语句。然而,这不能确保正确编译 .c 文件本身。

编辑:只是想一想:我假设您实际上正在编译 .c 文件?

关于iphone - c/objective-c问题,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/3207141/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com