1

我尝试将picoc项目编译成 xcode。没有外部库,只有我在命令行工具 C 项目中导入的 .c 和 .h 文件。

所有 .c 文件编译都没有问题,但是当 XCode 链接时,我收到以下消息:

    Undefined symbols for architecture x86_64:
  "_BasicIOInit", referenced from:
      _PicocInitialise in platform.o
  "_CStdOut", referenced from:
      _PrintSourceTextErrorLine in platform.o
      _PlatformVPrintf in platform.o
  "_MathFunctions", referenced from:
      _IncludeInit in include.o
  "_MathSetupFunc", referenced from:
      _IncludeInit in include.o
  "_PicocPlatformScanFile", referenced from:
      _IncludeFile in include.o
  ...

给出错误的命令如下:

/Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/clang -v -arch x86_64 -isysroot /Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/ MacOSX10.8.sdk -L/Users/laurent/Library/Developer/Xcode/DerivedData/Pico-dhfwbamkhiyphjcwuncbwjsyjlax/Build/Products/Debug -F/Users/laurent/Library/Developer/Xcode/DerivedData/Pico-dhfwbamkhiyphjcwuncbwjsyjlax/Build/ Products/Debug -filelist /Users/laurent/Library/Developer/Xcode/DerivedData/Pico-dhfwbamkhiyphjcwuncbwjsyjlax/Build/Intermediates/Pico.build/Debug/Pico.build/Objects-normal/x86_64/Pico.LinkFileList -mmacosx-version- min=10.8 -o /Users/laurent/Library/Developer/Xcode/DerivedData/Pico-dhfwbamkhiyphjcwuncbwjsyjlax/Build/Products/Debug/Pico

Pico.LinkFileList 文件正确地包含所有必需的 .o 文件的列表。

由于所有未找到的函数都在正确编译的 .c 文件中(并编译为 .o),我应该怎么做才能避免这些错误?谢谢。

4

3 回答 3

1

这些符号在clibrary.c; 您一定在要编译的源文件列表中错过了它。

你的下一个问题无疑是关于链接可执行文件的库,为了解决这个问题,我建议你看看Makefile.

于 2013-09-04T05:55:33.813 回答
1

在同样的情况下,将 Pico 添加到目标依赖项列表对我有用。(来自 Pico 我的意思是我们创建库的 xcode 项目文件夹)

参考: https ://github.com/bulldog2011/pico

于 2016-04-13T09:39:20.983 回答
0

In case it can help someone, I found out that some #ifdef commands were excluding the functions to be compiled.

于 2013-09-04T16:08:10.800 回答