Skip to content

Instructions_for_compilation_under_Windows

Paweł Salawa edited this page May 11, 2021 · 12 revisions

In case of problems

You can always ask for help at discussions.

Automatic compilation (recommended)

  • You will need all the dependencies as described at what you need, below.
  • Then you need to download source code, as described at downloading source code
  • Your source code after unpacking should look like described at source code layout
  • Run cmd.
  • cd C:\projects\sqlitestudio\scripts\win32
  • compile.bat
    • This script may ask you few questions (like how many CPU cores would you like to use for compilation), so answer them.
    • After questions are answered, compilation will start and will take couple of minutes, maybe more, depending on computer performance.
  • When compilation is finished you will want to create a ready to use, runnable disribution. Run create_dist_pkg.bat
    • This will take only a moment and in the end will print:
INFO: Portable distribution created at C:\projects\sqlitestudio\output\portable\SQLiteStudio

That's it. You can copy C:\projects\sqlitestudio\output\portable\SQLiteStudio directory to wherever you like and then delete whole C:\projects. You don't need it anymore.

Manual compilation - short description

  • Get a Qt library
  • Download SQLiteStudio sources and plugins, see downloading source code.
  • Setup source directories like described here: source code layout
  • Create and go to directory where you want the output files to be created and call: qmake path\to\SQLiteStudio3
  • Then call: mingw32-make
  • Repeat 2 previous steps for Plugins directory.
  • Binaries can be found in ..\output. Enjoy ;)

Manual compilation - more detailed description

What you need

  • Qt 5.12 or later (required Qt modules: core, gui, widgets, script, network, xml, svg, uitools, printsupport). Download Qt for MinGW, not for VS.
  • MinGW The MinGW can be installed using Qt installator (downloaded from above). It is available under "Tools" branch of Qt packages. Or you can install it from this link.

For version 3.4.x and later all dependencies below are included in the git repo. For version 3.3.x and older all additional dependencies can be downloaded by clicking here (32-bit) or here (64-bit) Just copy contents of lib and include directories accordingly (to learn how, please see source code layout later at this page). This package includes following:

Downloading source code

Downloading source code zip package (recommended)

The source code can be downloaded from the official download page: http://sqlitestudio.pl/?act=download

Downloading from GitHub

Alternatively you can download a current development source code from GitHub.

  • Git URL for main source code (the application) and standard plugins all together:

https://github.com/pawelsalawa/sqlitestudio.git

Remember, that this is unstable code, being developed per daily basis.

Preparing source code

Source code layout

It's not a big deal. Just make sure that all downloaded projects (main and plugins) are in the same directory.

Regarding dependencies mentioned at the begining of this page (SQLite, Tcl, ...) - you should put headers into include directory and DLLs into lib directory, which are placed at the same level as the downloaded sqlitestudio directory, like this:

c:\projects>tree
C:.
├───include
├───lib
└───sqlitestudio
    ├───Plugins
    │   ├───DbSqlite2
    │   └───SqlExport
    └───SQLiteStudio3
        ├───coreSQLiteStudio
        ├───docs
        ├───guiSQLiteStudio
        ├───sqlitestudio
        ├───sqlitestudiocli
        └───Tests

c:\projects>cd lib

c:\projects\lib>dir
24/02/2014  08:54    <DIR>          .
24/02/2014  08:54    <DIR>          ..
10/10/2013  12:30            40,666 libedit_static.a
10/10/2014  21:52           180 224 quazip.dll
10/10/2014  21:52           160 808 libquazip.a
19/12/2005  12:42           213,504 sqlite.dll
04/09/2013  00:27           625,614 sqlite3.dll
04/09/2013  06:26         1 171 456 tcl86.dll
04/09/2013  06:26           186 172 tcl86.lib

c:\projects\lib>cd ..\include

c:\projects\include>dir
01/01/2014  14:43    <DIR>          .
01/01/2014  14:43    <DIR>          ..
01/01/2014  22:05    <DIR>          quazip
04/03/2013  13:20             6,316 readline.h
04/03/2013  13:46            38,781 sqlite.h
06/12/2013  16:05           353,468 sqlite3.h
06/12/2013  06:26            93 780 tcl.h
06/12/2013  06:26           169 576 tclDecls.h
06/12/2013  06:26             3 286 tclPlatDecls.h

Compilation

Run "cmd".

You need to prepare "build directory" for output files:

cd C:\projects\sqlitestudio
md output
cd output
md build
cd build

Project is based on Qt framework, so each project (main, plugins) will basically require 2 steps (don't execute them like this yet, keep reading, we will execute them later, but with some arguments):

qmake
mingw32-make

Main project

We will now run commands with proper arguments:

cd C:\projects\sqlitestudio\output\build
qmake ..\..\SQLiteStudio3
mingw32-make -j 2

That's it! Compilation will start. Compilation process will produce 2 kinds of output files - temporary build files (makefiles, c++ object files, etc) in C:\projects\sqlitestudio\output\build and output executables and libraries in C:\projects\sqlitestudio\output\SQLiteStudio.

The "-j 2" for "make" tells to use 2 CPU cores (as this became a standard to have at least 2 cores), but it's okay to skip this option.

Note, that the path ..\..\SQLiteStudio3 can be different for you if you decided to use different directories hierarchy. Important thing is to make this path point to the directory where SQLiteStudio3.pro file is.

Files in the secondary directory are the subject of interest. You have an (almost) working application binary there.

Official plugins

cd C:\projects\sqlitestudio\output\build
md Plugins
cd Plugins

and then we go:

qmake ..\..\..\Plugins
mingw32-make

That's all. Plugin binary will be placed in C:\projects\sqlitestudio\output\SQLiteStudio\plugins

Excluding some of plugins

If you don't want to compile some plugin (for example DbSqlite2, because you don't have its required dependency), then just edit Plugins.pro file and remove it from the list.

External (unofficial) plugins

For each plugin you will need to add one build directory more, so it has it's own:

cd C:\projects\sqlitestudio\output\build
md MyPlugin
cd MyPlugin

and then we go:

qmake ..\..\..\MyPlugin
mingw32-make

You have to repeat the same steps for each plugin directory.

Preparing runnable distribution

In "cmd":

cd C:\projects\sqlitestudio\SQLiteStudio3
create_win32_portable.bat

This will create a ready to use application (with all dependency DLLs in place) in the directory: C:\projects\sqlitestudio\output\portable\SQLiteStudio\ You can copy this directory anywhere.

Optionally, if you want to create a zip packages (as they are prepared for SQLiteStudio official releases) you also need to have the 7z.exe available in your system PATH, while running the above batch file.

Optional compilation settings

Compile-time directories definition

You can pass additional flags either to qmake if you want to define some compile-time values of the application. Here are flags and what do they mean:

PLUGINS_DIR=/path/to/plugins Additional directory to look up for plugins.
ICONS_DIR=/path/to/icons Additional directory to look up for icons.
FORMS_DIR=/path/to/forms Additional directory to look up for *.ui files (forms used by plugins).

Example of how to do it:

qmake "DEFINES += PLUGINS_DIR=C:/sqlitestudio_plugins" "DEFINES += ICONS_DIR=C:/sqlitestudio_icons" "DEFINES += FORMS_DIR=C:/sqlitestudio_forms"

Multi-core CPU

If you have multi-core CPU, you can speed up compilation by passing "-j " option to make, where is number of cores you want to use, for example:

mingw32-make -j 4

Troubleshooting

I get errors from compilator/linker

Answer: Things to check out:

  1. Make sure you have required version of Qt (see dependencies at the begining of this document).
  2. Make sure that you used qmake from the correct Qt installation.
  3. If the error is about sqlite symbol, see if you have sqlite header and library available to the compiler and if the sqlite is in required version (see dependencies at the begining of this document).
Clone this wiki locally