Problems building wxWidgets 3.0.5 and sqlite 3.31 (amalgamation)

In this forum you can discuss database related issues which can be wxWidgets related, but also generic in nature.
nji
Earned a small fee
Earned a small fee
Posts: 22
Joined: Wed May 03, 2017 8:03 am

Problems building wxWidgets 3.0.5 and sqlite 3.31 (amalgamation)

Post by nji »

When building wxWidgets alone, all works well.
As soon as I add sqlite3.c I get error(s).
No problems with FLTK.
(I'm just new to this and thought this would be the easiest way. But there must be a reason for "wxsqlite"???)
Any help appreciated.

Code: Select all

g++.exe -Wall -pipe -mthreads -Winvalid-pch -include wx_pch.h -D__GNUWIN32__ -D__WXMSW__ -DWXUSINGDLL -DwxUSE_UNICODE -DWX_PRECOMP -g -ID:\Guido\develop\wxWidgets\include -ID:\Guido\develop\wxWidgets\lib\gcc_dll\mswu -c D:\Guido\develop\SeMan\First\FirstMain.cpp -o obj\Debug\SeMan\First\FirstMain.o
windres.exe -ID:\Guido\develop\wxWidgets\include -ID:\Guido\develop\wxWidgets\lib\gcc_dll\mswu  -J rc -O coff -i D:\Guido\develop\SeMan\First\resource.rc -o obj\Debug\SeMan\First\resource.res
g++.exe -LD:\Guido\develop\wxWidgets\lib\gcc_dll -o bin\Debug\First.exe obj\Debug\sqlite-amalgamation-3310100\sqlite3.o obj\Debug\SeMan\First\FirstApp.o obj\Debug\SeMan\First\FirstMain.o  obj\Debug\SeMan\First\resource.res -mthreads  -lwxmsw30u_core -lwxbase30u -lwxpng -lwxzlib -mwindows
cc1.exe: warning: ./wx_pch.h.gch/Debug_SeMan_First_wx_pch_h_gch: not for GNU C17
cc1.exe: warning: ./wx_pch.h.gch/Debug_wx_pch_h_gch: not for GNU C17
In file included from D:\Guido\develop\wxWidgets\include/wx/strconv.h:17,
                 from D:\Guido\develop\wxWidgets\include/wx/strvararg.h:20,
                 from D:\Guido\develop\wxWidgets\include/wx/string.h:46,
                 from D:\Guido\develop\wxWidgets\include/wx/log.h:43,
                 from D:\Guido\develop\wxWidgets\include/wx/msw/private.h:23,
                 from D:\Guido\develop\wxWidgets\include/wx/wxprec.h:44,
                 from ./wx_pch.h:14,
                 from <command-line>:
D:\Guido\develop\wxWidgets\include/wx/buffer.h:19:1: error: unknown type name 'class'
 class WXDLLIMPEXP_FWD_BASE wxCStrData;
 ^~~~~
D:\Guido\develop\wxWidgets\include/wx/buffer.h:27:1: error: unknown type name 'namespace'; did you mean 'iswspace'?
 namespace wxPrivate
...
User avatar
doublemax
Moderator
Moderator
Posts: 19103
Joined: Fri Apr 21, 2006 8:03 pm
Location: $FCE2

Re: Problems building wxWidgets 3.0.5 and sqlite 3.31 (amalgamation)

Post by doublemax »

Play around with order of include files. Try including sqlite.h after all wx headers.
Use the source, Luke!
nji
Earned a small fee
Earned a small fee
Posts: 22
Joined: Wed May 03, 2017 8:03 am

Re: Problems building wxWidgets 3.0.5 and sqlite 3.31 (amalgamation)

Post by nji »

But it's not me including the files etc.
It's by the generated pch file.
Generating a wxwidget app without sqlite works perfectly.
Generating a sqlite app (with our without fltk) works perfectly.
Just doing both gives the errors.

Still I don't even understand what kind of error there is.
It seems to be by the linker.
But the messages are like from the compiler.
???
User avatar
doublemax
Moderator
Moderator
Posts: 19103
Joined: Fri Apr 21, 2006 8:03 pm
Location: $FCE2

Re: Problems building wxWidgets 3.0.5 and sqlite 3.31 (amalgamation)

Post by doublemax »

Please explain what exactly you're doing.

wxWidgets doesn't use sqlite and it doesn't know anything about it. There can't be any reference to sqlite in the wx precompiled headers.

Let's suppose you're starting with the "minimal" sample and wanted to use sqlite in it. Then you would just include "sqlite.h" in minimal.cpp and add the sqlite amalgamation file to your makefile/project.
Use the source, Luke!
nji
Earned a small fee
Earned a small fee
Posts: 22
Joined: Wed May 03, 2017 8:03 am

Re: Problems building wxWidgets 3.0.5 and sqlite 3.31 (amalgamation)

Post by nji »

I use wxWidgets from newest Code::Blocks and the wxWizzard there.
All works fine when generating the minimal wxWidgets GUI project.
Then the only thing I do is adding sqlite.c amalgamation to the project.
Build it ... and get that strange error messages.
User avatar
doublemax
Moderator
Moderator
Posts: 19103
Joined: Fri Apr 21, 2006 8:03 pm
Location: $FCE2

Re: Problems building wxWidgets 3.0.5 and sqlite 3.31 (amalgamation)

Post by doublemax »

Sorry, i don't use CB or MinGW, i have no idea what's going on there.

I looks as if sqlite.c is compiled with different compiler settings as the rest.
Use the source, Luke!
ONEEYEMAN
Part Of The Furniture
Part Of The Furniture
Posts: 7449
Joined: Sat Apr 16, 2005 7:22 am
Location: USA, Ukraine

Re: Problems building wxWidgets 3.0.5 and sqlite 3.31 (amalgamation)

Post by ONEEYEMAN »

Hi,
Can you try to rebuild the project?
Also, try to use the actual source code for SQLite and not the precompiled binaries.

Thank you.
nji
Earned a small fee
Earned a small fee
Posts: 22
Joined: Wed May 03, 2017 8:03 am

Re: Problems building wxWidgets 3.0.5 and sqlite 3.31 (amalgamation)

Post by nji »

Hi,
actually the sqlite amalgamation IS the source code
I just added to the project.
The precompiled binaries are from wxWidget.
And: Of course I rebuilt the project. No change.
ONEEYEMAN
Part Of The Furniture
Part Of The Furniture
Posts: 7449
Joined: Sat Apr 16, 2005 7:22 am
Location: USA, Ukraine

Re: Problems building wxWidgets 3.0.5 and sqlite 3.31 (amalgamation)

Post by ONEEYEMAN »

Hi,
You are using prebuilt binaries for wxWidgets, right?

Can you post your code? Especially the include portion...

Thank you.
nji
Earned a small fee
Earned a small fee
Posts: 22
Joined: Wed May 03, 2017 8:03 am

Re: Problems building wxWidgets 3.0.5 and sqlite 3.31 (amalgamation)

Post by nji »

Yes, the prebuilt binaries.

The code is the most simple wxWidget "Hello world".

App.cpp and Main.cpp do first:
#include "wx_pch.h"

And wx_pch.h consists mainly of

Code: Select all

// basic wxWidgets headers
#include <wx/wxprec.h>

#ifndef WX_PRECOMP
    #include <wx/wx.h>
#endif
ONEEYEMAN
Part Of The Furniture
Part Of The Furniture
Posts: 7449
Joined: Sat Apr 16, 2005 7:22 am
Location: USA, Ukraine

Re: Problems building wxWidgets 3.0.5 and sqlite 3.31 (amalgamation)

Post by ONEEYEMAN »

Hi,
Still, can you post the code?

Thank you.
nji
Earned a small fee
Earned a small fee
Posts: 22
Joined: Wed May 03, 2017 8:03 am

Re: Problems building wxWidgets 3.0.5 and sqlite 3.31 (amalgamation)

Post by nji »

Hi,
there is NO relevant code.
(You wouldn't want the wxWidgets headers ...)
utelle
Moderator
Moderator
Posts: 1125
Joined: Tue Jul 05, 2005 10:00 pm
Location: Cologne, Germany
Contact:

Re: Problems building wxWidgets 3.0.5 and sqlite 3.31 (amalgamation)

Post by utelle »

nji wrote: Thu Jul 02, 2020 4:10 pm When building wxWidgets alone, all works well.
As soon as I add sqlite3.c I get error(s).
No problems with FLTK.
(I'm just new to this and thought this would be the easiest way. But there must be a reason for "wxsqlite"???)
Any help appreciated.

Code: Select all

g++.exe -Wall -pipe -mthreads -Winvalid-pch -include wx_pch.h -D__GNUWIN32__ -D__WXMSW__ -DWXUSINGDLL -DwxUSE_UNICODE -DWX_PRECOMP -g -ID:\Guido\develop\wxWidgets\include -ID:\Guido\develop\wxWidgets\lib\gcc_dll\mswu -c D:\Guido\develop\SeMan\First\FirstMain.cpp -o obj\Debug\SeMan\First\FirstMain.o
windres.exe -ID:\Guido\develop\wxWidgets\include -ID:\Guido\develop\wxWidgets\lib\gcc_dll\mswu  -J rc -O coff -i D:\Guido\develop\SeMan\First\resource.rc -o obj\Debug\SeMan\First\resource.res
g++.exe -LD:\Guido\develop\wxWidgets\lib\gcc_dll -o bin\Debug\First.exe obj\Debug\sqlite-amalgamation-3310100\sqlite3.o obj\Debug\SeMan\First\FirstApp.o obj\Debug\SeMan\First\FirstMain.o  obj\Debug\SeMan\First\resource.res -mthreads  -lwxmsw30u_core -lwxbase30u -lwxpng -lwxzlib -mwindows
cc1.exe: warning: ./wx_pch.h.gch/Debug_SeMan_First_wx_pch_h_gch: not for GNU C17
cc1.exe: warning: ./wx_pch.h.gch/Debug_wx_pch_h_gch: not for GNU C17
In file included from D:\Guido\develop\wxWidgets\include/wx/strconv.h:17,
                 from D:\Guido\develop\wxWidgets\include/wx/strvararg.h:20,
                 from D:\Guido\develop\wxWidgets\include/wx/string.h:46,
                 from D:\Guido\develop\wxWidgets\include/wx/log.h:43,
                 from D:\Guido\develop\wxWidgets\include/wx/msw/private.h:23,
                 from D:\Guido\develop\wxWidgets\include/wx/wxprec.h:44,
                 from ./wx_pch.h:14,
                 from <command-line>:
D:\Guido\develop\wxWidgets\include/wx/buffer.h:19:1: error: unknown type name 'class'
 class WXDLLIMPEXP_FWD_BASE wxCStrData;
 ^~~~~
D:\Guido\develop\wxWidgets\include/wx/buffer.h:27:1: error: unknown type name 'namespace'; did you mean 'iswspace'?
 namespace wxPrivate
...
First of all, you are giving way too little information. Which compiler version is used? Did you compile wxWidgets yourself? Or did you use a precompiled version? If the latter, which one?

At first glance, I see 2 issues.

1) The order of include paths
The order matters. The include directory residing in the lib folder must be given first! That is, the order must be:

Code: Select all

-ID:\Guido\develop\wxWidgets\lib\gcc_dll\mswu
-ID:\Guido\develop\wxWidgets\include
2) SQLite is written in C, not C++
The warning "./wx_pch.h.gch/Debug_wx_pch_h_gch: not for GNU C17" already gives you a hint, what's going wrong here: The compiler tries to compile C++ code as C code. That can't work - obviously, "class" and "namespace" are unknown keywords in C.

It seems that the compiler mode was set to C mode for your whole project after you added the SQLite source file. You have to make sure that the SQLite source code is compiled in C mode, while your other source files have to be compiled in C++ mode.

Regards,

Ulrich
nji
Earned a small fee
Earned a small fee
Posts: 22
Joined: Wed May 03, 2017 8:03 am

Re: Problems building wxWidgets 3.0.5 and sqlite 3.31 (amalgamation)

Post by nji »

Thank you for your support.

As you asked:
I use the GCC/G++/GFortran compiler and GDB debugger
from MinGW-W64 project (version 8.1.0, 32/64 bit, SEH)
which comes bundled with the recent CB release.
http://www.codeblocks.org/downloads/26

... and - as already answered formerly in this thread -
I use the precompiled version of wxWidgets in its
latest stable version 3.0.5 from
https://www.wxwidgets.org/downloads/
for MinGW-w64 8.1

All I want to do are the most simple, first steps
which is to build a wxWidgets application using sqlite.

Doing this my steps are as simple as:

Using CB's wizzard to generate a wxWidget project.
Let it build
(compiles 3 files: wx_pch.h, FirstApp.cpp, FirstMain.cpp
then the resources resource.rc
then links... all fine).
Now all I do is to add the sqlite3 amalgamation sqlite3.c
to the project.
Do a clean, then rebuild
(compiles 4 files now, wx_pch.h, sqlite3.c, FirstApp.cpp, FirstMain.cpp
then the resources resource.rc
then links... all seem to be without error, due to the build log up to this point,
but (beginning with the linker line) it says:

Code: Select all

g++.exe -LD:\Guido\develop\wxWidgets\lib\gcc_dll -o bin\Debug\First.exe obj\Debug\sqlite-amalgamation-3310100\sqlite3.o obj\Debug\SeMan\First\FirstApp.o obj\Debug\SeMan\First\FirstMain.o  obj\Debug\SeMan\First\resource.res -mthreads  -lwxmsw30u_core -lwxbase30u -lwxpng -lwxzlib -mwindows
cc1.exe: warning: ./wx_pch.h.gch/Debug_SeMan_First_wx_pch_h_gch: not for GNU C17
In file included from D:\Guido\develop\wxWidgets\include/wx/strconv.h:17,
                 from D:\Guido\develop\wxWidgets\include/wx/strvararg.h:20,
                 from D:\Guido\develop\wxWidgets\include/wx/string.h:46,
                 from D:\Guido\develop\wxWidgets\include/wx/log.h:43,
                 from D:\Guido\develop\wxWidgets\include/wx/msw/private.h:23,
                 from D:\Guido\develop\wxWidgets\include/wx/wxprec.h:44,
                 from ./wx_pch.h:14,
                 from <command-line>:
D:\Guido\develop\wxWidgets\include/wx/buffer.h:19:1: error: unknown type name 'class'
 class WXDLLIMPEXP_FWD_BASE wxCStrData;
 ^~~~~
D:\Guido\develop\wxWidgets\include/wx/buffer.h:27:1: error: unknown type name 'namespace'; did you mean 'iswspace'?
 namespace wxPrivate
 ^~~~~~~~~
[+ 50 errors]
All 3 former files have been generated as before, but the sqlite3.o has not been generated.

These doesn't make any sense to me.

Is it a linker error?
Why this "compiler-like" error messages as the 3 wxWidges files and sqlite3.c compiled fine?
Or is it about sqlite3.c in combination with that special pch? (sqlite = C, pch = C++?).
But I haven't found a way to disable/ enable pch for sqlite3.c

(These are only the very first, simple steps...! Discouraging I can tell ...)
nji
Earned a small fee
Earned a small fee
Posts: 22
Joined: Wed May 03, 2017 8:03 am

Re: Problems building wxWidgets 3.0.5 and sqlite 3.31 (amalgamation)

Post by nji »

... short addendum for clearification:

The "strange order" of the build log message actually came from multitreaded building.
If I swith to 1 horse, the errors all belong to sqlite3.c and its use of (C++) pch etc.

I hope there will still some help here although it's not a pure wxWidget problem,
but ... well? ... CB build system ...?

Regards
Post Reply