Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Erlang NIF Test -- OS X Lion

I'm trying to compile the NIF Test from Erlang (http://www.erlang.org/doc/man/erl_nif.html) on Mac OS X Lion. I can't get it to compile. Am I missing a compiler flag? Here's the error I get:

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

I've also tried this with -m32 but it says there's no i386 architecture either.

Thanks!

like image 989
batman Avatar asked Nov 27 '11 19:11

batman


1 Answers

for 64-bit Erlang, the following works for me:

gcc -undefined dynamic_lookup -dynamiclib niftest.c -o niftest.so \
    -I /usr/local/Cellar/erlang/R14B02/lib/erlang/usr/include
like image 136
butter71 Avatar answered Dec 03 '22 21:12

butter71