[erlang-questions] ei and erl_interface linking problem on Ubuntu

Hasan Veldstra hasan.veldstra@REDACTED
Thu Mar 6 14:14:53 CET 2008


The following C program compiles without any troubles on two OSX  
machines (Tiger/PPC and Leopard/Intel), but fails to compile on an  
Ubuntu 7.10 machine. All machines have R12B.

~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

#include "ei.h"

int main()
{
     ei_x_buff result;
     long x = 42;

     if(ei_x_new_with_version(&result) || ei_x_encode_tuple_header 
(&result, 2)) {
         return -1;
     }

     ei_x_encode_atom(&result, "ok");
     ei_x_encode_long(&result, x);
     ei_x_free(&result);
     return 0;
}

~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

This is how I compile the program on Macs:
gcc-4.0 -I/opt/local/lib/erlang/lib/erl_interface-3.5.5.3/include - 
lpthread -L/opt/local/lib/erlang/lib/erl_interface-3.5.5.3/lib -lei - 
lerl_interface test.c

And this is how I try to compile it on Ubuntu:
gcc-4.1 -I/usr/lib/erlang/lib/erl_interface-3.5.5.3/include -lpthread  
-L/usr/lib/erlang/lib/erl_interface-3.5.5.3/lib -lei -lerl_interface  
test.c

And this is the error I get:

~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
/tmp/cc26E8ki.o: In function `main':
test.c:(.text+0x1f): undefined reference to `ei_x_new_with_version'
test.c:(.text+0x36): undefined reference to `ei_x_encode_tuple_header'
test.c:(.text+0x56): undefined reference to `ei_x_encode_atom'
test.c:(.text+0x68): undefined reference to `ei_x_encode_long'
test.c:(.text+0x73): undefined reference to `ei_x_free'
collect2: ld returned 1 exit status
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~


Any pointers greatly appreciated.


--Hasan



More information about the erlang-questions mailing list