perl_fan has asked for the wisdom of the Perl Monks concerning the following question:
Am though getting one last problem, when am compiling (actually during linking) my program is not able to find out the correct library. is there anything missing?
# gcc -g -o test_socket test_socket.c `perl -MExtUtils::Embed -e cc +opts -e ldopts` /tmp/ccgdPXUT.o(.text+0x34): In function `xs_init': test_socket.c:19: undefined reference to `boot_Socket' collect2: ld returned 1 exit status test_socket.c ============= #include <EXTERN.h> #include <perl.h> static PerlInterpreter *my_perl; static void xs_init (pTHX); EXTERN_C void boot_DynaLoader (pTHX_ CV* cv); EXTERN_C void boot_Socket (pTHX_ CV* cv); EXTERN_C void xs_init(pTHX) { char *file = __FILE__; /* DynaLoader is a special case */ newXS("DynaLoader::boot_DynaLoader", boot_DynaLoader, file); newXS("Socket::bootstrap", boot_Socket, file); } int main(int argc, char **argv, char **env) { PERL_SYS_INIT3(&argc,&argv,&env); my_perl = perl_alloc(); perl_construct(my_perl); PL_exit_flags |= PERL_EXIT_DESTRUCT_END; perl_parse(my_perl, xs_init, argc, argv, (char **)NULL); call_argv("mymethod", G_DISCARD , args); perl_destruct(my_perl); perl_free(my_perl); PERL_SYS_TERM(); } mysocket.pl =========== #!/usr/local/bin/perl use Socket; sub mymethod() { @arr=gethostbyname('localhost'); print "@arr \n"; } running procedure ================= as per the material this binary has to be run like #./test_socket mysocket.pl
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: calling perl from C/C++
by Anonymous Monk on Dec 24, 2008 at 17:03 UTC | |
|
Re: calling perl from C/C++
by Anonymous Monk on Dec 24, 2008 at 16:57 UTC | |
by perl_fan (Novice) on Dec 24, 2008 at 17:54 UTC | |
by Anonymous Monk on Dec 25, 2008 at 03:03 UTC |