【发布时间】:2013-12-02 11:11:05
【问题描述】:
我正在使用 xcode 用 C 创建一个静态库,我似乎收到错误Undefined symbols for architecture i386。
静态库项目,包含三个文件:fun.c、testFun.cpp、testFun.h
这里是testFun.cpp
#include "testFun.h"
extern void test_c_fun();
void TestFun::test()
{
printf("# TestFun c++ # ");
test_c_fun();
}
这里是fun.c
#include <stdio.h>
void test_c_fun()
{
printf("# test_c_fun #");
}
当我使用“IOS Device”和“iPhone Retina(4-inch)”构建时,我得到了两个 x.a 文件。
使用lipo工具和-create参数输出新的x.a,支持arm和i386。
将 x.a 添加到我的项目中,并包含 testFun 头文件现在代码:
TestFun tf;
tf.test();
然后构建它,我得到这些错误
Undefined symbols for architecture i386: "test_c_fun()", referenced from: TestFun::test() in libstatistic.a(testFun.o) ld: symbol(s) not found for architecture i386
当我隐藏 c-fun 调用 (test_c_fun) 时,构建成功!
看起来像:
#include "testFun.h"
extern void test_c_fun();
void TestFun::test()
{
printf("# TestFun c++ # ");
//test_c_fun();
}
为什么不能使用 C 文件?
【问题讨论】: