f



Embedding Perl in C/C++: help needed!

I am a veteran Perl user, but a newbie embedder. I am trying to figure 
out the best way to solve a problem I have. Please read along--any 
advice is appreciated.

TASK: I am talking to a networked camera via HTTP, and the URLs I need 
to send and the requests I get back are a variety of fairly complicated 
and not always consistent text strings. THE GOAL: I need to interface 
with the camera from a C/C++ program.

APPROACH: the camera came with a hard-copy manual that spelled out all 
the camera params and commands, syntax, etc. I slapped all the info into 
a config file in my own white-space-delimited column format that is 
pretty simple to read and understand.  As far as parsing goes, I figure 
there are 4 general approaches I could have taken:

1. Hack something together using sscanf, strtok, and their ilk, and not 
have it robust, but get it working quickly. NOT AN OPTION.

2. Do it "right" in C using lex/yacc, bison/flex, etc.  I have done 
parsers in this manner, but generally takes longer than using a Perl 
approach, and you have to debug the grammar corner cases, etc.

3. Embed Perl into the C program and use Perl for all the text munging. 
Has the added advantage of being flexible, not having to recompile when 
config file changes, yada.

4. Do the config file in standardized text format like XML, and it may 
not be too readable to humans, but I am sure there are some free 
libraries that will parse it easily and hand me my data in C nicely.

COMMENTS WELCOME on which approach is best...but I chose 3.

Now to the Perl question:

PERL EMBEDDING: I read the manual and got ExtUtils::Embed working just 
fine. I created 3 simple classes: perl_hash, perl_array, and 
perl_scalar, in C++, and wrote a simple wrapper class that contains the 
Perl interpreter and has one method -- call(). You can call any perl 
function you like, hand it a C++ perl_array (@_) that you've filled 
inside C/C++ and get back a perl_array as a result from call() after it 
invokes Perl. It works great, and I was very proud of myself for taking 
a general embedding approach that would work in mutliple projects! But....

PROBLEM: the problem is that I just let ExtUtils::Embed spew out all the 
compile and link flags that I used for building, and when I run the 
executable on another machine, it barfs with different messages about 
shared libararies (depending on machine on which it is run), with  2 
representative error messages being:

cperltest: error while loading shared libraries: libperl.so: cannot open 
shared object file: No such file or directory

cperltest: /lib/i686/libc.so.6: version `GLIBC_2.3' not found (required 
by cperltest)


QUESTIONS:

I have a basic understanding of what shared libraries are and how they 
work, but I am not knowledgable about GLIBC compatibilities, or about 
the "best" way to attain the following goal: I want someone to be able 
to write a C/C++ program that links against my Cperl library, and as far 
as they are concerned, it will just work.

1. Is this possible?

2. Could someone please give me a short primer on the way that GCC build 
env, user environment (e.g. LD_LIBRARY_PATH), and Perl environment (how 
Perl was built, etc), all influence what the "right" answer is to 
solving this problem?  All these issues have me confused!

3. What approach should I take? The ground rules are that all the boxes 
I am working with will all have basically same O/S -- all Red Hat boxes 
that look pretty much like

Linux 2.4.20-19.7smp #1 SMP Tue Jul 15 13:34:04 EDT 2003 i686 unknown

but they may have slightly different Perl versions installed in slightly 
different places. SHould I compile everything statically so that my 
cperl.a essentially contains a stand-alone Perl?  How would I go about 
doing this if it's possible?

4. How do you figure out what shared libraries an executable depends on?

5. How do you statically compile an executable (gcc version 3.2.3) so 
that it depends on NOTHING?

6. Should I even try to compile statically, or can I somehow keep things 
the way they are, and just have everyone add a few things to their 
LD_LIBRARY_PATH on my behalf?  Any philosophical and pratical help would 
be great...


Any and all help is so greatly appreciated!  Thanks!


Steve











0
titus (6)
4/30/2004 10:35:40 PM
comp.lang.perl.modules 4194 articles. 0 followers. jerrykrinock (6) is leader. Post Follow

1 Replies
818 Views

Similar Articles

[PageSpeed] 55

Stephen Titus wrote:
> I am a veteran Perl user, but a newbie embedder. I am trying to figure 
> out the best way to solve a problem I have. Please read along--any 
> advice is appreciated.
> 
> TASK: I am talking to a networked camera via HTTP, and the URLs I need 
> to send and the requests I get back are a variety of fairly complicated 
> and not always consistent text strings. THE GOAL: I need to interface 
> with the camera from a C/C++ program.
> ...

If you don't feel comfortable embedding perl, you can use an 
stand alone perl server (instead of in-process) running as an 
adapter between the camera and your C++ program. You can use 
XML-RPC (or similar) as an easy way to get your C++ program 
talking to that server.

  http://xmlrpc-c.sourceforge.net/xmlrpc-howto/xmlrpc-howto.html

- Salvador.
0
salvafg (5)
5/2/2004 8:56:17 PM
Reply:

Similar Artilces:

install_driver(Oracle) failed: Can't load 'C:/Perl/site/lib/auto/DBD/Oracle/Oracle.dll' for module DBD::Oracle: load_file:The specified procedure could not be found at C:/Perl/lib/DynaLoader.pm line 2
hello i have a strange problem with DBI module. has anyone any clue about what is wrong here? my connection string: --------------------- use DBI; use DBD::ODBC; use DBI qw(:sql_types); use strict; use warnings; my $db = "something"; my $user = 'XXX'; my $passwd = 'XXX'; my $dbh = DBI->connect('dbi:Oracle:XXX', $user,$passwd, {RaiseError => 1, AutoCommit => 0}) or die $DBI::errstr; ################# This gives the foll...

google trends on java,c#,perl,c++,c
http://google.com/trends?q=java%2Cc%23%2Cperl%2Cc%2B%2B%2Cc&ctab=0&date=all&geo=all Java and C show big. Perl, C++, C# show small. Opalinski opalpa@gmail.com http://www.geocities.com/opalpaweb/ ...

Help needed with a C++ syntax (legal in C, but not C++)
Greetings, I'm trying to use a vender-supplied API in my C++ program. The vender's API is in C and it contains something similar to: type int INT; struct S { int i; double INT; /* OK in C, not C++ */ } According to a C/C++ book (C, A reference manual by S Harbison and G. Steele JR), the above struct is actually legal in C, as typedef names can be redeclared as objects in inner scopes. However, in C++ it is not permitted to do so within a structure or union -- which are scopes -- if the original typedef name has been used in the structure or union already. The problem I'm f...

!!! need to write an agent in C++ or C
Hi All, I'm newbie in SNMP. I NEED to write snmp agent in c++ or c for solaris. Is there a free agent toolkit available on SUN.com site? I know that there is a JDMK available. Is there any other toolkit (on SUN.com)? If no, can I use JDMK to develop an agent in c++ or c language? I'm not interested in AdventNet toolkit. BTW: is this good toolkit? Help me please, Thanks. Regards P miniu wrote: > I NEED to write snmp agent in c++ or c for solaris. Do you need to write one from scratch, or can you build on existing software? You might like to have a l...

Better C/C++ Than C/C++?
I am looking for a good systems programming language that can be used instead of C/C++. My qualifications for the language are: * mature compiler(s) that produce native-code binaries (for Windows) * open source - preferable, but not 100% necessary Thanks, Kevin "Kevin Albrecht" <kevin@albrecht.net> writes: > I am looking for a good systems programming language > that can be used instead of C/C++. My qualifications > for the language are: > > * mature compiler(s) that produce native-code > binaries (for Windows) Ocaml, D, cyclone, Eiffel, Beta > * open source - preferable, but not 100% necessary what's wrong with using C? Friedrich > what's wrong with using C? Too low level, no built-in garbage collection. -- Kevin "Kevin Albrecht" <kevin@albrecht.net> writes: >> what's wrong with using C? > > Too low level, Well the Smalltalk people say, have a small language and a big library. I assume C's library status beyond that of Smalltalk. > no built-in garbage collection. Use the Boehm Weisser GC. Friedrich "Kevin Albrecht" <kevin@albrecht.net> wrote in message news:<2TiYb.237892$rj7.1641209@twister.tampabay.rr.com>... > I am looking for a good systems programming language > that can be used instead of C/C++. My qualifications > for the language are: > > * mature compiler(s) that produce native-code > binaries (for Windows) > ...

Perl MakeMaker
Hi, I'm building a Perl extension (dll in Windows XP) using ExtUtils::MakeMaker. This dll needs to link with other libraries that were built in static mode (-MTd). My perl configuration states dynamic libraries (-MD) which causes MakeMaker to pull a dynamic C library (msvcrtd.dll). The other libraries are using the static C library (libcmtd.lib) These dynamic and static C libraries collide giving link errors. Is there a way to force perl to compile with (-MTd) albeit its configuration flags? I tried reinstalling Perl (ActiveState perl v5.8.8 built for MSWin32- x86-multi-thread) but didn't see an option to control the configuration flags. Also, my platform supports both dynamic (-MD) and static (-MTd) builds. Does this mean that I have to maintain two versions of Perl? Thanks, Avner Avi wrote: > Hi, > > I'm building a Perl extension (dll in Windows XP) using > ExtUtils::MakeMaker. > This dll needs to link with other libraries that were built in static > mode (-MTd). > My perl configuration states dynamic libraries (-MD) which causes > MakeMaker to pull a dynamic C library (msvcrtd.dll). > The other libraries are using the static C library (libcmtd.lib) > These dynamic and static C libraries collide giving link errors. > > Is there a way to force perl to compile with (-MTd) albeit its > configuration flags? > I tried reinstalling Perl (ActiveState perl v5.8.8 built for MSWin32- > x86-multi-thread) but didn't ...

I need help with xerces-c and xalan-c, please help -------------------------------
I am new to Xerces, Xalan and C++ but not to XML and XSL. I have been looking at the example but they are over my head. <doc> <item type="x"></item> <item type="y"></item> <item type="z"></item> .... <!-- I need to add/remove <item/> here --> </doc> Any help is appreciated. Thanks. -Tamim ...

Perl MakeMaker
Hi, I'm building a Perl extension (dll in Windows XP) using ExtUtils::MakeMaker. This dll needs to link with other libraries that were built in static mode (-MTd). My perl configuration states dynamic libraries (-MD) which causes MakeMaker to pull a dynamic C library (msvcrtd.dll). The other libraries are using the static C library (libcmtd.lib) These dynamic and static C libraries collide giving link errors. Is there a way to force perl to compile with (-MTd) albeit its configuration flags? I tried reinstalling Perl (ActiveState perl v5.8.8 built for MSWin32- x86-multi-thread) but didn&...

Re: Calling R, C, C++, C#, Java, Python, Perl, #2
Alan, I found it much easier to process un-structured data in Perl then feed the cleaned, summarized data to SAS. You get the best of both languages when you proceed as suggested, and it takes considerably less time to finish the project. Now, I know a few very good SAS programmers who know all the substleties of string parsing in SAS and can do with SAS what I do with Perl, as easily. But I'm not one of them. Vincent PS: one of my colleagues believe that un-structured data is a thing of the past. In a few years, all data (even messages posted on usenet) will be structured. At 07:28 PM 8/25/2008, Alan Churchill wrote: >Vincent, > >Let's look at the process. > >SAS produces a dataset after a lot of processing. You don't need a 3rd party >calling a 3rd to do something. > >Read a SAS dataset directly using the FREE SAS OleDb driver. Once it is in >memory, manipulate to your heart's content and then write it back out to the >source you need it to go in. > >Pluses? > >Minimal steps reduce the surface area. > >Alan > >Alan Churchill >Savian >www.savian.net > > >-----Original Message----- >From: SAS(r) Discussion [mailto:SAS-L@LISTSERV.UGA.EDU] On Behalf Of Vincent >Granville >Sent: Monday, August 25, 2008 8:03 PM >To: SAS-L@LISTSERV.UGA.EDU >Subject: Calling R, C, C++, C#, Java, Python, Perl, etc. from a SAS program > >What about a Perl script calling SAS, R, C++, C# etc. ...

Experts on embedding Perl in C wanted: Weird problem on RH7.3/Perl 5.6.1
Hi, I'm tearing my hair out on this one. I'm trying to embed a Perl interpreter into a C program. I need to be able to create and destroy the interpreter periodically, but will never actually have two interpreters at the same time. On Red Hat Linux 7.3 with Perl 5.6.1, the attached program segfaults. On Red Hat 9 with Perl 5.8.0, it works perfectly. Save the program code as "test-embed-perl.c" and the build script as "buildte". Then run: sh buildte ./te to see the behaviour. Enlightenment is appreciated! :-( A gdb stacktrace shows this: $...

embeding perl in C++
Hi, It seem libperl can be used to embed perl in C++. But that was developed long ago and is for C. I'm wondering if there are any new and better library to embed perl in C++. Thanks, Peng Peng Yu wrote: > It seem libperl can be used to embed perl in C++. But that was > developed long ago and is for C. I'm wondering if there are any new > and better library to embed perl in C++. On the one hand, embedding *modern* Perl (5.10) is straight- forward and easy if you know the pitfalls. On some projects, I link the perl core to C++-programs, this works fine in Visual Studio 6 up...

Embedding Perl into C: Why?
Hi, I've browsed perlembed, the Books (Llama, Camel, Bighorn), the perl faqs and google-groups -- but still seek more compelling rationale(s) (versus how-to's) for embedding the Perl interpreter into a C program. I'm not arguing against it; rather looking for use-case justifications. Some possible rationales: 1. Obtain regular expression processing; but why not instead link against a C regex function library? 2. Endow a C program with scriptable behaviors communicated via external Perl scripts -- presumably the latter are more readily prototyped/expressed. The downside might ...

Calling R, C, C++, C#, Java, Python, Perl, etc. from a SAS program
What about a Perl script calling SAS, R, C++, C# etc. rather than SAS calling these languages? Wouldn't it be easier? What are the pluses / minuses? I'm used to write Perl scripts to pre-process messy data (text mining) and produce summary tables, then feed the clean summary tables to SAS. What do SAS engineers think about this strategy? Feel free to reply on http://www.analyticbridge.com/group/sasandstatisticalprogramming Unstructured data will always be with us since people communicate in an unstructured way. Will the unstructured section be held within a structured framework? Sure, I can see that. Alan Alan Churchill Savian www.savian.net -----Original Message----- From: Vincent Granville [mailto:vincentg@datashaping.com] Sent: Monday, September 01, 2008 11:19 AM To: Alan Churchill; SAS-L@LISTSERV.UGA.EDU Subject: RE: Calling R, C, C++, C#, Java, Python, Perl, etc. from a SAS program Alan, I found it much easier to process un-structured data in Perl then feed the cleaned, summarized data to SAS. You get the best of both languages when you proceed as suggested, and it takes considerably less time to finish the project. Now, I know a few very good SAS programmers who know all the substleties of string parsing in SAS and can do with SAS what I do with Perl, as easily. But I'm not one of them. Vincent PS: one of my colleagues believe that un-structured data is a thing of the past. In a few years, all data (even messages posted on usenet) will be structu...

C, C++ and Perl Workshops by NYLXS
While we have some summer off time I'm going to lead 3 workshops for beginners through the NYLXS Mailing List at hangout@nylxs.com We will be doing Introduction to C Programming using the book C Programming: A Modren Approach by K.N.King I'll be developing C programming notes on line as we go. This book is fairly intensive Also we will do Perl Porgramming using the Perl Programming Notes of NYLXS on http://www.nylxs.com/docs/perlcourse/ I'll be reediting these notes as we go, but they are fairly complete as they are Finally, we will be learning C++ with ...

C, C++ and Perl Workshops with NYLXS
While we have some summer off time I'm going to lead 3 workshops for beginners through the NYLXS Mailing List at hangout@nylxs.com We will be doing Introduction to C Programming using the book C Programming: A Modren Approach by K.N.King I'll be developing C programming notes on line as we go. This book is fairly intensive Also we will do Perl Porgramming using the Perl Programming Notes of NYLXS on http://www.nylxs.com/docs/perlcourse/ I'll be reediting these notes as we go, but they are fairly complete as they are Finally, we will be learning C++ with the text C++ Prim...

Books on C/C++ for perl programmers
There are many books on "perl for C/C++ programmers" but none for "C/C+ + for perl programmers". Does anyone know of any such book or tutorial? Thanks in advance, >Hanna< On Apr 28, 4:27=A0am, l0cl <taurusgemini...@gmail.com> wrote: > + for perl programmers". Does anyone know of any such book or > tutorial? I don't think that they are any, but that's not a problem. There are many, many books on C and C++, and we each have our favorites. I can vouch personally for a dozen or so, but I won't. Most of them will probably get you into C or...

Calling R, C, C++, C#, Java, Python, Perl, etc. from a SAS program #2
What about a Perl script calling SAS, R, C++, C# etc. rather than SAS calling these languages? Wouldn't it be easier? What are the pluses / minuses? I'm used to write Perl scripts to pre-process messy data (text mining) and produce summary tables, then feed the clean summary tables to SAS. What do SAS engineers think about this strategy? Anybody has thoughts on this? Feel free to reply on http://www.analyticbridge.com/group/sasandstatisticalprogramming Vincent, Let's look at the process. SAS produces a dataset after a lot of processing. You don't need a 3rd party calling a 3rd to do something. Read a SAS dataset directly using the FREE SAS OleDb driver. Once it is in memory, manipulate to your heart's content and then write it back out to the source you need it to go in. Pluses? Minimal steps reduce the surface area. Alan Alan Churchill Savian www.savian.net -----Original Message----- From: SAS(r) Discussion [mailto:SAS-L@LISTSERV.UGA.EDU] On Behalf Of Vincent Granville Sent: Monday, August 25, 2008 8:03 PM To: SAS-L@LISTSERV.UGA.EDU Subject: Calling R, C, C++, C#, Java, Python, Perl, etc. from a SAS program What about a Perl script calling SAS, R, C++, C# etc. rather than SAS calling these languages? Wouldn't it be easier? What are the pluses / minuses? I'm used to write Perl scripts to pre-process messy data (text mining) and produce summary tables, then feed the clean summary tables to SAS. What do SAS engineers think about this st...

Needed Sr. C / C++ / C# developer !
A leading financial institution is seeking a C / C++ / C#/.Net software developer with 5 to 6 years of programming experience to develop, test and support new and existing mission-critical global trading applications. mailto:prominc@yahoo.ca ...

Needed Sr. C / C++ / C# developer !
A leading financial institution is seeking a C / C++ / C#/.Net software developer with 5 to 6 years of programming experience to develop, test and support new and existing mission-critical global trading applications. mailto:prominc@yahoo.ca ...

C/C++, Perl, etc. to Python converter
Is there a Perl to Python converter? Or in general: a XY to Python converter? Is see, that Python is much better then Perl anyway. But for beginners, they whant to konw how is this done with Python etc. Sure, there are some docus out there in the internet. But a converter? mm wrote: > > Is there a Perl to Python converter? > Or in general: a XY to Python converter? > > Is see, that Python is much better then Perl anyway. > But for beginners, they whant to konw how is this done with Python etc. > > Sure, there are some docus out there in the internet. But a conve...

C, C++ and Perl Programming Workshops from NYLXS
While we have some summer off time I'm going to lead 3 workshops for beginners through the NYLXS Mailing List at hangout@nylxs.com We will be doing Introduction to C Programming using the book C Programming: A Modren Approach by K.N.King I'll be developing C programming notes on line as we go. This book is fairly intensive Also we will do Perl Porgramming using the Perl Programming Notes of NYLXS on http://www.nylxs.com/docs/perlcourse/ I'll be reediting these notes as we go, but they are fairly complete as they are Finally, we will be learning C++ with the text C++ Prime...

Help Needed: C/C++ Standard Libraries
Hi. I am starting to learn C++ and am curious to find out if there are any Word documents or PDF files that list all of the standard libraries, the functions contained within them, a short description of them, and how to use them. Basically, what is listed on www.cplusplus.com under the reference area. It would be a major help to have a hard copy reference list on hand that lists all of this data. Thanks in advance... DV [ See http://www.gotw.ca/resources/clcm.htm for info about ] [ comp.lang.c++.moderated. First time posters: Do this! ] da Vinci wrote: > I am start...

ATTENTION:
NONE I am a highly qualified consultant looking for a contract mission or a turn-key project in the following domains: - Software development using C/C++/C#, Java, and Perl - UML-OO Anlysis and Design - RDBMS/SQL Modelling and Implementation (Oracle, DB2, Informix, Sybase, InterBase) - Unix/Linux based system architecture and cross-platform development - Unix to/from Windows XP/NT system ports. - IT Audits. With kind regards. sdev@bluewin.ch wrote in message news:<3f13994e_3@news.bluewin.ch>... > NONE > I am a highly qualified consultant looking for a contract miss...

Help is needed for C program compiled by C++
Hi, I need your help. I have a legend C program that works well after it was compiled under Visial Studio 6. Now a new version of Visial Studio 2005, V8 is installed on my machine. And I failed to generate its *.exe file. What I have done is: 1. Create a project under C++; 2. Select 32-bit window console project; 3. Add my *.c files into it. 4. Compile it. Error information: When I included statement: #include "stdafx.h" Error information: Error 1 fatal error C1853: 'Debug\Filter.pch' precompiled header file is from a previous version of the compiler, or the precompiled ...

Web resources about - Embedding Perl in C/C++: help needed! - comp.lang.perl.modules

Whitney embedding theorem - Wikipedia, the free encyclopedia
), if m > 0 . This is the best linear bound on the smallest-dimensional Euclidean space that all m -dimensional manifolds embed in, as the real ...

Improved Embedding Tools: Embedded Video Player API and oEmbed support
Launch of embedded video API and oEmbed support for facebook videos and posts

Instagram adds web embedding, makes sharing content on the web easier
... its platform beyond its mobile applications. Today, the photo sharing application has made it easier to share photos and videos with web embedding. ...

School transforms a generation by embedding Indigenous culture into its curriculum
From Indigenous dolls in the childcare centre to a discussion of the treatment of Adam Goodes, embedding Indigenous culture into the curriculum ...


Apple uploads individual iPhone 6 and Apple Watch promo videos to YouTube for your embedding pleasure ...
... iPhone 6 , and YouTube . What do you think? Discuss "Apple uploads individual iPhone 6 and Apple Watch promo videos to YouTube for your embedding ...

Instagram Adds Web Embedding in Bid for Real-Time Relevance
The real-time battle rages on. Instagram on Wednesday announced the latest in a string of recent updates, now allowing users to embed videos ...

The new Android Central Photography forums are open and feature Photosphere embedding
A great place to talk about the camera on your Android phone, and share the great pictures you take with it

Apple granted patent for embedding sapphire displays in LiquidMetal iPhone chassis
The U.S. Patent and Trademark Office on Tuesday issued Apple a patent describing a process in which an iPhone's display glass including sapphire ...

MPAA "embedding is infringement" theory rejected by court
Judge Posner A federal appeals court has decisively rejected a legal theory that would have placed anyone who embeds a third-party video on ...

Resources last updated: 3/24/2016 9:02:32 AM