compiling & using wxSQLite 3.5.8 Topic is solved

Do you have a question about makefiles, a compiler or IDE you are using and need to know how to set it up for wxWidgets or why it doesn't compile but other IDE's do ? Post your questions here.
Post Reply
Natulux
Filthy Rich wx Solver
Filthy Rich wx Solver
Posts: 242
Joined: Thu Aug 03, 2017 12:20 pm

compiling & using wxSQLite 3.5.8

Post by Natulux »

Hey guys

I dare say, that I basically understand how to compile a project with VisualStudio, but I got hung up here.
I try to compile and use wxSQLite3 for wxWidgets3, and I was able to apply wxSQLite 3.3.1 to my projects. Yet I have issues with compiling and using 3.5.8 (or 3.5.7) with encryption.

I tried compiling everything Multithreaded (/MT) or everything Multithreaded-DLL (/MD) in Release-Win32 mode in the following cases.
My project is a wxWidgets 3.1.0 project using VisualStudio2008 on Windows10x64.

My doings step by step:
1. Getting wxsqlite3 from GitHub (version 2.5.8 atm)
2. Downloading premake 5 alpha (https://premake.github.io/download.html)
3. Extracting "premake5.lua" with premake for vs2015
4. Building the solution "SQLite3" with Release AES256 - Win32, Multithreaded DLL (/MD)
contains:
  1. sqlite3dll
    sqlite3dllicu
    sqlite3lib
    sqlite3libicu
    sqlite3shell
    sqlite3shellicu
sqlite3dll and sqlite3lib complete without errors, "sqlite3.dll" and "sqlite3.lib" are created
The others fail due to dependencies
5. Building "wxsqlite3_vc14.sln" with vs2015 with Release - Win32, Multithreaded DLL (/MD)
contains:
  1. minimal
    treeview
    wxsqlite3
wxsqlite3 completes (as static lib) without errors, "wxsqlite3.lib" is being created.
minimal and treeview fail due to linker errors (building several times doesn't help)
minimal linker erros go like this:
1>msvcprt.lib(MSVCP140.dll) : error LNK2005: "void __cdecl std::_Xbad_alloc(void)" (?_Xbad_alloc@std@@YAXXZ) already defined in libcpmt.lib(xthrow.obj)
1>wxsqlite3.lib(sqlite3secure.obj) : error LNK2001: unresolved external symbol __imp__strncmp
1>wxbase31u.lib(baselib_string.obj) : error LNK2019: unresolved external symbol "__declspec(dllimport) public: void __thiscall std::basic_streambuf<char,struct std::char_traits<char> >::_Unlock(void)" (__imp_?_Unlock@?$basic_streambuf@DU?$char_traits@D@std@@@std@@QAEXXZ) referenced in function "public: __thiscall std::basic_ostream<char,struct std::char_traits<char> >::_Sentry_base::~_Sentry_base(void)" (??1_Sentry_base@?$basic_ostream@DU?$char_traits@D@std@@@std@@QAE@XZ)
...
My settings for Release - Win32 in vs2008:
c++ additional includes
  • .\wxsqlite3-3.5.8\include
    .\wxsqlite3-3.5.8\sqlite3\secure\src
Linker additional libraries
  • .\wxsqlite3-3.5.8\lib\vc_lib
    .\wxsqlite3-3.5.8\lib\vc_lib
Linker additional dependencies
  • wxsqlite3.lib
    sqlite3.lib
Compiling my project generates 36 german linker errors (see below).
They basically say, that some parts of my windows standard libs (MSVCP90.dll) are already defined in "wxsqlite3.obj" which is supposed to be an error that occurs, if debug and release is mixed (according to my research).
Additionally, in "wxsqlite3.lib(sqlite3secure.obj)" are several unresolved external symbols.
Yet, changing my setting to wxSQLite3.3.1, it compiles allright. Is there something I'm doing terribly wrong in my setup? Why can't I even compile the minimal sample?

Thanks and have a good day.
Natu

errors:
compilerErrors_minimal.txt
compiler errors when compiling minimal from wxSQLite3.5.8
(369.93 KiB) Downloaded 78 times
compilerErrors_myProject.txt
compiler errors when compiling my project
(8.53 KiB) Downloaded 77 times
ONEEYEMAN
Part Of The Furniture
Part Of The Furniture
Posts: 7480
Joined: Sat Apr 16, 2005 7:22 am
Location: USA, Ukraine

Re: compiling & using wxSQLite 3.5.8

Post by ONEEYEMAN »

Hi,
For your own project:

On Windows you can't mix "Debug" and "Release" configuration. They use different CRTs and ther4efore not compatible.
You need to either build your project in "Release" mode or rebuild wxSQLite3 in "Debug" one.

For the wxSQLite samples - I don't know. Try to get the dependencies in order to satisfy building everything on step4. After all you are trying to build it with encryption support.

Thank you.
Natulux
Filthy Rich wx Solver
Filthy Rich wx Solver
Posts: 242
Joined: Thu Aug 03, 2017 12:20 pm

Re: compiling & using wxSQLite 3.5.8

Post by Natulux »

Thanks for your reply.
My goal is to compile everything in Release mode, so I basically can't mix up Debug and Release (at least not with the projects I'm building myself - there is so much included sideways, that I kinda lost control of that).

If the order of my dependencies would be a problem, building several times would solve the problem or at least change it, which is not the case.

I would like a static build, so I wouldn't need the sqlite3.dll to be lying arround. But if need be, I just try the new version of sqlite3.dll and the precompiled build of wxSQLite.
Although I have read on GitHub, that wxSQLite build 3.5 and later would include the sqlite3 statically and therefore don't need it or wouldn't be able to use it anyways. I just can't compile my project with it to prove it. (3.5.0 release note: Changes since previous release: Upgrade to SQLite version 3.16.2, SQLite3 library now integrated part of wxSQLite3)

Have a nice day.
Natu
User avatar
doublemax
Moderator
Moderator
Posts: 19160
Joined: Fri Apr 21, 2006 8:03 pm
Location: $FCE2

Re: compiling & using wxSQLite 3.5.8

Post by doublemax »

I don't know if this also works when you need encryption support, but i just add all wxSQLite3 sources and the sqlite amalgamation source to my project. Not as external libraries.
Use the source, Luke!
Natulux
Filthy Rich wx Solver
Filthy Rich wx Solver
Posts: 242
Joined: Thu Aug 03, 2017 12:20 pm

Re: compiling & using wxSQLite 3.5.8

Post by Natulux »

Even with the new versions? wxSQLite3.5 and further have encryption support actiavated by standard.

I couldn't find my error, but I found a solution. Most likely I had issues by mixing up vs2008 and vs2015. I had my project and wxWidgets built and used in vs2008, but wxSQLite doesn't support vc9 anymore, so I compiled that with vc14 (vs2015).

I solved my problem by:
- recompile wxWidgets 3.1.0 with vc14 project in vs2015 with projects on Release x86 and Multi-threaded (/MT)
- recompile wxSQLite 3.5.8 with vc14 project in vs2015 with projects on Release x86 and Multi-threaded (/MT)
- merge my project from vc9 to vc14
- include the include dir from wxSQLite and the freshly built lib/vc_lib/wxSQLite3.lib, NO sqlite3 anymore (cause it's statically built into wxSQLite already)

Using:

Code: Select all

#include "wx/wxsqlite3.h"
wxSQLite3Database::InitializeSQLite();
wxSQLite3Database db;
- rebuild my project in vs2015 with projects on Release x86 and Multi-threaded (/MT)

Voila. This project runs (without sqlite3.dll happily) and none of my other project can be compiled anymore ;-)
Thank you guys nevertheless. This forum always proves to be a great help for little programmers to become bigger over time. :-)

EDIT:
Oh wait, I guess I was mistaken. wxSQLite3 does support vc9 still, but I should have used another build setting in premake5. I'll try to redo every step with vs2008 now.

EDIT2:
My intuition was right though. When I try to compile with 2008, I need to use Multithreaded-DLL rather than Multithreaded and furthermore, wxSQLite3 wont compile due to the following line, the flag isn't defined and the compiler can't work out the comparison:

sqlite3secure.c

Code: Select all

#if defined(SQLITE_ENABLE_DEBUG) && (SQLITE_ENABLE_DEBUG == 1)
Just stay with vs2015 for our own good ;-)

Greets
Natu
ONEEYEMAN
Part Of The Furniture
Part Of The Furniture
Posts: 7480
Joined: Sat Apr 16, 2005 7:22 am
Location: USA, Ukraine

Re: compiling & using wxSQLite 3.5.8

Post by ONEEYEMAN »

Hi,
Usually people try building the Debug version and then, when everything works, they build a Release one. ;-)

But that is up to you.

Also as doublemax said, just include the SQLite and wxSQLite sources inside your project and compile. There will be no issues. I did it myself (just for SQLite amalgamation) and everything builds and works as expected.

Thank you.
Natulux
Filthy Rich wx Solver
Filthy Rich wx Solver
Posts: 242
Joined: Thu Aug 03, 2017 12:20 pm

Re: compiling & using wxSQLite 3.5.8

Post by Natulux »

Hey,

I guess that is how it should be - debugging first and finishing with release. But do you keep two copys of wxwidgets, one compiled for debug (eg. MTd) and one for release (eg MT)? Because I solved my error by rebuilding everything from scratch, including wxWidgets, all with one setting (Multithreaded /MT) and one editor (vs2015), nothing else worked. That is why Im a bit concerned about switching between debug and release.

I tried just including the files before, but I didn't come through, though I don't remember the errors I got.
For completeness sake: Do you include all the resources from wxSQLite (.h and .cpp) + sqlite3.dll, if prior to version 3.5, and thats it?

Im quite happy with my include of just wxqslite3.lib though :-)

Greetings
Natu
PB
Part Of The Furniture
Part Of The Furniture
Posts: 4204
Joined: Sun Jan 03, 2010 5:45 pm

Re: compiling & using wxSQLite 3.5.8

Post by PB »

Natulux wrote:But do you keep two copys of wxwidgets, one compiled for debug (eg. MTd) and one for release (eg MT)?
At least on Windows, wxWidgets support in-source building and using multiple configurations (e.g. (static and/or DLL) debug and release) out of the box, for GCC and MSVC makefiles as well as for MSVS solutions.

I believe that not using the debug build during development would not be a good idea, the diagnostics included in the debug build (both in wxWidgets/STL... sources and the CRT) can be very helpful. Any decent IDE makes using both debug and release version of your application/library very easy...
Natulux
Filthy Rich wx Solver
Filthy Rich wx Solver
Posts: 242
Joined: Thu Aug 03, 2017 12:20 pm

Re: compiling & using wxSQLite 3.5.8

Post by Natulux »

PB wrote:At least on Windows, wxWidgets support in-source building and using multiple configurations (e.g. (static and/or DLL) debug and release) out of the box, for GCC and MSVC makefiles as well as for MSVS solutions.
So to achieve this with visual studio, I could compile wxWidgets once with Release and once with Debug settings? (eg. once MT and once MTd)
If so, I should really try that.

At least I learned, that I shouldn't mix vs2008 and vs2015 builds, which is a tough call, when your colleagues still use vs2008 and you would rather have vs2015 or 2017 maybe.
PB
Part Of The Furniture
Part Of The Furniture
Posts: 4204
Joined: Sun Jan 03, 2010 5:45 pm

Re: compiling & using wxSQLite 3.5.8

Post by PB »

Natulux wrote:So to achieve this with visual studio, I could compile wxWidgets once with Release and once with Debug settings? (eg. once MT and once MTd)
Yes, except the debug and release builds differ in more than the CRT. Some defines (e.g., NDEBUG etc.) also differ between the two version, resulting in different code generated (e.g., assert messages will pop up, more checks for code correctness may be applied...).
utelle
Moderator
Moderator
Posts: 1129
Joined: Tue Jul 05, 2005 10:00 pm
Location: Cologne, Germany
Contact:

Re: compiling & using wxSQLite 3.5.8

Post by utelle »

Natulux wrote:wxSQLite3.5 and further have encryption support actiavated by standard.
That's right, since that is what most users of wxSQLite3 want anyway. Therefore I decided to activate encryption support as the default and to make SQLite3 an integrated part of wxSQLite3. The latter helps to avoid conflicts with non-matching SQLite versions.

The SQLite library can still be built separately, if someone just wants to use SQLite with encryption support, but is not interested in the wxWidgets wrapper. For this purpose the folder sqlite3/secure contains a premake5 script to generate build files for this use case.
Natulux wrote:I couldn't find my error, but I found a solution. Most likely I had issues by mixing up vs2008 and vs2015. I had my project and wxWidgets built and used in vs2008, but wxSQLite doesn't support vc9 anymore, so I compiled that with vc14 (vs2015).
Mixing code compiled with vs2008 and vs2015 will not work most likely.

I have to admit that I removed the build files for Visual Studio older than vs2010 in the course of overhauling the wxSQLite3 build system. vs2010 and higher support a mechanism for including property files (.props). This is very convenient for configuring the build files for various wxWidgets versions and/or installations. This mechanism is not available for vs2008. Nevertheless, it should be possible to generate working project and solution files for vs2008 by invoking premake5 in the root folder with the build action vs2008. Did you try that?
Natulux wrote:EDIT:
Oh wait, I guess I was mistaken. wxSQLite3 does support vc9 still, but I should have used another build setting in premake5. I'll try to redo every step with vs2008 now.
Right. However, since I haven't tested this myself, since I don't have vs2008 installed any longer on my system, there might be issues.
Natulux wrote:EDIT2:
My intuition was right though. When I try to compile with 2008, I need to use Multithreaded-DLL rather than Multithreaded ...
Multithreaded-DLL runtime is the default. To instruct premake5 to generate build files using the static runtime you will have to tweak the premake5 scripts by adding the appropriate flags

Code: Select all

flags { "StaticRuntime" }
Search for it in wxwidgets.lua in folder premake and remove the comment prefix "--".
Natulux wrote:...and furthermore, wxSQLite3 wont compile due to the following line, the flag isn't defined and the compiler can't work out the comparison:

sqlite3secure.c

Code: Select all

#if defined(SQLITE_ENABLE_DEBUG) && (SQLITE_ENABLE_DEBUG == 1)
This is an issue that is probably related to the property file feature. In the premake5 script you will find the line

Code: Select all

    "SQLITE_ENABLE_DEBUG=$(SQLITE_ENABLE_DEBUG)",
The symbol $(SQLITE_ENABLE_DEBUG) is defined in the property file, but will not be defined for the vs2008 build files. A quick fix would be to change the line in premake5.lua to

Code: Select all

    "SQLITE_ENABLE_DEBUG=0",
Regards,

Ulrich
Natulux
Filthy Rich wx Solver
Filthy Rich wx Solver
Posts: 242
Joined: Thu Aug 03, 2017 12:20 pm

Re: compiling & using wxSQLite 3.5.8

Post by Natulux »

Hello,

thank you all for your continued support. You are a great help.
I appreciate the further insights into the building options of wxSQLite you gave here, Ulrich. Special thanks to you, I think I have learned some more things here. Keep up the good work! Danke nochmal :-)

All the best
Natu
Post Reply