<br><font size=2 face="sans-serif">Hi,</font>
<br>
<br><font size=2 face="sans-serif">Got the solution :</font>
<br>
<br><font size=2 face="sans-serif">to compile : gcc -c -I/usr/local/lib/erlang/lib/erl_interface-3.5.5.3/include
test.c</font>
<br><font size=2 face="sans-serif">to link : gcc -L/usr/local/lib/erlang/lib/erl_interface-3.5.5.3/lib/
test.o -lerl_interface -lei -lpthread -o test'</font>
<br><font size=2 face="sans-serif">to execute : ./test </font>
<br>
<br><font size=2 face="sans-serif">:-)</font>
<br>
<br><font size=2 face="sans-serif">Thanks,</font>
<br><font size=2 face="sans-serif">jb</font>
<br><font size=2 face="sans-serif"><br>
____________________________________________</font>
<br>
<br>
<br>
<table width=100%>
<tr valign=top>
<td width=40%><font size=1 face="sans-serif"><b>"Jachym Holecek"
<jachym.holecek@e-fractal.cz></b> </font>
<p><font size=1 face="sans-serif">01/30/2008 06:39 PM</font>
<td width=59%>
<table width=100%>
<tr valign=top>
<td>
<div align=right><font size=1 face="sans-serif">To</font></div>
<td><font size=1 face="sans-serif">"J Bhanot" <j.bhanot@tcs.com>,
"Tomas Pihl" <tomas.pihl@ericsson.com></font>
<tr valign=top>
<td>
<div align=right><font size=1 face="sans-serif">cc</font></div>
<td><font size=1 face="sans-serif">erlang-questions@erlang.org</font>
<tr valign=top>
<td>
<div align=right><font size=1 face="sans-serif">Subject</font></div>
<td><font size=1 face="sans-serif">Re: [erlang-questions] Problems with
C Erlang interface</font></table>
<br>
<table>
<tr valign=top>
<td>
<td></table>
<br></table>
<br>
<br>
<br><font size=2><tt>On Wed, 30 Jan 2008 13:09:43 +0100, J Bhanot <j.bhanot@tcs.com>
wrote:<br>
> [root@localhost otp_src_R12B-0]# cc -o test<br>
> -I/usr/local/lib/erlang/lib/erl_interface-3.5.5.3/include<br>
> -L/usr/local/lib/erlang/lib/erl_interface-3.5.5.3/lib -lerl_interface
<br>
> -lei<br>
> test.c<br>
><br>
> got the following error -<br>
><br>
> /tmp/ccAvr8jd.o: In function `main':<br>
> test.c:(.text+0x28): undefined reference to `erl_init'<br>
> collect2: ld returned 1 exit status<br>
> [root@localhost otp_src_R12B-0]#<br>
<br>
To quote gcc(1):<br>
<br>
[explanation of '-l' option]<br>
It makes a difference where in the command you write this option;
the <br>
linker searches and processes<br>
libraries and object files in the order they are specified. Thus,
foo.o <br>
-lz bar.o searches library<br>
z after file foo.o but before bar.o. If bar.o refers to functions
in z, <br>
those functions may not be<br>
loaded.<br>
<br>
So you might try to put the arguments in different order:<br>
<br>
[root@localhost otp_src_R12B-0]# cc -o test \<br>
-I/usr/local/lib/erlang/lib/erl_interface-3.5.5.3/include \<br>
-L/usr/local/lib/erlang/lib/erl_interface-3.5.5.3/lib \<br>
test.c \<br>
-lerl_interface \<br>
-lei<br>
<br>
(FWIW the 'erl_init' symbol is defined in liberl_interface.a)<br>
<br>
> Also, i tried<br>
><br>
> [root@localhost otp_src_R12B-0]# ld<br>
> -L/usr/local/lib/erlang/lib/erl_interface-3.5.5.3/lib test.o<br>
> -lerl_interface -lei -lpthread -o test<br>
<br>
Using ld(1) requires you to know exactly what you're doing. Normally,<br>
you want to let [g]cc(1) compile & link your program (it will invoke
ld(1)<br>
internally with the correct options).<br>
<br>
HTH,<br>
-- Jachym<br>
<br>
</tt></font>
<br><font size=1 color=white face="sans-serif">ForwardSourceID:NT0000DFFE
</font>
<br><pre>=====-----=====-----=====
Notice: The information contained in this e-mail
message and/or attachments to it may contain
confidential or privileged information. If you are
not the intended recipient, any dissemination, use,
review, distribution, printing or copying of the
information contained in this e-mail message
and/or attachments to it are strictly prohibited. If
you have received this communication in error,
please notify us by reply e-mail or telephone and
immediately and permanently delete the message
and any attachments. Thank you
</pre>