Author Topic: SQLite3/C++11 Issues  (Read 12366 times)

Offline Geowil

  • Multiple posting newcomer
  • *
  • Posts: 10
SQLite3/C++11 Issues
« on: March 22, 2014, 06:34:14 am »
After searching topics I have found none discussing how to add the pre-compiled sqlite3.lib into Code::Blocks.

I am attempting to add the lib file in for my project however so far all I am getting on compile are errors about how sqlite3 functions are undefined.  I have added the path to the sqlite3.lib file into my build options -> linker settings, that path being SQLite3\sqlite3.lib, for both debug and release builds.  Does Code::Blocks require something else besides this?

Edit:

I decided to try compiling SQLite3 myself as suggested in some of the other topics since maybe that pre-compiled lib will not work with g++.  So I have the .a file now but the linker is still refusing to recognize it now saying that -lsqlite3_2 cannot be found (the file is named libsqlite3_2.a).

Edit 2:

I have now correctly named both the .a and .lib file as libsqlite3 however ld.exe still cannot find either of them.  Is TDM's MinGW one of those that blows up on spaces in file paths?

Edit 3:

I am out of ideas now.  Here are all of the settings (in the global compiler settings):

Linker Settings - Other Linker Options: -lsqlite3
Search Directories - Compiler: D:\Codeblocks\MinGW\SQLite3
Search Directories - Linker: D:\Codeblocks\MinGW\SQLite3

File names (in D:\Codeblocks\MinGW\SQLite3):
libsqlite3.a
_libsqlite3.lib
sqlite3.h
sqlite3.c
sqlite3.dll
shell.c

When I compile my project I still am getting the ld.exe -lsqlite3 not found error.
« Last Edit: March 22, 2014, 09:25:49 am by Geowil »

Offline Jenna

  • Administrator
  • Lives here!
  • *****
  • Posts: 7255
Re: SQLite3 Issues - update 2
« Reply #1 on: March 22, 2014, 08:53:30 am »
Please post the builkd log(!) of a full rebuild with full commandline enabled.

Offline Geowil

  • Multiple posting newcomer
  • *
  • Posts: 10
Re: SQLite3 Issues - update 2
« Reply #2 on: March 22, 2014, 09:22:00 am »
Please post the builkd log(!) of a full rebuild with full commandline enabled.

The entire log is too big to post but I think this is the problem:

Quote
d:/codeblocks/mingw/bin/../lib/gcc/x86_64-w64-mingw32/4.8.1/../../../../x86_64-w64-mingw32/bin/ld.exe: skipping incompatible D:\CodeBlocks\MinGW\SQLite3/libsqlite3.a when searching for -lsqlite3
d:/codeblocks/mingw/bin/../lib/gcc/x86_64-w64-mingw32/4.8.1/../../../../x86_64-w64-mingw32/bin/ld.exe: skipping incompatible D:\CodeBlocks\MinGW\SQLite3/sqlite3.dll when searching for -lsqlite3
d:/codeblocks/mingw/bin/../lib/gcc/x86_64-w64-mingw32/4.8.1/../../../../x86_64-w64-mingw32/bin/ld.exe: skipping incompatible D:\CodeBlocks\MinGW\SQLite3\libsqlite3.a when searching for -lsqlite3
d:/codeblocks/mingw/bin/../lib/gcc/x86_64-w64-mingw32/4.8.1/../../../../x86_64-w64-mingw32/bin/ld.exe: skipping incompatible D:\CodeBlocks\MinGW\SQLite3/libsqlite3.a when searching for -lsqlite3
d:/codeblocks/mingw/bin/../lib/gcc/x86_64-w64-mingw32/4.8.1/../../../../x86_64-w64-mingw32/bin/ld.exe: skipping incompatible D:\CodeBlocks\MinGW\SQLite3/sqlite3.dll when searching for -lsqlite3
d:/codeblocks/mingw/bin/../lib/gcc/x86_64-w64-mingw32/4.8.1/../../../../x86_64-w64-mingw32/bin/ld.exe: cannot find -lsqlite3
collect2.exe: error: ld returned 1 exit status
Process terminated with status 1 (0 minute(s), 58 second(s))
1 error(s), 317 warning(s) (0 minute(s), 58 second(s))

Did some Googling and it seems that this means that the linker is stating that the built files do not match the type of the program (32-bit or 64-bit).  I was using MinGw 4.8.1 64-bit but had built 32-bit libs for SQLite3 (could not get it to build as 64-bit).  So I attempted again to get TDM-MinGW 4.8.1 32-bit to work but it is still giving me trouble with c++11:

Quote
D:\Codeblocks\Projects\Space Crusade 0.5A Build 5\database.cpp:925:85: error: 'to_string' was not declared in this scope
     dbug.createBReport("SQL Code 7","No column queried",bLocale + to_string(__LINE__),bTDate,"./SC_Log.txt");
                                                                                     ^
D:\Codeblocks\Projects\Space Crusade 0.5A Build 5\database.cpp:933:86: error: 'to_string' was not declared in this scope
    dbug.createBReport("SQL Code 8",sqlite3_errmsg(dBase),bLocale + to_string(__LINE__),bTDate,"./SC_Log.txt");
                                                                                      ^
D:\Codeblocks\Projects\Space Crusade 0.5A Build 5\database.cpp:941:85: error: 'to_string' was not declared in this scope
   dbug.createBReport("SQL Code 3",sqlite3_errmsg(dBase),bLocale + to_string(__LINE__),bTDate,"./SC_Log.txt");
                                                                                     ^
D:\Codeblocks\Projects\Space Crusade 0.5A Build 5\database.cpp: In member function 'void Database::returnMesResult(std::vector<message>&)':
D:\Codeblocks\Projects\Space Crusade 0.5A Build 5\database.cpp:949:34: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
  for (i = 0; i < mesResults.size(); i++)
                                  ^
D:\Codeblocks\Projects\Space Crusade 0.5A Build 5\database.cpp: In member function 'void Database::getPNResults(bool*)':
D:\Codeblocks\Projects\Space Crusade 0.5A Build 5\database.cpp:994:97: error: 'to_string' was not declared in this scope
         dbug.createBReport("SQL Code 6","Data returned equals NULL",bLocale + to_string(__LINE__),bTDate,"./SC_Log.txt");
                                                                                                 ^
D:\Codeblocks\Projects\Space Crusade 0.5A Build 5\database.cpp:1009:86: error: 'to_string' was not declared in this scope
      dbug.createBReport("SQL Code 7","No column queried",bLocale + to_string(__LINE__),bTDate,"./SC_Log.txt");
                                                                                      ^
D:\Codeblocks\Projects\Space Crusade 0.5A Build 5\database.cpp:1018:81: error: 'to_string' was not declared in this scope
    dbug.createBReport("SQL Code 8","No row queried",bLocale + to_string(__LINE__),bTDate,"./SC_Log.txt");
                                                                                 ^
D:\Codeblocks\Projects\Space Crusade 0.5A Build 5\database.cpp:1026:85: error: 'to_string' was not declared in this scope
   dbug.createBReport("SQL Code 3",sqlite3_errmsg(dBase),bLocale + to_string(__LINE__),bTDate,"./SC_Log.txt");
                                                                                     ^
D:\Codeblocks\Projects\Space Crusade 0.5A Build 5\database.cpp: In member function 'void Database::returnPNResult(std::vector<planetName>&)':
D:\Codeblocks\Projects\Space Crusade 0.5A Build 5\database.cpp:1035:33: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
  for (i = 0; i < pNResults.size(); i++)
                                 ^
D:\Codeblocks\Projects\Space Crusade 0.5A Build 5\database.cpp: In member function 'void Database::getDResults(bool*)':
D:\Codeblocks\Projects\Space Crusade 0.5A Build 5\database.cpp:1077:96: error: 'to_string' was not declared in this scope
        dbug.createBReport("SQL Code 6","Data returned equals NULL",bLocale + to_string(__LINE__),bTDate,"./SC_Log.txt");
                                                                                                ^
D:\Codeblocks\Projects\Space Crusade 0.5A Build 5\database.cpp:1092:85: error: 'to_string' was not declared in this scope
     dbug.createBReport("SQL Code 7","No column queried",bLocale + to_string(__LINE__),bTDate,"./SC_Log.txt");
                                                                                     ^
D:\Codeblocks\Projects\Space Crusade 0.5A Build 5\database.cpp:1100:81: error: 'to_string' was not declared in this scope
    dbug.createBReport("SQL Code 8","No row queried",bLocale + to_string(__LINE__),bTDate,"./SC_Log.txt");
                                                                                 ^
D:\Codeblocks\Projects\Space Crusade 0.5A Build 5\database.cpp:1108:85: error: 'to_string' was not declared in this scope
   dbug.createBReport("SQL Code 3",sqlite3_errmsg(dBase),bLocale + to_string(__LINE__),bTDate,"./SC_Log.txt");
                                                                                     ^
D:\Codeblocks\Projects\Space Crusade 0.5A Build 5\database.cpp: In member function 'void Database::returnDResult(std::vector<diplomacy>&)':
D:\Codeblocks\Projects\Space Crusade 0.5A Build 5\database.cpp:1116:32: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
  for (i = 0; i < dResults.size(); i++)
                                ^
D:\Codeblocks\Projects\Space Crusade 0.5A Build 5\database.cpp: In member function 'void Database::getRResults(bool*)':
D:\Codeblocks\Projects\Space Crusade 0.5A Build 5\database.cpp:1157:96: error: 'to_string' was not declared in this scope
        dbug.createBReport("SQL Code 6","Data returned equals NULL",bLocale + to_string(__LINE__),bTDate,"./SC_Log.txt");
                                                                                                ^
D:\Codeblocks\Projects\Space Crusade 0.5A Build 5\database.cpp:1172:85: error: 'to_string' was not declared in this scope
     dbug.createBReport("SQL Code 7","No column queried",bLocale + to_string(__LINE__),bTDate,"./SC_Log.txt");
                                                                                     ^
D:\Codeblocks\Projects\Space Crusade 0.5A Build 5\database.cpp:1180:81: error: 'to_string' was not declared in this scope
    dbug.createBReport("SQL Code 8","No row queried",bLocale + to_string(__LINE__),bTDate,"./SC_Log.txt");
                                                                                 ^
D:\Codeblocks\Projects\Space Crusade 0.5A Build 5\database.cpp:1188:85: error: 'to_string' was not declared in this scope
   dbug.createBReport("SQL Code 3",sqlite3_errmsg(dBase),bLocale + to_string(__LINE__),bTDate,"./SC_Log.txt");
                                                                                     ^
D:\Codeblocks\Projects\Space Crusade 0.5A Build 5\database.cpp: In member function 'void Database::returnRResult(std::vector<ranks>&)':
D:\Codeblocks\Projects\Space Crusade 0.5A Build 5\database.cpp:1196:32: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
  for (i = 0; i < rResults.size(); i++)
                                ^
D:\Codeblocks\Projects\Space Crusade 0.5A Build 5\database.cpp: In member function 'void Database::getRcResults(bool*)':
D:\Codeblocks\Projects\Space Crusade 0.5A Build 5\database.cpp:1238:96: error: 'to_string' was not declared in this scope
        dbug.createBReport("SQL Code 6","Data returned equals NULL",bLocale + to_string(__LINE__),bTDate,"./SC_Log.txt");
                                                                                                ^
D:\Codeblocks\Projects\Space Crusade 0.5A Build 5\database.cpp:1253:85: error: 'to_string' was not declared in this scope
     dbug.createBReport("SQL Code 7","No column queried",bLocale + to_string(__LINE__),bTDate,"./SC_Log.txt");
                                                                                     ^
D:\Codeblocks\Projects\Space Crusade 0.5A Build 5\database.cpp:1261:81: error: 'to_string' was not declared in this scope
    dbug.createBReport("SQL Code 8","No row queried",bLocale + to_string(__LINE__),bTDate,"./SC_Log.txt");
                                                                                 ^
D:\Codeblocks\Projects\Space Crusade 0.5A Build 5\database.cpp:1269:85: error: 'to_string' was not declared in this scope
   dbug.createBReport("SQL Code 3",sqlite3_errmsg(dBase),bLocale + to_string(__LINE__),bTDate,"./SC_Log.txt");

The toolchain is as follows:

C Compiler: mingw32-gcc-4.8.1.exe
C++ Compliler: mingw32-g++.exe
Linker for Dynamic Libs: mingw32-g++.exe
Linker for Static Libs: mingw32-gcc-ar.exe
Debugger: GDB/CDB Debugger : Default
Resource Compiler: windres.exe
Make Program: mingw32-make.exe

The c++11 flag is checked:
Quote
mingw32-c++.exe -Wall -fexceptions -std=c++11 -g -std=c++11 -ID:\CodeBlocks\MinGW\SQLite3 -c "D:\Codeblocks\Projects\Space Crusade 0.5A Build 5\database.cpp"
« Last Edit: March 22, 2014, 09:25:03 am by Geowil »

Offline Jenna

  • Administrator
  • Lives here!
  • *****
  • Posts: 7255
Re: SQLite3/C++11 Issues
« Reply #3 on: March 22, 2014, 09:32:11 am »
If you have more than one MinGW installation, make sure none of them is in [anydrive]:\MinGW or the chosen installation might pick up incorrect libs.
This is a MinGW issue.
Chosing e.g \Mingw32 and \MinGW64 for 32- and 64-bit should work.

Offline Jenna

  • Administrator
  • Lives here!
  • *****
  • Posts: 7255

Offline Geowil

  • Multiple posting newcomer
  • *
  • Posts: 10
Re: SQLite3/C++11 Issues
« Reply #5 on: March 22, 2014, 09:49:58 am »
If you have more than one MinGW installation, make sure none of them is in [anydrive]:\MinGW or the chosen installation might pick up incorrect libs.
This is a MinGW issue.
Chosing e.g \Mingw32 and \MinGW64 for 32- and 64-bit should work.

Neither of the installations (I have both 64 and 32 installed) are in MinGW.  They are in TDM-GCC-32 and TDM-GCC-64.  I also did not install PATH variables for either of them.  The toolchain exe files are in the Codeblocks\MinGW\bin folder; currently contains MinGW 4.8.1 32-bit files.

See also this thread: http://forums.codeblocks.org/index.php/topic,19068.msg130636/topicseen.html#msg130636

I also tried this type of setup but I am still getting the same errors on to_string.  So I uninstalled Codeblocks again as well as both versions of MinGW.  I installed MinGW 32-bit first and made sure that no PATH variable was added.  Next I installed Codeblocks, deleted the vanilla MinGW files from it (again checking the PATH field for any MinGW variables) and copied the 4.8.1 TDM MinGW files into the Codeblocks MinGW folder.

I changed the toolchain paths so that they were looking for the above mentioned exe files in D:\Codeblocks\MinGW\bin\ and tried a rebuild of my project; still get those to_string errors.

Offline osdt

  • Multiple posting newcomer
  • *
  • Posts: 63
Re: SQLite3/C++11 Issues
« Reply #6 on: March 22, 2014, 10:47:41 am »
... still get those to_string errors.

It's a known MinGW issue http://gcc.gnu.org/bugzilla/show_bug.cgi?id=52015#c25 which probably won't be fixed for 32-Bit targets.

Offline Geowil

  • Multiple posting newcomer
  • *
  • Posts: 10
Re: SQLite3/C++11 Issues
« Reply #7 on: March 22, 2014, 01:56:25 pm »
... still get those to_string errors.

It's a known MinGW issue http://gcc.gnu.org/bugzilla/show_bug.cgi?id=52015#c25 which probably won't be fixed for 32-Bit targets.

Interesting and it explains a lot.  Well if MinGW's developer's are going to be that intransigent I will just have to fall back to my fall-back plan of using string stream to create a jury rigged to_string function.

Offline Geowil

  • Multiple posting newcomer
  • *
  • Posts: 10
Re: SQLite3/C++11 Issues
« Reply #8 on: March 22, 2014, 05:29:02 pm »
I finally got my project to build  :D

I had to rebuild my SQLite amalgamation compile and also learned that for atoi you need cstdlib and cstdio in g++/gcc.  Along with the string stream replacement for to_string c++11 everything works.  Thanks for the help and suggestions.