0

xcode を使用して C でスタティック ライブラリを作成していますが、エラーが発生するようですUndefined symbols for architecture i386

静的ライブラリ プロジェクトには、次の 3 つのファイルが含まれますfun.ctestFun.cpptestFun.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)」でビルドするとxaファイルが2つ出てきます。

lipotool とparam を使用して、と-createをサポートする新しい xa を出力します。armi386

プロジェクトに xa を追加し、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 ファイルで動作しないのですか?

4

1 に答える 1