gpt4 book ai didi

c - 无法将 C 代码链接到 Objective C : Undefined symbols for architecture arm64

转载 作者:行者123 更新时间:2023-11-30 14:37:48 25 4
gpt4 key购买 nike

我的 XCode 项目中有一些 C 代码(使用 Objective C)。我将 C 文件包含到 MyHost.m 中像这样的文件:

#include <my_code.h>

然后这样调用它:

my_function();

我已经设置了项目设置,以便 header 搜索路径设置包含包含我的 C 代码的目录。但是,当我构建时,我收到如下错误:

Undefined symbols for architecture arm64:
"_my_function", referenced from:
-[MyHost run] in MyHost.o

为什么链接器无法链接到 C 代码?

更新:我走上使用#include <file.h>之路的原因而不是#include "file.h"是因为后者无法解析该文件。我发现this related question这表明无论项目结构如何,XCode 都应该找到我的头文件。事实并非如此。即使删除并重新添加文件后,它仍然无法解决。

最佳答案

我已将文件添加为文件夹而不是组。组被 XCode 扁平化,因此可以直接包含。文件夹不是(但我仍然无法通过指定完整路径来包含)。组在项目 View 中显示为黄色图标,而文件夹显示为蓝色。

关于c - 无法将 C 代码链接到 Objective C : Undefined symbols for architecture arm64,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/57017409/

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