Another followup: If I change main.cpp to read as
follows, the program compiles and runs with the same
makefile as below:
#include <iostream>
#include <mysql++.h>
#include <string_util.h>
#define MY_DATABASE "test"
#define MY_HOST "localhost"
#define MY_USER "user"
#define MY_PASSWORD "pwd"
#define MY_TABLE "fax"
#define MY_KEY "datet" // PRIMARY KEY
#define MY_FIELD "datet" // PRIMARY KEY
int main (int argc, char * const argv[]) {
std::cout << "Hello, World!\n";
std::string s = "34j2l4j//&*";
mysqlpp::Connection c;
//mysqlpp::escape_string(s);
std::cout << s;
c.real_connect(MY_DATABASE, MY_HOST, MY_USER,
MY_PASSWORD, 3306,
(int) 0, 60, NULL);
mysqlpp::Query query = c.query();
query << "SELECT " << MY_FIELD << " FROM " <<
MY_TABLE << " WHERE "
<< MY_KEY << " = " << argv[1];
return 0;
}
?????
Is escape_string for sure in the libmysqlpp.*
libraries? I noticed it's not used in any of the
examples.
???
Thanks again!
jrobinson
--- J Robinson <jrobinson852@stripped> wrote:
> OK, I've stepped back to a simpler situation, just
> trying to build a test app with a Makefile, and I
> get
> the same error.
>
> % cat main.cpp
> #include <iostream>
> #include <mysql++.h>
> #include <string_util.h>
> int main (int argc, char * const argv[]) {
> std::cout << "Hello, World!\n";
> std::string s = "34j2l4j//&*";
> mysqlpp::Connection c; // no complaint here!
> mysqlpp::escape_string(s);
> std::cout << s;
> return 0;
> }
>
> %cat Makefile
> test:
> g++ -g main.cpp -I/usr/local/include
> -I/usr/local/mysql/include -o TEST.exe -lmysqlpp -lm
> -L/usr/local/mysql/lib -lz -lmysqlclient
>
> % make
> g++ -g main.cpp -I/usr/local/include
> -I/usr/local/mysql/include -o TEST.exe -lmysqlpp -lm
> -L/usr/local/mysql/lib -lz -lmysqlclient
> ld: Undefined symbols:
> mysqlpp::escape_string(std::basic_string<char,
> std::char_traits<char>, std::allocator<char> >&)
> make: *** [bin] Error 1
>
>
> I thought that maybe mysql_escape_string didn't wind
> up in the library, but nm shows some variations
> there:
> % nm /usr/local/lib/libmysqlpp.a | grep
> escape_string
> U _mysql_escape_string
> U _mysql_escape_string
> 00000b34 S _Z13escape_stringRSs.eh
> 000001e4 T __Z13escape_stringRSs
>
> Help? I know there must be some g++ option to flip
> to
> make this work. Thanks again for your feedback
> Ovidiu
> and Warren!
>
> --- Ovidiu Bivolaru <ovidiu@stripped>
> wrote:
>
> > Btw, I've didn't used XCode to build MacOS X
> > application with mysql++,
> > but Makefile.
> > You might want to turf off ZeroLink when building
> > the application:
> >
>
http://developer.apple.com/documentation/DeveloperTools/Conceptual/Build_System/Using_ZeroLink/Using_ZeroLink.html
> >
> > Regards,
> > Ovidiu
> >
> > J Robinson wrote:
> >
> > >Thanks for the input, Warren and Ovidiu!
> > >
> > >
> > >--- Warren Young <mysqlpp@stripped> wrote:
> > >
> > >
> > >
> > >>J Robinson wrote:
> > >>
> > >>
> > >>
> > >>>My program (ported from linux to OSX)
> > >>>
> > >>>
> > >>I have yet to get a success report on OS X, so
> > there
> > >>may well be things
> > >>that have to be done to the library to get it to
> > >>work.
> > >>
> > >>
> > >>
> > >>>ZeroLink: unknown symbol '__ZTVN7mysqlpp3RowE'
> > >>>
> > >>>
> > >>That's the only message? I would think you'd
> get
> > a
> > >>bunch of similar
> > >>messages as well.
> > >>
> > >>
> > >>
> > >
> > >Nope, just that one -- reproducibly. But I think
> > the
> > >linker may just be showing the first one.
> > >
> > >I forgot to mention in my last post that I'm
> using
> > >Xcode to build and maintain the project. If need
> be
> > I
> > >can try it with straight Makefiles (ack).
> > >
> > >
> > >
> > >>>What am I doing wrong? Do I need to set
> > >>>LD_LIBRARY_PATH or LDFLAGS or something? (I
> tried
> > >>>those things but it didn't seem to make a
> > >>>
> > >>>
> > >>difference).
> > >>
> > >>Do the examples compile and run?
> > >>
> > >>
> > >
> > >Yeah, they do! (And I'm using the OSX binary
> > install
> > >version of mysql - it does contain
> > libmysqlclient.a,
> > >but no libmysqlclient.dylib).
> > >
> > >This is on OS X 10.3.6 using MySQL 4.0.22. The
> > >examples were built and tested from the command
> > line,
> > >but my app's being built using Xcode.
> > >
> > >On a related note, I found that under Xcode, I'm
> > >unable to get the following code to run:
> > >
> > >#include <iostream>
> > >#include <mysql++.h>
> > >#include <string_util.h>
> > >int main (int argc, char * const argv[]) {
> > > // insert code here...
> > > std::cout << "Hello, World!\n";
> > > std::string s = "34j2l4j//&*";
> > > mysqlpp::escape_string(s);
> > > std::cout << s;
> > > return 0;
> > >}
> > >
> > >If I build in 'deployment' mode, I get:
> > >...
> > >ld: warning prebinding disabled because dependent
> > >library: /usr/local/lib/libmysqlpp.3.dylib is not
> > >prebound
> > >ld: Undefined symbols:
> > >mysqlpp::escape_string(std::basic_string<char,
> > >std::char_traits<char>, std::allocator<char> >&)
> > >
> > >and the program won't start.
> > >
> > >If I build in 'development' mode, the program
> > starts,
> > >but at runtime I get:
> > >
> > >Hello, World!
> > >ZeroLink: unknown symbol
> > >'__ZN7mysqlpp13escape_stringERSs'
> > >(hm, same symbol as above apparently)
> > >
> > >I'm still bangin' my head against this. The
> > relevant
> > >config options from Xcode are:
> > >HEADER SEARCH PATHS: /usr/local/include
> > >/usr/local/mysql/include
> > >LIBRARY SEARCH PATHS: /usr/local/mysql/lib
> > >/usr/local/lib
> > >
> > >OTHER LINKER FLAGS: -lmysqlpp -lmysqlclient
> > >/usr/local/lib/libmysqlpp.a
> > >
> > >What's going wrong?
> > >
> > >
> > >
__________________________________
Do you Yahoo!?
All your favorites on one personal page http://my.yahoo.com