List:MySQL++« Previous MessageNext Message »
From:Steve Ong Date:February 2 2011 8:46pm
Subject:Patch fix for compile problem in Cygwin and Linux Fedora 14
View as plain text  
Hi all,

I just downloaded mysql++-3.1.0 and tried to compile on Cygwin (CYGWIN_NT-5.1 i686) and
Linux Redhat Fedora 14.
I encountered a number of problems during the build. I've fixed them and created a patch
(attached with this email) in hope that someone could help me to source these fixes into
the source repository.

Let me explain what are the problems and how this patch fixed them...

1. Problem with ssx/genv2.cpp:
Somewhere in ssx/genv2.cpp using 'strcmp', but didn't include <cstring>. Added:
#include <cstring>
... into ssx/genv2.cpp


2. Problem linking 'ssqlsxlat' and 'test_ssqls2':
Bot the 'ssqlsxlat' and 'test_ssqls2' were linked like the following...

g++ -o ssqlsxlat.exe ssqlsxlat_genv2.o ssqlsxlat_main.o    -L.
-lmysqlclient_r   -lz -L/mysql-5.5.8/lib -Wl,--enable-auto-import 
-lmysqlpp -lmysqlpp_ssqls2parse  -lintl

...And

g++ -o test_ssqls2.exe test_ssqls2_ssqls2.o    -L.
-lmysqlclient_r   -lz -L/mysql-5.5.8/lib -Wl,--enable-auto-import -lmysqlpp
-lmysqlpp_ssqls2parse  -lintl

...The problem is:

There are some source code in libmysqlpp_ssqls2parse.a library calling functions from
classes in libmysqlpp.a. By the time the linker is ready to link these functions,
libmysqlpp.a was already unloaded. Thus, one will see 'undefined function..." errors from
g++ linking

Fixes:

I reverse the order of -lmysqlpp -lmysqlpp_ssqls2parse  (now it becomes
-lmysqlpp_ssqls2parse -lmysqlpp) in "Makefile.in" (configure uses the content of this
file to generate 'Makefile') for these two instances

3. problem compile/link 'cpool'

Here is the error message I saw while compiling 'cpool_cpool.o':

g++ -c -o cpool_cpool.o -Ilib     -pthread
-I/projects/mysqlDeploy/mysql-5.5.8/include -g -O2 ./examples/cpool.cpp

g++ -o cpool cpool_cpool.o    -L. -lmysqlclient_r  
-L/projects/mysqlDeploy/mysql-5.5.8/lib  -lmysqlpp_excommon -lmysqlpp

/usr/bin/ld: cpool_cpool.o: undefined reference to symbol 'pthread_create@@GLIBC_2.1'
/usr/bin/ld: note: 'pthread_create@@GLIBC_2.1' is defined in DSO /lib/libpthread.so.0 so
try adding it to the linker command line
/lib/libpthread.so.0: could not read symbols: Invalid operation
collect2: ld returned 1 exit status
make: *** [cpool] Error 1

...As you can see, -pthread was in the WRONG PLACE (honestly, I saw this problem all over
'Makefile.in'. It's amazing that this is the only executable that's complained)

Fixes:

I agreed wholeheartedly with g++ that '-pthread' has no business be where cpool_cpool.o
being compiled, and the rightful place for it to be is when 'cpool' (the executable)
being linked. So I've moved -pthread in this particular case.
Frankly speaking, I think all other should be moved also (except, there are many of them!)

Anyhow, now that you know what I've fixed. It's you call to whether you want to include
this patch into the release.

Happy coding,
Steven




      
Attachment: [text/html]
Thread
Patch fix for compile problem in Cygwin and Linux Fedora 14Steve Ong2 Feb
  • Re: Patch fix for compile problem in Cygwin and Linux Fedora 14Jonathan Wakely2 Feb
  • Re: Patch fix for compile problem in Cygwin and Linux Fedora 14Warren Young3 Feb
  • Re: Patch fix for compile problem in Cygwin and Linux Fedora 14Remi Collet3 Feb