Error: Cannot parse function definition from ' hello()' in Mytest.xs, line 9
I am trying to use perl XS in RHEL 5. but simple programm is giving error.I followed same code as in Example 1 in perldoc perlxstut
Can anyone help me in correcting the following error?
[root@localhost Mytest]# [root@localhost Mytest]# pwd /home/nikole/perlcode/Mytest [root@localhost Mytest]# ls blib lib MANIFEST Mytest.xs pm_to_blib README Changes Makefile.PL Mytest.c Mytest.xsc ppport.h t [root@localhost Mytest]# perl Makefile.PL Checking if your kit is complete... Looks good Writing Makefile for Mytest [root@localhost Mytest]# [root@localhost Mytest]# [root@localhost Mytest]# make /usr/bin/perl /usr/lib/perl5/5.8.8/ExtUtils/xsubpp -typemap /usr/lib/perl5/5.8.8/ExtUtils/typemap Mytest.xs > Mytest.xsc && mv Mytest.xsc Mytest.c Error: Cannot parse function definition from ' hello()' in Mytest.xs, line 9 Please specify prototyping behavior for Mytest.xs (see perlxs manual) make: *** [Mytest.c] Error 1 [root@localhost Mytest]#
Thanks Ryan. I removed white spaces between void
and hello
, and it solved the problem. After editing, my Mytest.xs
looks like
#include "EXTERN.h"
#include "perl.h"
#include "XSUB.h"
#include "ppport.h"
MODULE = Mytest PACKAGE = Mytest
void
hello()
CODE:
printf("Hello, world!\n");
Update
Hi Ryan & cjm, I resolved error in doing make as above but my perl programm is giving error now " use: command not found"
Any ideas?
[root@localhost Mytest]# [root@localhost Mytest]# [root@localhost Mytest]# perl Makefile.PL Checking if your kit is complete... Looks good Writing Makefile for Mytest [root@localhost Mytest]# [root@localhost Mytest]# [root@localhost Mytest]# make gcc -c -I. -D_REENTRANT -D_GNU_SOURCE -fno-strict-aliasing -pipe -Wdeclaration-after-statement -I/usr/local/include -D_LARGEFILE_SOURCE -D_FILE_OFFSET_BITS=64 -I/usr/include/gdbm -O2 -g -pipe -Wall -Wp,-D_FORTIFY_SOURCE=2 -fexceptions -fstack-protector --param=ssp-buffer-size=4 -m32 -march=i386 -mtune=generic -fasynchronous-unwind-tables -DVERSION=\"0.01\" -DXS_VERSION=\"0.01\" -fPIC "-I/usr/lib/perl5/5.8.8/i386-linux-thread-multi/CORE" Mytest.c Running Mkbootstrap for Mytest () chmod 644 Mytest.bs rm -f blib/arch/auto/Mytest/Mytest.so gcc -shared -O2 -g -pipe -Wall -Wp,-D_FORTIFY_SOURCE=2 -fexceptions -fstack-protector --param=ssp-buffer-size=4 -m32 -march=i386 -mtune=generic -fasynchronous-unwind-tables -L/usr/local/lib Mytest.o -o blib/arch/auto/Mytest/Mytest.so \ 开发者_StackOverflow中文版 \ chmod 755 blib/arch/auto/Mytest/Mytest.so cp Mytest.bs blib/arch/auto/Mytest/Mytest.bs chmod 644 blib/arch/auto/Mytest/Mytest.bs Manifying blib/man3/Mytest.3pm [root@localhost Mytest]# [root@localhost Mytest]# [root@localhost Mytest]# [root@localhost Mytest]# cat hello #! /usr/bin/perl -w use ExtUtils::testlib; use Mytest; Mytest::hello(); [root@localhost Mytest]# [root@localhost Mytest]# cat hello #! /usr/bin/perl -w use ExtUtils::testlib; use Mytest; Mytest::hello(); [root@localhost Mytest]# [root@localhost Mytest]# ls -l hello -rwxrwxrwx 1 root root 87 Apr 8 04:01 hello [root@localhost Mytest]# [root@localhost Mytest]# [root@localhost Mytest]# ./hello ./hello: line 2: use: command not found ./hello: line 3: use: command not found ./hello: line 4: syntax error near unexpected token `;' ./hello: line 4: ` Mytest::hello();' [root@localhost Mytest]#
Update
thanks Ryan, removed white spaces between void and hello it solved problem After editing , my Mytest.xs looks like
#include "EXTERN.h"
#include "perl.h"
#include "XSUB.h"
#include "ppport.h"
MODULE = Mytest PACKAGE = Mytest
void
hello()
CODE:
printf("Hello, world!\n");
In your Mytest.xs remove the whitespace in front of hello();
Update: Your new problem, "command not found..." doesn't sound like Perl is running your program. I think it may be from whitespace before "#!/usr/bin/perl" in hello.
精彩评论