Conflict between perl DBI & libmysqlclient
rbrown46_at_gmail.com
Date: 01/18/05
- Next message: Dmitry Karasik: "Re: DBD::Pg - send arrays to a stored procedure"
- Previous message: Rudy Lippan: "Re: DBD::Pg - send arrays to a stored procedure"
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
Date: 17 Jan 2005 20:36:26 -0800
I'm developing a C program that embeds perl code for certain things
(using perl_run, perl_parse, perl_destuct, etc.). I ran into a problem
because libmysqlclient is getting used two times: in perl through DBI
and in C, directly. I need to use libmysqlclient in C and I need to
have perl call libmysqlclient through DBI. Because of this conflict,
the program crashes. Below are two source files (perl & C) that will
illustrate the problem. Through I backtrace in gdb I found that the
crash usually occurs while freeing a variable in perl_destruct().
Compile exampleC.c with "gcc -o example exampleC.c `perl
-MExtUtils::Embed -e ccopts -e ldopts`", then run example with
"./example examplePerl.pl" and experience no segmentation faults.
Compile with "gcc -o example exampleC.c `perl -MExtUtils::Embed -e
ccopts -e ldopts` -lmysqlclient", run it with the same command, and
experience a crash.
Any help is greatly appreciated!
Ryan
examplePerl.pl:
#!/usr/bin/perl
use DBI;
use Finance::Quote;
print "Perl code is running";
$dbh = DBI->connect("dbi:mysql:dbname=noname", "user1", "pass1")
or die "Cannot connect to database: $DBI::errstr";
exampleC.c:
#include <EXTERN.h>
#include <perl.h>
#include <sys/types.h>
#include <sys/stat.h>
#include <fcntl.h>
#include <stdio.h>
EXTERN_C void xs_init (pTHX);
EXTERN_C void boot_DynaLoader (pTHX_ CV* cv);
EXTERN_C void
xs_init(pTHX)
{
char *file = __FILE__;
dXSUB_SYS;
/* DynaLoader is a special case */
newXS("DynaLoader::boot_DynaLoader", boot_DynaLoader, file);
}
main(int argc, char **argv, char **env) {
PerlInterpreter *my_perl;
my_perl = perl_alloc();
perl_construct(my_perl);
perl_parse(my_perl, xs_init, argc, argv, env);
perl_run(my_perl);
perl_destruct(my_perl);
perl_free(my_perl);
}
- Next message: Dmitry Karasik: "Re: DBD::Pg - send arrays to a stored procedure"
- Previous message: Rudy Lippan: "Re: DBD::Pg - send arrays to a stored procedure"
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
Relevant Pages
|