Hello,
  I am trying to call a perl function that will use DBI from c++.   This is what I have included for that (in c++) as suggested by perl documentation:
#ifdef cplusplus #define EXTERN_C extern "C" #else #define EXTERN_C extern #endif extern "C" { # include "EXTERN.h" // from the Perl distribution # include "perl.h" } EXTERN_C { void boot_DynaLoader _((CV* cv)); void boot_DBI _((CV* cv)); void boot_DBD__mysql _((CV* cv)); } static void xs_init(){ newXS("DynaLoader::boot_DynaLoader", boot_DynaLoader, __FILE__); newXS("DBI::bootstrap", boot_DBI, __FILE__); newXS("DBD::mysql::bootstrap", boot_DBD__mysql, __FILE__); }
but when I compile the c++ like this:
g++ -g -o dbChg dbWrapper.cc -Wno-deprecated `perl -MExtUtils::Embed - +e ccopts -e ldopts`
I got errors as the following:
/tmp/cccNMAhR.o: In function `void __iter_swap<char *, char *, char>(c +har *, char *, char *)': /usr/include/g++-3/stl_iterator.h(.text+0x29): undefined reference to +`boot_DBI' /usr/include/g++-3/stl_iterator.h(.text+0x43): undefined reference to +`boot_DBD__mysql' collect2: ld returned 1 exit status
It is gcc 2.96 with perl 5.6.1 under linux redhat.   Could you please give me some hint to make it work? Thank you so much.
  christine

janitored by ybiC: <code> tags around code block as per Monastery convention, fix minor format faux paus


In reply to question about loading dbi when calling perl from c++ by christine

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post, it's "PerlMonks-approved HTML":



  • Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
  • Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
  • Read Where should I post X? if you're not absolutely sure you're posting in the right place.
  • Please read these before you post! —
  • Posts may use any of the Perl Monks Approved HTML tags:
    a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
  • You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
            For:     Use:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  • See Writeup Formatting Tips and other pages linked from there for more info.