Warning: file_get_contents(/data/phpspider/zhask/data//catemap/4/c/59.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181

Warning: file_get_contents(/data/phpspider/zhask/data//catemap/4/jquery-ui/2.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
C Erlang NIF测试——OSX狮子_C_Gcc_Erlang_Erlang Nif - Fatal编程技术网

C Erlang NIF测试——OSX狮子

C Erlang NIF测试——OSX狮子,c,gcc,erlang,erlang-nif,C,Gcc,Erlang,Erlang Nif,我试图在MacOSXLion上从Erlang()编译NIF测试。我无法编译它。我是否缺少编译器标志?下面是我得到的错误: Computer:~ me $ gcc -fPIC -shared -o niftest.so niftest.c -I /usr/local/Cellar/erlang/R14B02/lib/erlang/usr/include/ Undefined symbols for architecture x86_64: "_enif_make_string", refere

我试图在MacOSXLion上从Erlang()编译NIF测试。我无法编译它。我是否缺少编译器标志?下面是我得到的错误:

Computer:~ me $ gcc -fPIC -shared -o niftest.so niftest.c -I /usr/local/Cellar/erlang/R14B02/lib/erlang/usr/include/
Undefined symbols for architecture x86_64:
  "_enif_make_string", referenced from:
      _hello in ccXfh0oG.o
ld: symbol(s) not found for architecture x86_64
collect2: ld returned 1 exit status
我也用
-m32
尝试过,但它说也没有i386架构


谢谢

您的问题似乎不是架构,而是未定义的符号
\u enif\u make\u string
,这意味着您必须使用
-l
选项链接
enif
库。另外,我已经很久没有为OS X构建共享库了,但我认为正确的标志是
-dynamiclib
,而不是
-shared
,并且在编译nif时,您不必在
-I

之后留有空格,而不是-shared>尝试使用这些标志

-bundle -flat_namespace -undefined suppress

对于64位Erlang,以下内容适用于我:

gcc -undefined dynamic_lookup -dynamiclib niftest.c -o niftest.so \
    -I /usr/local/Cellar/erlang/R14B02/lib/erlang/usr/include

如果我有
#include
指令和-I标志,这难道不足以引用include文件吗?查看链接。谢谢@特拉维斯鲍威尔:不,
#include
仅用于编译,而不用于链接。您的错误在链接中,请参阅
ld:sym…
。这是链接器错误。它是动态查找!谢谢:)非常感谢你的回答:)