[erlang-questions] Problems with C Erlang interface
J Bhanot
j.bhanot@REDACTED
Wed Jan 30 14:26:10 CET 2008
Hi,
Got the solution :
to compile : gcc -c
-I/usr/local/lib/erlang/lib/erl_interface-3.5.5.3/include test.c
to link : gcc -L/usr/local/lib/erlang/lib/erl_interface-3.5.5.3/lib/
test.o -lerl_interface -lei -lpthread -o test'
to execute : ./test
:-)
Thanks,
jb
____________________________________________
"Jachym Holecek" <jachym.holecek@REDACTED>
01/30/2008 06:39 PM
To
"J Bhanot" <j.bhanot@REDACTED>, "Tomas Pihl" <tomas.pihl@REDACTED>
cc
erlang-questions@REDACTED
Subject
Re: [erlang-questions] Problems with C Erlang interface
On Wed, 30 Jan 2008 13:09:43 +0100, J Bhanot <j.bhanot@REDACTED> wrote:
> [root@REDACTED otp_src_R12B-0]# cc -o test
> -I/usr/local/lib/erlang/lib/erl_interface-3.5.5.3/include
> -L/usr/local/lib/erlang/lib/erl_interface-3.5.5.3/lib -lerl_interface
> -lei
> test.c
>
> got the following error -
>
> /tmp/ccAvr8jd.o: In function `main':
> test.c:(.text+0x28): undefined reference to `erl_init'
> collect2: ld returned 1 exit status
> [root@REDACTED otp_src_R12B-0]#
To quote gcc(1):
[explanation of '-l' option]
It makes a difference where in the command you write this option; the
linker searches and processes
libraries and object files in the order they are specified. Thus,
foo.o
-lz bar.o searches library
z after file foo.o but before bar.o. If bar.o refers to functions in
z,
those functions may not be
loaded.
So you might try to put the arguments in different order:
[root@REDACTED otp_src_R12B-0]# cc -o test \
-I/usr/local/lib/erlang/lib/erl_interface-3.5.5.3/include \
-L/usr/local/lib/erlang/lib/erl_interface-3.5.5.3/lib \
test.c \
-lerl_interface \
-lei
(FWIW the 'erl_init' symbol is defined in liberl_interface.a)
> Also, i tried
>
> [root@REDACTED otp_src_R12B-0]# ld
> -L/usr/local/lib/erlang/lib/erl_interface-3.5.5.3/lib test.o
> -lerl_interface -lei -lpthread -o test
Using ld(1) requires you to know exactly what you're doing. Normally,
you want to let [g]cc(1) compile & link your program (it will invoke ld(1)
internally with the correct options).
HTH,
-- Jachym
ForwardSourceID:NT0000DFFE
=====-----=====-----=====
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
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://erlang.org/pipermail/erlang-questions/attachments/20080130/2fae6bef/attachment.htm>
More information about the erlang-questions
mailing list