You are not logged in.
Pages: 1
Good day.
I am about to write a small IRC bot which shall be controlled by Perl scripts. I am thinking of a scripting interface I know from irssi but all documentation about how to embed Perl are related to C. If I try to do the same thing in C++ my application fails to compile when I include anything else than EXTERN.h and perl.h; for instance iostream.
I read something about libperl++ which seem to be what I need but I don't know where I can get further information. And google seem to be as unaware as me. Except that I want to pull in dependencies as little as possible. It would be great if I just need Perl.
My questions are:
How can I embed Perl into C++?
Can I use the way I would do it in C? (If not, why?)
And I would be even more thankful if you can give me some kind of documentation or how to to get started.
Thanks. (:
harlekin
Hail to the thief!
Offline
Read this: http://www.suckless.org/wiki/tools/irc
IRC: Stalwart @ FreeNode
Skype ID: thestalwart
WeeChat-devel nightly packages for i686
Offline
Thanks. But I am writing this bot in order to learn; not to do something that nobody has done before or that will create a new experience of irc'ing.
If your post was anything else than "Stop it. Somebody has already done it. And this maybe even better.", I apologize and kindly ask where I find the information I asked for. Cannot see anything Perl relating.
But anyway. It was worth reading this code. Looks pretty clean.
Last edited by harlekin (2007-03-05 18:39:51)
Hail to the thief!
Offline
no the thing is ii works off a simple text file, so anything that is capable of reading and writing to a file can use it.
meaning you can just write the bot entirely in perl and just use perl's standard file i/o functions instead of having to figure out how to interface it with whatever.
Offline
That's fine. Definitely.
But my question is, as even summarized in my first post, how to embed Perl into C++. What I was trying to do was just to provide some background information.
Last edited by harlekin (2007-03-06 05:40:42)
Hail to the thief!
Offline
I clearly do not know what you are doing, and read your post about google not having the answer. But to try and wet my tongue I did a simple search and many links came up the first link was about EP and the second is how to add perl to c++. I did not search any farther just posting my google results.
Offline
Thanks. But I am writing this bot in order to learn; not to do something that nobody has done before or that will create a new experience of irc'ing.
If your post was anything else than "Stop it. Somebody has already done it. And this maybe even better.", I apologize and kindly ask where I find the information I asked for. Cannot see anything Perl relating.
But anyway. It was worth reading this code. Looks pretty clean.
No offence, i just offered you a way to write bot in lang you like and don't mess with low-level stuff. IRC protocol is quite boring - a while ago i wrote sample bot in python
IRC: Stalwart @ FreeNode
Skype ID: thestalwart
WeeChat-devel nightly packages for i686
Offline
I know nothing about embedding perl. I do, however, know C++ fairly well. If you could provide complier errors, I could help you figure out what is wrong.
Offline
Sorry that I answer so late. I had much to do the last one and will have the next two or three weeks.
phrakture: I finally was able to compile the first test program from man perlemb:
#include <EXTERN.h>
#include <perl.h>
int main(int argc, char* argv[]) {
PerlInterpreter *my_perl;
my_perl = perl_alloc();
perl_construct(my_perl);
perl_parse(my_perl, NULL, argc, argv, (char**) NULL);
perl_run(my_perl);
perl_destruct(my_perl);
perl_free(my_perl);
return 0;
}
Using this Makefile:
FLAGS=-I/usr/lib/perl5/current/x86_64-linux-thread-multi/CORE -L/usr/lib/perl5/current/x86_64-linux-thread-multi/CORE -lperl -lm -lc -lpthread -lcrypt -ldb -ldl -lnsl -lgdbm -L/usr/local/lib
perlemb: perlemb.cpp
g++ -o perlemb perlemb.cpp $(FLAGS)
But I don't know why it seems that I cannot include other libraries. For example, if I include iostream:
#include <EXTERN.h>
#include <perl.h>
#include <iostream>
/* the rest of the code doesn't change */
I am not able to compile the program. If I type in `make`, I'll get the following errors:
Following errors \o/
Do you have any suggestions?
junglepeanut: Thanks. I'll check this out too. But as I want to keep the dependencies low, I'll try first to do it with standard libraries. (:
Last edited by harlekin (2007-03-11 11:47:53)
Hail to the thief!
Offline
Looks like those errors are do to craptacular perl C macros (but I don't know the exact errors, as I can't translate that).... try adding iostream *before* the perl headers
Offline
Thank you! That actually did the trick! (=
Sorry, I didn't recognize that the error output was in German.
Hail to the thief!
Offline
Pages: 1