Cmake linking to mysql & curl, LNK2019 - mysql

Ok so I just started playing around with CMake. I'm trying to build a project which has dependencies on both MySQL and CURL. This is the directory structure:
./
./src
./cmake
CMakeLists.txt
It's really that simple, src only contains 9 Cpp files and a CMakeLists.txt.
When running CMake, everything works fine. I just get a bunch of linker errors due to MySQL and CURL not being effectively linked. What am I doing wrong ?
Root CMakeLists.txt:
PROJECT(IRCBot)
INCLUDE(CPack)
SET(CMAKE_MODULE_PATH ${CMAKE_SOURCE_DIR}/cmake)
INCLUDE(${CMAKE_SOURCE_DIR}/cmake/FindCURL.cmake)
CMAKE_MINIMUM_REQUIRED(VERSION 2.6 FATAL_ERROR)
FIND_PACKAGE(CURL)
IF(CURL_FOUND)
MESSAGE(STATUS "Curl libraries found at: ${CURL_LIBRARIES}")
MESSAGE(STATUS "Curl includes found at: ${CURL_INCLUDE_DIRS}")
else()
MESSAGE(SEND_ERROR "Could not find cURL on your system")
ENDIF(CURL_FOUND)
FIND_PACKAGE(MySQL)
IF(MYSQL_FOUND)
MESSAGE(STATUS "MySQL found at: ${MYSQL_INCLUDE_DIR}, ${MYSQL_LIBRARIES}")
ELSE(MYSQL_FOUND)
MESSAGE(SEND_ERROR "Couldn't find MySQL include files and/or library")
ENDIF(MYSQL_FOUND)
ADD_SUBDIRECTORY(src)
And ./src/CMakeLists.txt
FILE(GLOB_RECURSE IRCBot_files *.cpp *.h)
SET(IRCBot_src
${IRCBot_files}
)
INCLUDE_DIRECTORIES(
${CURL_INCLUDE_DIRS}
${MYSQL_INCLUDE_DIR}
)
LINK_DIRECTORIES(
${MYSQL_LIBRARIES}
${CURL_LIBRARIES}
)
ADD_EXECUTABLE(IRCBot ${IRCBot_src})
INSTALL(TARGETS IRCBot DESTINATION ${INSTALL_DIR}/bin)

You don't need LINK_DIRECTORIES() call in this case, since it tells compiler where to find libs.
Instead, use
TARGET_LINK_LIBRARIES(IRCBot
${MYSQL_LIBRARIES}
${CURL_LIBRARIES})
because ${MYSQL_LIBRARIES} contains absolute paths.

Related

libtool can't find the la when linking with option -L

I met the problem when compiling the source code of mpc which will depend on gmp.
The command to compile mpc is as below.
./configure --with-mpfr=/home/wy/tmp/mpfr-4.0.2/ins --with-gmp=/home/wy/tmp/gmp-6.2.0/ins --prefix=/home/wy/tmp/mpc-1.1.0/ins
The gmp has been installed into /home/user/tmp/gmp-6.2.0/ins successfully.
The error when compiling mpc with libtool is as below.
/bin/bash ../libtool --tag=CC --mode=link gcc -std=gnu99 -O2 -pedantic -fomit-frame-pointer -m64 -mtune=corei7 -march=corei7 -version-info 4:0:1 -L/home/wy/tmp/gmp-6.2.0/ins/lib -L/home/wy/tmp/mpfr-4.0.2/ins/lib -o libmpc.la -rpath /home/wy/tmp/mpc-1.1.0/ins/lib abs.lo acos.lo acosh.lo add.lo add_fr.lo add_si.lo add_ui.lo arg.lo asin.lo asinh.lo atan.lo atanh.lo clear.lo cmp.lo cmp_abs.lo cmp_si_si.lo conj.lo cos.lo cosh.lo div_2si.lo div_2ui.lo div.lo div_fr.lo div_ui.lo exp.lo fma.lo fr_div.lo fr_sub.lo get_prec2.lo get_prec.lo get_version.lo get_x.lo imag.lo init2.lo init3.lo inp_str.lo log.lo log10.lo mem.lo mul_2si.lo mul_2ui.lo mul.lo mul_fr.lo mul_i.lo mul_si.lo mul_ui.lo neg.lo norm.lo out_str.lo pow.lo pow_fr.lo pow_ld.lo pow_d.lo pow_si.lo pow_ui.lo pow_z.lo proj.lo real.lo rootofunity.lo urandom.lo set.lo set_prec.lo set_str.lo set_x.lo set_x_x.lo sin.lo sin_cos.lo sinh.lo sqr.lo sqrt.lo strtoc.lo sub.lo sub_fr.lo sub_ui.lo swap.lo tan.lo tanh.lo uceil_log2.lo ui_div.lo ui_ui_sub.lo -lmpfr -lmpfr -lgmp -lm
/bin/grep: /usr/local/lib/libgmp.la: No such file or directory
/bin/sed: can't read /usr/local/lib/libgmp.la: No such file or directory
libtool: error: '/usr/local/lib/libgmp.la' is not a valid libtool archive
Makefile:432: recipe for target 'libmpc.la' failed
make[2]: *** [libmpc.la] Error 1
make[2]: Leaving directory '/home/wy/tmp/mpc-1.1.0/src'
Makefile:465: recipe for target 'all-recursive' failed
make[1]: *** [all-recursive] Error 1
make[1]: Leaving directory '/home/wy/tmp/mpc-1.1.0'
Makefile:375: recipe for target 'all' failed
make: *** [all] Error 2
From the error message, we can see that the lib path has been indicated as -L/home/wy/tmp/gmp-6.2.0/ins/lib. But libtool still can't find the lib.
This is going to be hard to answer easily, but it seems like you have some other .la file that references it, and causes it to fail this way. Paths within .la files are always absolute. See this old blog post of mine for details.
My best guess for your particular case, is that you have an old copy of mpfr installed in /usr/local — and that is taking precedence over the one you want to use.
The problem appears to be in the MPFR configure scripts or makefile, not in MPC!
As you can see above, it's not looking for libgmp.la in the place you specified on the command-line, but in the default installation location. The reason for this is that the location of libgmp.la is specified incorrectly in libmpfr.la! It's not MPC's fault...
I was able to work around the problem by editing libmpfr.la, which you can find where you specified the MPFR libraries to go, and change the location to libgmp.la from /usr/lib/libgmp.la to the actual location where you targeted the GMP libraries.
The line in libgmp.la should look like this:
# Libraries that this one depends upon.
dependency_libs=' -L/your/mpfr/lib/target /your/gmp/lib/target/libgmp.la
Where "/your/mpfr/lib/target" should be where you told MPFR to put its library files, and "/your/gmp/lib/target" needs to be changed to where you told GMP to put its library files.

TYPO3 error configuring extension "sphinx"

I've installed latest sphinx version 2.3.1.
I have TYPO3 CMS 6.2.19.
Before sphinx can be used it must be configured. Now in sphinx configuration area I click on Sphinx 1.4.5. After some time I get following message:
Sphinx 1.4.5 has been downloaded.
Could not extract Sphinx 1.4.5:
Could not extract 3rd-party libraries for Sphinx:
Archive: /opt/lampp/htdocs/cms1/typo3temp/sphinx-contrib.zip
Inconsistency detected by ld.so: dl-open.c: 596: _dl_open: Assertion `_dl_debug_initialize (0, args.nsid)->r_state == RT_CONSISTENT' failed!
Could not find a compatible version of Pygments
I could debug this extension and found out it crashes at following command:
CommandUtility::exec("'/usr/bin/unzip' '/opt/lampp/htdocs/cms1/typo3temp/sphinx-contrib.zip' -d '/opt/lampp/htdocs/cms1/uploads/tx_sphinx/sphinx-contrib' 2>&1", $out, $returnValue);
If I execute it from a php-one-line script I get following message:
lchmod (file attributes) error: Function not implemented
Does anybody understand what is wrong with it???
OK. I've found a workaround myself: it were libraries. So I had to preload another versions.
All in all, the way is: in the file where unzip is called (Setup.php) in the function unarchive add LD_PRELOAD=/lib64/libgcc_s.so.1:/usr/lib64/libstdc++.so.6 before unzip command. Now it looks as follows:
$cmd = 'LD_PRELOAD=/lib64/libgcc_s.so.1:/usr/lib64/libstdc++.so.6 ' . $unzip . ' ' . escapeshellarg($archiveFileName) ...
And yes, it is not the best solution, but it worked for me.

pycuda -- error: command 'x86_64-pc-linux-gnu-g++' failed with exit status 1

i installed sabayon linux and i tried to install pycuda but i am receiving the following error when i try
su -c "make install"
In file included from src/cpp/cuda.cpp:1:0: src/cpp/cuda.hpp:12:18:
fatal error: cuda.h: No such file or directory compilation terminated.
error: command 'x86_64-pc-linux-gnu-g++' failed with exit status 1
I must mention that i can compile with cuda.
The same happens and when i try with
sudo -E sh -c "make install"
My .bashrc is :
# Put your fun stuff here.
export PATH=~/bin:$PATH
export PATH=$PATH:$HOME/Matlab_2010b/bin
export PATH=/opt/cuda/bin:$PATH
export LD_LIBRARY_PATH=/opt/cuda/lib64:$LD_LIBRARY_PATH
export CUDA_ROOT=/opt/cuda/bin
(When i do echo $PATH as user it shows me : /opt/cuda/bin but when i try it as root it doesn't show anything and i had to do export PATH...again in order to show.)
You have CUDA installed in a non-standard path and the PyCUDA installer doesn't know how to find the toolkit headers it needs to compile. As per the installation instructions, you need to do something like this:
python configure.py --cuda-root=/opt/cuda
then
su -c "make install"
this will ensure that the compilation can find the necessary driver API headers to build the support libraries and hardcode all the right paths into the PyCUDA python libraries so that everything works correctly.

Installation error for DBD::MySQL on OSX v10.6.6

I'm attempting to get DBD::MySQL working on Snow Leopard (v10.6.6). The default version of Perl that comes with the OS is v5.10.0. Since I've read that's 64-bit, I went ahead and downloaded and installed a 64-bit version of MySQL (mysql-5.5.8-osx10.6-x86_64).
Installing and setting up MySQL went smoothly, here's my config and version number for reference.
I used CPAN to download DBI and the DBD::MySQL drivers. I then:
Installed DBI
Setup a Makefile.PL
Ran the make command from the command line
The Makefile.PL said it would use the following settings for compiling and testing:
I will use the following settings for compiling and testing:
cflags (mysql_config ) = -I/usr/local/mysql/include -Os -g -fno-common -fno-strict-aliasing -arch x86_64
embedded (mysql_config ) =
libs (mysql_config ) = -L/usr/local/mysql/lib -lmysqlclient -lpthread
mysql_config (guessed ) = mysql_config
nocatchstderr (default ) = 0
nofoundrows (default ) = 0
ssl (guessed ) = 0
testdb (default ) = test
testhost (default ) =
testpassword (User's choice) = r00t!
testsocket (default ) =
testuser (User's choice) = root
To change these settings, see 'perl Makefile.PL --help' and
'perldoc INSTALL'.
Multiple copies of Driver.xst found in: /Library/Perl/5.10.0/darwin-thread-multi-2level/auto/DBI/ /System/Library/Perl/Extras/5.10.0/darwin-thread-multi-2level/auto/DBI/ at Makefile.PL line 907
Using DBI 1.616 (for perl 5.010000 on darwin-thread-multi-2level) installed in /Library/Perl/5.10.0/darwin-thread-multi-2level/auto/DBI/
Writing Makefile for DBD::mysql
Everything seemed to be going fine, until I tried to run make test :
t/00base....................NOK 2/6# Tried to use 'DBD::mysql'.
# Error: Can't load '/Users/swm/.cpan/build/DBD-mysql-4.018-Pnd2qz/blib/arch/auto/DBD/mysql/mysql.bundle' for module DBD::mysql: dlopen(/Users/swm/.cpan/build/DBD-mysql-4.018-Pnd2qz/blib/arch/auto/DBD/mysql/mysql.bundle, 2): Library not loaded: libmysqlclient.16.dylib
# Referenced from: /Users/swm/.cpan/build/DBD-mysql-4.018-Pnd2qz/blib/arch/auto/DBD/mysql/mysql.bundle
# Reason: image not found at /System/Library/Perl/5.10.0/darwin-thread-multi-2level/DynaLoader.pm line 207.
# at (eval 7) line 2
# Compilation failed in require at (eval 7) line 2.
# BEGIN failed--compilation aborted at (eval 7) line 2.
FAILED--Further testing stopped: Unable to load DBD::mysql
make: *** [test_dynamic] Error 9
It's failing because it can't seem to find the mysql.bundle for DBD. Has anyone come across this problem? Or can point me in the right direction on what to try next? I need DBI/DBD::MySQL for my new job and I'm scrambling to find a solution.
Many thanks in advance.
I got around the "Library not loaded: libmysqlclient.16.dylib" problem by placing a symbolic link in /usr/lib/" to /usr/local/mysql-5.5.8-osx10.6-x86_64/lib/libmysqlclient.16.dylib
I worked around the same or a similar issue. Somehow I could build and test DBD::mysql with cpan but when I tried to use it in a script it said things like
dyld: lazy symbol binding failed: Symbol not found: _mysql_init
Referenced from: /Library/Perl/5.10.0/darwin-thread-multi-2level/auto/DBD/mysql/mysql.bundle
Expected in: flat namespace
Apparently, it's a 64-bit vs 32-bit issue.
Installing the fink dbd-mysql-pm5100 package made it work though it took kind of a long time. I also removed the cpan-installed version:
sudo rm -rf /Library/Perl/5.10.0/darwin-thread-multi-2level/auto/DBD/mysql
sudo rm -rf /Library/Perl/5.10.0/darwin-thread-multi-2level/DBD/mysql
sudo rm -rf /Library/Perl/5.10.0/darwin-thread-multi-2level/DBD/mysql.pm
also include in .profile
export VERSIONER_PERL_PREFER_32_BIT=yes;
Besides creating the link the executions of the program with DBI::mysql generated an error, thus including this variable on the environment make it works
I know this is an old post. But I suppose the best solution would be to add the library directory to the DYLD_FALLBACK_LIBRARY_PATH env variable. (reason here: https://stackoverflow.com/a/3172515/119958 )
There is no ldconfig in mac, so just add the path to this env var and rerun the install process for DBD::mysql
Donato-Vianas-MacBook-Pro:Invoicer donato$ cpanm DBD::mysql
--> Working on DBD::mysql
Fetching http://www.cpan.org/authors/id/C/CA/CAPTTOFU/DBD-mysql-4.022.tar.gz ... OK
Configuring DBD-mysql-4.022 ... OK
Building and testing DBD-mysql-4.022 ... FAIL
! Installing DBD::mysql failed. See /Users/donato/.cpanm/build.log for details.
# Failed test 'use DBD::mysql;'
# at t/00base.t line 21.
# Tried to use 'DBD::mysql'.
# Error: Can't load '/Users/donato/.cpanm/work/1359948144.491/DBD-mysql-4.022/blib/arch/auto/DBD/mysql/mysql.bundle' for module DBD::mysql: dlopen(/Users/donato/.cpanm/work/1359948144.491/DBD-mysql-4.022/blib/arch/auto/DBD/mysql/mysql.bundle, 2): Library not loaded: libmysqlclient.18.dylib
Donato-Vianas-MacBook-Pro:Invoicer donato$ export DYLD_FALLBACK_LIBRARY_PATH=/usr/local/mysql/lib/:$DYLD_FALLBACK_LIBRARY_PATH
Donato-Vianas-MacBook-Pro:Invoicer donato$ cpanm DBD::mysql--> Working on DBD::mysql
Fetching http://www.cpan.org/authors/id/C/CA/CAPTTOFU/DBD-mysql-4.022.tar.gz ... OK
Configuring DBD-mysql-4.022 ... OK
Building and testing DBD-mysql-4.022 ... OK
Successfully installed DBD-mysql-4.022
1 distribution installed
Donato's solution works for install, but the var has to be present at runtime as well or I get the same error. The following fixes this at runtime for shell and _www user:
# For command line use, add following line to ~/.bash_profile:
export DYLD_FALLBACK_LIBRARY_PATH=/usr/local/mysql/lib/:$DYLD_FALLBACK_LIBRARY_PATH
# If Apache needs it, add following line to /etc/apache2/httpd.conf:
# On Lion Server, I put it after <IfDefine MACOSXSERVER>, but shouldn't matter
SetEnv DYLD_FALLBACK_LIBRARY_PATH /usr/local/mysql/lib/:$DYLD_FALLBACK_LIBRARY_PATH
It's somewhat of an aside, but I strongly recommend setting up a separate perl on the machine -- either by fink / macports, or from source -- and leaving the Mac's system perl (and its libraries) alone.
Once I did this on my own Mac, I had very few troubles installing modules thereafter, and I didn't have to worry about accidentally blowing a hole in my OS by breaking the perl that the system uses.
If it were my Mac, I'd install a new perl from source (the Perl source distribution is smart enough to install itself see that it's on a Mac and install itself safely into /usr/local/bin) and the proceed from thee to install DBD::Mysql (and the other modules you require).

Win7 MInGW QT MySQL program screams "cannot find -lqsqlmysqld"; where is the missing library?

I am attempting to make a qt program on Windows 7 that uses a MySQL plugin.
I have compiled both qt and the mysql plugin with no problems using my minGW 32bit compiler.
However, I keep on getting an error like this:
mingw32-make -f Makefile.Debug
mingw32-make[1]: Entering directory `C:/Users/dhatt/Desktop/testdb2'
g++ -c -g -frtti -fexceptions -mthreads -Wall -DUNICODE -DQT_LARGEFILE_SUPPORT -DQT_DLL -DQT_SQL_LIB -DQT_GUI_LIB -DQT_CORE_LIB -DQT_THREAD_SUPPORT -DQT_NEEDS_QMAIN - I"..\..\..\..\QT\qt\include\QtCore" -I"..\..\..\..\QT\qt\include\QtGui" -I"..\..\..\..\QT\qt\include\QtSql" -I"..\..\..\..\QT\qt\include" -I"..\..\..\..\MySQL\bin" -I"..\..\..\..\QT\qt\include\ActiveQt" -I"debug" -I"..\..\..\..\QT\qt\mkspecs\win32-g++" -o debug\database.o database.cpp
g++ -enable-stdcall-fixup -Wl,-enable-auto-import -Wl,-enable-runtime-pseudo-reloc -mthreads -Wl -Wl,-subsystem,windows -o debug\testdb2.exe debug/database.o -L"c:\QT\qt\lib" -lmingw32 -lqtmaind -L C:\MySQL\lib\opt -LC:/QT/qt/plugins/sqldrivers -lqsqlmysqld -lQtSqld4 -lQtGuid4 -lQtCored4 -LC:\MySQL\lib\opt
C:/qt/mingw/bin/../lib/gcc/mingw32/4.4.0/../../../../mingw32/bin/ld.exe: cannot find -lqsqlmysqld
collect2: ld returned 1 exit status
mingw32-make[1]: *** [debug\executable.exe] Error 1
mingw32-make[1]: Leaving directory `C:/Users/dhatt/Desktop/testdb2'
mingw32-make: *** [debug] Error 2
I apologize in advance for being very verbose of what I did, but I am doing this partly for troubleshooting, and partly so any other lost souls don't end up wasting three weeks on this particular problem. :)
Here are my specs:
Windows 7 Nokia's Open Source QT
Qt SDK for Windows (C:\Qt\2010.04\qt)
Linux MinGW Version 5.1.6 (C\Linux\MinGW)
MySQL5 with C++ files (C:\MySQL5)
If you want to know how I installed qt, just follow this site's instructions:
http://www.jiggerjuice.net/software/qt-sql-drivers.html
These other sites may hold some extra information tidbits:
http://doc.qt.nokia.com/4.6/sql-driver.html
http://www.rag.com.au/linux/qt4howto.html
http://qtnode.net/wiki?title=Qt4_on_Windows (yes, I did check with Nokia's docs!!!)
http://doc.trolltech.com/qq/qq10-windows-deployment.html
This fellow mentioned about remaking qmake, which I am not doing unless I have a good reason.
http://christopher.rasch-olsen.no/2009/04/14/qt-45-and-mysql-plugin-with-mingw-on-windows-xp/
I've already deleted the plugin cache once before, I hope I won't have to do it again...
http://doc.trolltech.com/4.2/plugins-howto.html#the-plugin-cache
http://ubuntuforums.org/showthread.php?t=1070155
If there is any confusion, between the two compilation option (creating the mysql libraries statically, or as a plugin), I chose for the plugin because it compiles quicker and I don't have to worry about licensing.
Generally, the big trouble of mysql to most people is to make a mingw compatible library. Generally, I did this with the mingw tools in ( https://olex.openlogic.com/packages/mingw-utils )...
c:\> cd MySQL\lib\opt
c:\mysql\lib\opt> reimp -d libmysql.lib
c:\mysql\lib\opt> dlltool --input-def libmysql.def --dllname libmysql.dll --output-lib libmysql.a -k
I should have done it right since in my C:\MySQL\lib\opt, it has the two files:
libmysql.a
libmysql.lib
LIBMYSQL.def (not a typo)
and in the C:\MySQL\bin directory, I have:
libmySQL.bin (not a typo)
I had compiled the mysql plugin beforehand:
cd %QTDIR%\src\plugins\sqldrivers\mysql
qmake "INCLUDEPATH+=C:\MySQL\include" "LIBS+=C:\MYSQL\lib\opt\libmysql.lib" mysql.pro
mingw32-make
As a result, I have in my C:\QT\qt\plugins\sqldrivers folder:
libqsqlmysql4.a
libqsqlmysqldq4.a
libqsqlodbc4.a
libqsqlodbcd4.a
qsqlmysql4.dll
qsqlmysqld4.dll
qsqlodbc4.dll
qsqlodbc4.dll
And in my C:\QT\bin folder
QtSql4.dll
QtSqld4.dll
So, I assume from this site ( http://www.qtforum.org/article/21352/how-to-compile-use-a-mysql-driver.html) that I got it right.
I didn't use the binaries of qt itself, I used the compiled qt files(also from Nokia), but reconfigured and recompiled them using mingw32-make. I had no errors. This was my configuration options for remaking qt.
-opensource
-nomake examples
-nomake demos
-no-sql-lite
-no-qt3support
-no-gif
-no-libpng
-no-libmng
-no-libtiff
-no-phonon
-no-phonon-backend
-no-multimedia
-no-audio-backend
-no-webkit
-no-script
-no-scripttools
-nodeclarative
-plugin-sql-mysql -l mysql -I C:\QT\qt\include -L C:\QT\qt\lib\opt
Here is my .pro file
LANGUAGE = C++
TEMPLATE = app
TARGET = executable
QT += core sql
QTPLUGIN += qsqlmysql
DEPENDPATH += .
INCLUDEPATH += C:\MySQL\bin
LIBS += -L C:\MySQL\lib\opt -lmysql
# Input
SOURCES += database.cpp
I installed the plugin described in here:
C:\QT\qt
My path variables are:
%SystemRoot%\system32;%SystemRoot%;%SystemRoot%\System32\Wbem;%SYSTEMROOT%\System32\WindowsPowerShell\v1.0\;C:\Program Files (x86)\QuickTime\QTSystem\;C:\Python26;C:\Linux\Cygwin\bin;C:\mingw-utils-0.3\bin;C:\QT\qt\bin;C:\MySQL\bin;C:\MySQL\include;C:\QT\mingw32\bin;C:\QT\mingw\bin;C:\QT\qt\plugins\sqldrivers
The qt command prompt added a few extra though, so I did all of this in the command prompt.
Setting up a MinGW/Qt only environment...
-- QTDIR set to C:\QT\qt
-- PATH set to C:\QT\qt\bin
-- Adding C:\QT\bin to PATH
-- Adding C:\Windows\System32 to PATH
-- QMAKESPEC set to win32-g++ (mingw is my only compiler so, this is unnecessary)
Although I either did all that already, or it is redundant. I only add this for the sake of completeness.
Here is my code (database.cpp):
#include <QtSql>
#include <iostream>
using namespace std;
int main( int argc, char ** argv )
{
QSqlDatabase db = QSqlDatabase::addDatabase("QMYSQL");
db.setHostName("---.---.---.---");
db.setDatabaseName("--------");
db.setUserName("------------");
db.setPassword("------------");
if (!db.open()) cout << "Failed to connect to mysql" << endl;
else cout << "Works finally." << endl;
QSqlDatabase::removeDatabase("QMYSQL");
exit ( 0 );
}
Very simple, yes?
I went to my directory with the example code, run
mingw32-make distclean
qmake
mingw32-make
and get the error message above. I've tried building a version with the release version only (no debug), and it still shows the same message, but with "cannot find -lqsqlmysq", so it is not that.
I've tried many things, but where should I look next to solve it; maybe someone can narrow it down for me, set me on the right path, or even better, solve his annoying problem.
Also, I plan to use python bindings with my code (I need PyQT + MySQL). If the proposed solution would prevent me from doing so, let me know.
Well, I'm going to solve my own problem, again, so let's make this fun!
This is your last chance.
After this, there is no turning back.
You download the PyQT.exe, the story ends. You wake up in your bed and you believe whatever you want to believe. You modify the .pro file, you stay in wonderland. And, I show you how deep the rabbit hole goes.
I eventually gave up and downloaded the .exe, which does have MySQL support out of the box. If mysql does not work, your application is the problem, and I recommend you read this post here ( http://lists.trolltech.com/qt-interest/2006-06/thread00292-0.html ) or follow the quote below:
The issue is that you either have to
use the addLibraryPath method or
create a QCoreApplication instance
before your first call to loading a
database
Believe me, manually installing PyQT+MySQL on Windows is a pain. But if you need some out of the way plugin to get at that the executable doesn't know, you have to go down the rabbit hole further.
Here is the new and improved .pro file:
LANGUAGE = C++
TEMPLATE = app
TARGET = executable
QT += core sql
QTPLUGIN += qsqlmysql
DEPENDPATH += .
INCLUDEPATH += C:\MySQL\bin
LIBS += -L C:\MySQL\lib\opt
# Input
SOURCES += database.cpp
Turns out I did have the right path to mysql, I was just confusing it with the .pro file that I had. After redownloading qt and following the steps above again, modifying my .pro file made all the difference.
But now I had to download SIP and PyQT. I followed the docs on there. There are a few more problems. Follow the links or the directions which are left there in case the information is removed.
If your SIP make install has an error where it is looking at Unix paths (/usr/bin) instead of DOS paths (C:\QT), look at this link http://old.nabble.com/Building-SIP-on-MinGW-:-problem-at-%22make-install%22-td28909249.html#
(short version: the problem is the sh.exe in one of your other linux compilers like cygwin or msys, change the name temporarily to force the make install to use DOS path naming):
If you configure PyQT and it spits out a file error that has to do with QTCore
Google pexports and download. Go to %QTdir%/bin. Then follow instructions or link ( http://jeethurao.com/blog/?p=18 )
pexports QtCore4.dll > QtCore4.def
dlltool –dllname QtCore4.dll –def QtCore4.def –output-lib libQtCore4.a
move libQtCore4.a ..\lib
And now you know kung-fu.
P.S: I never tried this method myself. This is a different, but untested (by me) method of compiling PyQT, done up by the trolls at Trolltech:
http://www.diotavelli.net/PyQtWiki/InstallingPyQTCommercialWin