I've been trying to compile the MySQL++ programs with major trouble. I don't know where the problem is, so I came here since the MySQL++ site is basically useless.
I have to link to the mysql libraries, and to the mysql++ libraries. However, I could only get the mysql++ libraries to compile with the GCC compiler, which is why I'm here, and it gives me a *.a file. But the libraries that come with MySQL are *.lib files. When I try to compile I get a lot of undefined references which makes me think it's not getting the library it needs. Are lib even compatible with GCC?
I also tried linking the another mysql lib thinking the needed stuff is in there, but that generates lots of "variable '<var>' can't be auto-imported." errors.
Any ideas? I'm not very experienced in there things so please use "for idiots" language.
Here is the full log:
Project : simple1
Compiler : GNU GCC Compiler (called directly)
Directory : D:\CPP\mysql++-1.7.32\examples\
--------------------------------------------------------------------------------
Switching to target: Debug
mingw32-g++.exe -W -DWIN32 -D_DEBUG -ID:\CPP\mysql++-1.7.32\lib -ID:\CPP\mysql-4.1.11-win32\include -ID:\CPP\mysql-4.1.11\include -ID:\Publishing\CodeBlocks\include -c util.cpp -o Debug\util.o
mingw32-g++.exe -W -DWIN32 -D_DEBUG -ID:\CPP\mysql++-1.7.32\lib -ID:\CPP\mysql-4.1.11-win32\include -ID:\CPP\mysql-4.1.11\include -ID:\Publishing\CodeBlocks\include -c simple1.cpp -o Debug\simple1.o
mingw32-g++.exe -LD:\CPP\mysql++-1.7.32\Debug -LD:\CPP\mysql-4.1.11-win32\lib\debug -LD:\Publishing\CodeBlocks\lib -o $(ProjectDir)Debug\simple1.exe Debug\util.o Debug\simple1.o -lmysql++ -lmysql -lwsock32
Debug\util.o(.text$_ZNK7mysqlpp6Result8num_rowsEv[mysqlpp::Result::num_rows() const]+0x1f):util.cpp: undefined reference to `mysql_num_rows@4'
Debug\util.o(.text$_ZNK7mysqlpp6Result9fetch_rowEv[mysqlpp::Result::fetch_row() const]+0x1a1):util.cpp: undefined reference to `mysql_fetch_row@4'
Debug\util.o(.text$_ZNK7mysqlpp6Result9fetch_rowEv[mysqlpp::Result::fetch_row() const]+0x1b8):util.cpp: undefined reference to `mysql_fetch_lengths@4'
Debug\util.o(.text$_ZNK7mysqlpp6Result9data_seekEj[mysqlpp::Result::data_seek(unsigned int) const]+0x23):util.cpp: undefined reference to `mysql_data_seek@12'
D:\CPP\mysql++-1.7.32\Debug/libmysql++.a(row.o)(.text$_ZNK7mysqlpp6ResUse10num_fieldsEv[mysqlpp::ResUse::num_fields() const]+0x10): In function `ZN7mysqlpp3Row4selfEv':
D:/CPP/mysql++-1.7.32/lib//row.h: undefined reference to `mysql_num_fields@4'
D:\CPP\mysql++-1.7.32\Debug/libmysql++.a(connection.o)(.text+0x120): In function `ZN7mysqlpp10ConnectionC2Ev':
D:/CPP/mysql++-1.7.32/lib/connection.cpp:23: undefined reference to `mysql_init@4'
D:\CPP\mysql++-1.7.32\Debug/libmysql++.a(connection.o)(.text+0x14a): In function `ZN7mysqlpp10ConnectionC1Ev':
D:/CPP/mysql++-1.7.32/lib/connection.cpp:23: undefined reference to `mysql_init@4'
D:\CPP\mysql++-1.7.32\Debug/libmysql++.a(connection.o)(.text+0x191): In function `ZN7mysqlpp10ConnectionC2Eb':
D:/CPP/mysql++-1.7.32/lib/connection.cpp:32: undefined reference to `mysql_init@4'
D:\CPP\mysql++-1.7.32\Debug/libmysql++.a(connection.o)(.text+0x1d7): In function `ZN7mysqlpp10ConnectionC1Eb':
D:/CPP/mysql++-1.7.32/lib/connection.cpp:32: undefined reference to `mysql_init@4'
D:\CPP\mysql++-1.7.32\Debug/libmysql++.a(connection.o)(.text+0x242): In function `ZN7mysqlpp10ConnectionC2EPKcS2_S2_S2_b':
D:/CPP/mysql++-1.7.32/lib/connection.cpp:40: undefined reference to `mysql_init@4'
D:\CPP\mysql++-1.7.32\Debug/libmysql++.a(connection.o)(.text+0x4b6):D:/CPP/mysql++-1.7.32/lib/connection.cpp:40: more undefined references to `mysql_init@4' follow
D:\CPP\mysql++-1.7.32\Debug/libmysql++.a(connection.o)(.text+0xc36): In function `ZN7mysqlpp10Connection12real_connectEPKcS2_S2_S2_jcjS2_j':
D:/CPP/mysql++-1.7.32/lib/connection.cpp:86: undefined reference to `mysql_options@12'
D:\CPP\mysql++-1.7.32\Debug/libmysql++.a(connection.o)(.text+0xc78):D:/CPP/mysql++-1.7.32/lib/connection.cpp:88: undefined reference to `mysql_real_connect@32'
D:\CPP\mysql++-1.7.32\Debug/libmysql++.a(connection.o)(.text+0xeb8): In function `ZN7mysqlpp10ConnectionD2Ev':
D:/CPP/mysql++-1.7.32/lib/connection.cpp:113: undefined reference to `mysql_close@4'
D:\CPP\mysql++-1.7.32\Debug/libmysql++.a(connection.o)(.text+0xed2): In function `ZN7mysqlpp10ConnectionD1Ev':
D:/CPP/mysql++-1.7.32/lib/connection.cpp:113: undefined reference to `mysql_close@4'
D:\CPP\mysql++-1.7.32\Debug/libmysql++.a(connection.o)(.text+0xf2c): In function `ZN7mysqlpp10Connection9select_dbEPKc':
D:/CPP/mysql++-1.7.32/lib/connection.cpp:118: undefined reference to `mysql_select_db@8'
D:\CPP\mysql++-1.7.32\Debug/libmysql++.a(connection.o)(.text+0x111d): In function `ZN7mysqlpp10Connection6reloadEv':
D:/CPP/mysql++-1.7.32/lib/connection.cpp:129: undefined reference to `mysql_refresh@8'
D:\CPP\mysql++-1.7.32\Debug/libmysql++.a(connection.o)(.text+0x1305): In function `ZN7mysqlpp10Connection8shutdownEv':
D:/CPP/mysql++-1.7.32/lib/connection.cpp:140: undefined reference to `mysql_shutdown@4'
D:\CPP\mysql++-1.7.32\Debug/libmysql++.a(connection.o)(.text+0x1507): In function `ZN7mysqlpp10Connection7connectEPKcS2_S2_S2_':
D:/CPP/mysql++-1.7.32/lib/connection.cpp:154: undefined reference to `mysql_options@12'
D:\CPP\mysql++-1.7.32\Debug/libmysql++.a(connection.o)(.text+0x154c):D:/CPP/mysql++-1.7.32/lib/connection.cpp:156: undefined reference to `mysql_real_connect@32'
D:\CPP\mysql++-1.7.32\Debug/libmysql++.a(connection.o)(.text+0x17a4): In function `ZN7mysqlpp10Connection4infoEv':
D:/CPP/mysql++-1.7.32/lib/connection.cpp:177: undefined reference to `mysql_info@4'
D:\CPP\mysql++-1.7.32\Debug/libmysql++.a(connection.o)(.text+0x1a19): In function `ZN7mysqlpp10Connection7executeERKSsb':
D:/CPP/mysql++-1.7.32/lib/connection.cpp:196: undefined reference to `mysql_query@8'
D:\CPP\mysql++-1.7.32\Debug/libmysql++.a(connection.o)(.text+0x1c7a): In function `ZN7mysqlpp10Connection4execERKSs':
D:/CPP/mysql++-1.7.32/lib/connection.cpp:213: undefined reference to `mysql_query@8'
D:\CPP\mysql++-1.7.32\Debug/libmysql++.a(connection.o)(.text+0x1fef): In function `ZN7mysqlpp10Connection5storeERKSsb':
D:/CPP/mysql++-1.7.32/lib/connection.cpp:232: undefined reference to `mysql_query@8'
D:\CPP\mysql++-1.7.32\Debug/libmysql++.a(connection.o)(.text+0x201d):D:/CPP/mysql++-1.7.32/lib/connection.cpp:234: undefined reference to `mysql_store_result@4'
D:\CPP\mysql++-1.7.32\Debug/libmysql++.a(connection.o)(.text+0x23f9): In function `ZN7mysqlpp10Connection3useERKSsb':
D:/CPP/mysql++-1.7.32/lib/connection.cpp:263: undefined reference to `mysql_query@8'
D:\CPP\mysql++-1.7.32\Debug/libmysql++.a(connection.o)(.text+0x2427):D:/CPP/mysql++-1.7.32/lib/connection.cpp:265: undefined reference to `mysql_use_result@4'
D:\CPP\mysql++-1.7.32\Debug/libmysql++.a(connection.o)(.text$_ZN7mysqlpp10Connection5errorEv[mysqlpp::Connection::error()]+0x10): In function `ZNSt6vectorIN7mysqlpp9SQLStringESaIS1_EED2Ev':
D:/CPP/mysql++-1.7.32/lib//sql_query.h: undefined reference to `mysql_error@4'
D:\CPP\mysql++-1.7.32\Debug/libmysql++.a(manip.o)(.text+0x36d): In function `ZN7mysqlpplsENS_11quote_type2ERNS_9SQLStringE':
D:/CPP/mysql++-1.7.32/lib/manip.cpp:24: undefined reference to `mysql_escape_string@12'
D:\CPP\mysql++-1.7.32\Debug/libmysql++.a(manip.o)(.text+0x697): In function `ZN7mysqlpplsISsEERSoNS_11quote_type1ERKT_':
Process terminated with status 1 (0 minutes, 5 seconds)
29 errors, 0 warnings
Hmmmm have you tried renaming the .lib files to .a? I'm not very sure about this, but I think (correction: hope) they're compatible.
It's the same results either way. But, it doesn't give me the "file not found" with the *.lib file anyway.
Quote-lmysql++ -lmysql
Change the libraries order. Put mysql
before mysql++
Yiannis.
It gives the exact same results.
I think I am supposed to include mysqlclient.lib as well, but when I do that I get this.
Project : simple1
Compiler : GNU GCC Compiler (called directly)
Directory : D:\CPP\mysql++-1.7.32\examples\
--------------------------------------------------------------------------------
Switching to target: Debug
mingw32-g++.exe -W -DWIN32 -D_DEBUG -ID:\CPP\mysql++-1.7.32\lib -ID:\CPP\mysql-4.1.11-win32\include -ID:\CPP\mysql-4.1.11\include -ID:\Publishing\CodeBlocks\include -c util.cpp -o Debug\util.o
mingw32-g++.exe -W -DWIN32 -D_DEBUG -ID:\CPP\mysql++-1.7.32\lib -ID:\CPP\mysql-4.1.11-win32\include -ID:\CPP\mysql-4.1.11\include -ID:\Publishing\CodeBlocks\include -c simple1.cpp -o Debug\simple1.o
mingw32-g++.exe -LD:\CPP\mysql++-1.7.32\Debug -LD:\CPP\mysql-4.1.11-win32\lib\debug -LD:\Publishing\CodeBlocks\lib -o $(ProjectDir)Debug\simple1.exe Debug\util.o Debug\simple1.o -lmysql -lmysqlclient -lwsock32 -lmysql++
D:\CPP\mysql-4.1.11-win32\lib\debug\mysqlclient.lib(./debug/client.obj)(.debug$S+0x26a1):C:\cygwin\home\mys: variable '_iob' can't be auto-imported. Please read the documentation for ld's --enable-auto-import for details.
D:\CPP\mysql-4.1.11-win32\lib\debug\mysqlclient.lib(./debug/client.obj)(.text+0x165e): In function `mysql_read_default_options':
C:\cygwin\home\mys:155: variable '_iob' can't be auto-imported. Please read the documentation for ld's --enable-auto-import for details.
D:\CPP\mysql-4.1.11-win32\lib\debug\mysqlclient.lib(./debug/dbug.obj)(.debug$S+0xefb):C:\cygwin\home\mys: variable '_iob' can't be auto-imported. Please read the documentation for ld's --enable-auto-import for details.
D:\CPP\mysql-4.1.11-win32\lib\debug\mysqlclient.lib(./debug/dbug.obj)(.text+0x15): In function `_db_push_':
C:\cygwin\home\mys:6: variable '_iob' can't be auto-imported. Please read the documentation for ld's --enable-auto-import for details.
D:\CPP\mysql-4.1.11-win32\lib\debug\mysqlclient.lib(./debug/dbug.obj)(.text+0xc89): In function `PushState':
C:\cygwin\home\mys:1153: variable '_iob' can't be auto-imported. Please read the documentation for ld's --enable-auto-import for details.
D:\CPP\mysql-4.1.11-win32\lib\debug\mysqlclient.lib(./debug/dbug.obj)(.text+0x110b): In function `DBUGOpenFile':
C:\cygwin\home\mys:1344: variable '_iob' can't be auto-imported. Please read the documentation for ld's --enable-auto-import for details.
D:\CPP\mysql-4.1.11-win32\lib\debug\mysqlclient.lib(./debug/dbug.obj)(.text+0x114e):C:\cygwin\home\mys:1352: variable '_iob' can't be auto-imported. Please read the documentation for ld's --enable-auto-import for details.
D:\CPP\mysql-4.1.11-win32\lib\debug\mysqlclient.lib(./debug/dbug.obj)(.text+0x1168):C:\cygwin\home\mys:1354: variable '_iob' can't be auto-imported. Please read the documentation for ld's --enable-auto-import for details.
D:\CPP\mysql-4.1.11-win32\lib\debug\mysqlclient.lib(./debug/dbug.obj)(.text+0x11c0):C:\cygwin\home\mys:1361: variable '_iob' can't be auto-imported. Please read the documentation for ld's --enable-auto-import for details.
D:\CPP\mysql-4.1.11-win32\lib\debug\mysqlclient.lib(./debug/dbug.obj)(.text+0x11da):C:\cygwin\home\mys:1363: variable '_iob' can't be auto-imported. Please read the documentation for ld's --enable-auto-import for details.
D:\CPP\mysql-4.1.11-win32\lib\debug\mysqlclient.lib(./debug/dbug.obj)(.text+0x1206): In function `CloseFile':
C:\cygwin\home\mys:1336: variable '_iob' can't be auto-imported. Please read the documentation for ld's --enable-auto-import for details.
D:\CPP\mysql-4.1.11-win32\lib\debug\mysqlclient.lib(./debug/dbug.obj)(.text+0x120f):C:\cygwin\home\mys: variable '_iob' can't be auto-imported. Please read the documentation for ld's --enable-auto-import for details.
D:\CPP\mysql-4.1.11-win32\lib\debug\mysqlclient.lib(./debug/dbug.obj)(.text+0x12a6): In function `DbugExit':
C:\cygwin\home\mys:1336: variable '_iob' can't be auto-imported. Please read the documentation for ld's --enable-auto-import for details.
D:\CPP\mysql-4.1.11-win32\lib\debug\mysqlclient.lib(./debug/dbug.obj)(.text+0x12b3):C:\cygwin\home\mys:1337: variable '_iob' can't be auto-imported. Please read the documentation for ld's --enable-auto-import for details.
D:\CPP\mysql-4.1.11-win32\lib\debug\mysqlclient.lib(./debug/dbug.obj)(.text+0x13c8): In function `dbug_flush':
C:\cygwin\home\mys:1895: variable '_iob' can't be auto-imported. Please read the documentation for ld's --enable-auto-import for details.
D:\CPP\mysql-4.1.11-win32\lib\debug\mysqlclient.lib(./debug/dbug.obj)(.text+0x13d8):C:\cygwin\home\mys: variable '_iob' can't be auto-imported. Please read the documentation for ld's --enable-auto-import for details.
D:\CPP\mysql-4.1.11-win32\lib\debug\mysqlclient.lib(./debug/dbug.obj)(.text+0x1419):C:\cygwin\home\mys:1899: variable '_iob' can't be auto-imported. Please read the documentation for ld's --enable-auto-import for details.
D:\CPP\mysql-4.1.11-win32\lib\debug\mysqlclient.lib(./debug/dbug.obj)(.text+0x1426):C:\cygwin\home\mys:1900: variable '_iob' can't be auto-imported. Please read the documentation for ld's --enable-auto-import for details.
D:\CPP\mysql-4.1.11-win32\lib\debug\mysqlclient.lib(./debug/dbug.obj)(.text+0x1438):C:\cygwin\home\mys:1901: variable '_iob' can't be auto-imported. Please read the documentation for ld's --enable-auto-import for details.
D:\CPP\mysql-4.1.11-win32\lib\debug\mysqlclient.lib(./debug/safemalloc.obj)(.debug$S+0x9bb):C:\cygwin\home\mys: variable '_iob' can't be auto-imported. Please read the documentation for ld's --enable-auto-import for details.
D:\CPP\mysql-4.1.11-win32\lib\debug\mysqlclient.lib(./debug/safemalloc.obj)(.text+0x46e): In function `_myrealloc':
C:\cygwin\home\mys:18: variable '_iob' can't be auto-imported. Please read the documentation for ld's --enable-auto-import for details.
D:\CPP\mysql-4.1.11-win32\lib\debug\mysqlclient.lib(./debug/safemalloc.obj)(.text+0x4ab):C:\cygwin\home\mys:21: variable '_iob' can't be auto-imported. Please read the documentation for ld's --enable-auto-import for details.
D:\CPP\mysql-4.1.11-win32\lib\debug\mysqlclient.lib(./debug/safemalloc.obj)(.text+0x699): In function `_myfree':
C:\cygwin\home\mys:27: variable '_iob' can't be auto-imported. Please read the documentation for ld's --enable-auto-import for details.
D:\CPP\mysql-4.1.11-win32\lib\debug\mysqlclient.lib(./debug/safemalloc.obj)(.text+0x6d6):C:\cygwin\home\mys:29: variable '_iob' can't be auto-imported. Please read the documentation for ld's --enable-auto-import for details.
D:\CPP\mysql-4.1.11-win32\lib\debug\mysqlclient.lib(./debug/safemalloc.obj)(.text+0x7dd): In function `check_ptr':
C:\cygwin\home\mys:3: variable '_iob' can't be auto-imported. Please read the documentation for ld's --enable-auto-import for details.
D:\CPP\mysql-4.1.11-win32\lib\debug\mysqlclient.lib(./debug/safemalloc.obj)(.text+0x81a):C:\cygwin\home\mys:5: variable '_iob' can't be auto-imported. Please read the documentation for ld's --enable-auto-import for details.
D:\CPP\mysql-4.1.11-win32\lib\debug\mysqlclient.lib(./debug/safemalloc.obj)(.text+0x855):C:\cygwin\home\mys:22: variable '_iob' can't be auto-imported. Please read the documentation for ld's --enable-auto-import for details.
D:\CPP\mysql-4.1.11-win32\lib\debug\mysqlclient.lib(./debug/safemalloc.obj)(.text+0x892):C:\cygwin\home\mys:25: variable '_iob' can't be auto-imported. Please read the documentation for ld's --enable-auto-import for details.
D:\CPP\mysql-4.1.11-win32\lib\debug\mysqlclient.lib(./debug/safemalloc.obj)(.text+0xbb9): In function `_sanity':
C:\cygwin\home\mys:16: variable '_iob' can't be auto-imported. Please read the documentation for ld's --enable-auto-import for details.
D:\CPP\mysql-4.1.11-win32\lib\debug\mysqlclient.lib(./debug/safemalloc.obj)(.text+0xbc6):C:\cygwin\home\mys: variable '_iob' can't be auto-imported. Please read the documentation for ld's --enable-auto-import for details.
D:\CPP\mysql-4.1.11-win32\lib\debug\mysqlclient.lib(./debug/safemalloc.obj)(.text+0xbe9):C:\cygwin\home\mys:17: variable '_iob' can't be auto-imported. Please read the documentation for ld's --enable-auto-import for details.
D:\CPP\mysql-4.1.11-win32\lib\debug\mysqlclient.lib(./debug/safemalloc.obj)(.text+0xbf6):C:\cygwin\home\mys:18: variable '_iob' can't be auto-imported. Please read the documentation for ld's --enable-auto-import for details.
D:\CPP\mysql-4.1.11-win32\lib\debug\mysqlclient.lib(./debug/safemalloc.obj)(.text+0xc7f): In function `_checkchunk':
C:\cygwin\home\mys:9: variable '_iob' can't be auto-imported. Please read the documentation for ld's --enable-auto-import for details.
D:\CPP\mysql-4.1.11-win32\lib\debug\mysqlclient.lib(./debug/safemalloc.obj)(.text+0xc99):C:\cygwin\home\mys:10: variable '_iob' can't be auto-imported. Please read the documentation for ld's --enable-auto-import for details.
D:\CPP\mysql-4.1.11-win32\lib\debug\mysqlclient.lib(./debug/safemalloc.obj)(.text+0xca6):C:\cygwin\home\mys:11: variable '_iob' can't be auto-imported. Please read the documentation for ld's --enable-auto-import for details.
D:\CPP\mysql-4.1.11-win32\lib\debug\mysqlclient.lib(./debug/safemalloc.obj)(.text+0xd67):C:\cygwin\home\mys:25: variable '_iob' can't be auto-imported. Please read the documentation for ld's --enable-auto-import for details.
D:\CPP\mysql-4.1.11-win32\lib\debug\mysqlclient.lib(./debug/safemalloc.obj)(.text+0xd81):C:\cygwin\home\mys:26: variable '_iob' can't be auto-imported. Please read the documentation for ld's --enable-auto-import for details.
D:\CPP\mysql-4.1.11-win32\lib\debug\mysqlclient.lib(./debug/safemalloc.obj)(.text+0xd8e):C:\cygwin\home\mys:27: variable '_iob' can't be auto-imported. Please read the documentation for ld's --enable-auto-import for details.
Process terminated with status 1 (0 minutes, 21 seconds)
32 errors, 0 warnings
I have found that when I get the "cannot be auto-imported" errors, I have to go to the compiler options, and uncheck "Enable standard compiler warnings" option. For me, that was causing it. Not sure if that is the same problem you have, but you might want to try without it.