CGI/Perl Guide | Learning Center | Forums | Advertise | Login
Site Search: in

  Main Index MAIN
INDEX
Search Posts SEARCH
POSTS
Who's Online WHO'S
ONLINE
Log in LOG
IN

Home: Perl Programming Help: Beginner:
Accessinc C function in Perl

 



sach_1979
Novice

Jul 6, 2009, 1:41 AM

Post #1 of 7 (704 views)
Accessinc C function in Perl Can't Post

Hi,



I am trying to access a c function from a perl script. I have created a test.c which has a function

int add(int a, int b)

{

return (a+b);

}

void main()

{

add(2,3);

}

Now how can I call the "add" function my perl script?



Thanks

Sachin


ichi
User

Jul 6, 2009, 1:50 AM

Post #2 of 7 (701 views)
Re: [sach_1979] Accessinc C function in Perl [In reply to] Can't Post

i am bewildered. what are actually wanting to do?


sach_1979
Novice

Jul 6, 2009, 1:52 AM

Post #3 of 7 (700 views)
Re: [ichi] Accessinc C function in Perl [In reply to] Can't Post

Hi,

I want to call the "add" function in my perl script.

I have a test.pl which will call "add" function.

Thanks

Sachin


ichi
User

Jul 6, 2009, 2:18 AM

Post #4 of 7 (699 views)
Re: [sach_1979] Accessinc C function in Perl [In reply to] Can't Post

i am guessing you what to call a C program from Perl instead. you can use system(), backticks , or open() function. See perldoc perlopentut also.


sach_1979
Novice

Jul 6, 2009, 4:18 AM

Post #5 of 7 (693 views)
Re: [ichi] Accessinc C function in Perl [In reply to] Can't Post

No, the system will execute all the functions called under main.

I just want to call a function which is defined in a .C file from perl script.


ichi
User

Jul 6, 2009, 4:28 AM

Post #6 of 7 (690 views)
Re: [sach_1979] Accessinc C function in Perl [In reply to] Can't Post

i have never heard that you can do that (closest thing to it is extending Perl, ie using C from Perl). But if its still not what you want, then good luck and hope someone else can answer you


(This post was edited by ichi on Jul 6, 2009, 4:36 AM)


shawnhcorey
Enthusiast


Jul 6, 2009, 5:46 AM

Post #7 of 7 (684 views)
Re: [sach_1979] Accessinc C function in Perl [In reply to] Can't Post


In Reply To
Now how can I call the "add" function my perl script?


Accessing C functions from Perl is not considered a beginners question; it is quite complicated. To get you started, I suggest you run `perldoc perl` and read those docs under /Internals and C Language Interface/.

__END__

I love Perl; it's the only language where you can bless your thingy.

Perl documentation is available at perldoc.perl.org. The list of standard modules and pragmatics is available in perlmodlib.

Get Markup Help. Please note the markup tag of "code".

 
 


Search for (options) Powered by Gossamer Forum v.1.2.0

Web Applications & Managed Hosting Powered by Gossamer Threads
Visit our Mailing List Archives