无法在mac上编译C应用程序

时间:2017-02-15 00:37:59

标签: c xcode macos

我需要一位了解Mac版SDK的C开发人员帮助。我尝试使用命令

创建一个c可执行文件
./configure --enable-shared

我需要--enabled-shared才能重新发布我的二进制文件。

我偶然发现了这个编译错误。其他人可以详细说明此错误消息。

gcc -DNDEBUG -g -fwrapv -O3 -Wall -Wstrict-prototypes
-L/usr/local/opt/openssl/lib Parser/acceler.o Parser/grammar1.o Parser/listnode.o Parser/node.o Parser/parser.o Parser/parsetok.o Parser/bitset.o Parser/metagrammar.o Parser/firstsets.o Parser/grammar.o Parser/pgen.o Objects/obmalloc.o Python/mysnprintf.o Python/pyctype.o Parser/tokenizer_pgen.o Parser/printgrammar.o Parser/pgenmain.o -ldl  -framework CoreFoundation -o Parser/pgen
    Undefined symbols for architecture x86_64:
      "__PyMem_DebugFree", referenced from:
          _PyTokenizer_Free in tokenizer_pgen.o
          _tok_nextc in tokenizer_pgen.o
      "__PyMem_DebugMalloc", referenced from:
          _tok_new in tokenizer_pgen.o
          _PyTokenizer_FromFile in tokenizer_pgen.o
          _new_string in tokenizer_pgen.o
          _tok_nextc in tokenizer_pgen.o
          _PyOS_Readline in pgenmain.o
      "__PyMem_DebugRealloc", referenced from:
          _tok_nextc in tokenizer_pgen.o
          _PyOS_Readline in pgenmain.o
      "__PyObject_DebugFree", referenced from:
          _getgrammar in pgenmain.o
    ld: symbol(s) not found for architecture x86_64
    clang: error: linker command failed with exit code 1 (use -v to see invocation)
    make: *** [Parser/pgen] Error 1

我的xcode已安装并且是最新的。

$ xcode-select --install

xcode-select: error: command line tools are already installed, use "Software Update" to install updates

1 个答案:

答案 0 :(得分:0)

我做了一个make distclean,然后用这个标志运行make。

LD_RUN_PATH=/usr/local/lib make

它迫使编译器查看/usr/local/lib并帮助我构建共享库。