Skip to content

Instructions_for_compilation_under_MacOSX

Paweł Salawa edited this page Mar 11, 2021 · 6 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 /Users/user/projects/sqlitestudio/scripts/macosx
  • ./compile_build_bundle.sh
    • 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.

That's it. You can copy /Users/user/sqlitestudio/output/SQLiteStudio/SQLiteStudio.app directory to wherever you like and then delete whole /Users/user/sqlitestudio. You don't need it anymore. You can run SQLiteStudio.app from Finder.

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(Setting_up_directory_hierarchy_for_compilation "wikilink")
  • Create and go to directory where you want the output files to be created and call: qmake path/to/SQLiteStudio3/project/directory
  • Then call: make
  • Repeat 2 previous steps for Plugins directory.
  • Go back to the first directory you created 3 steps earlier and call: make bundle
  • Binaries can be found in ../output/SQLiteStudio. Enjoy ;)

Manual compilation - more detailed description

What you need

  • XCode command line tools.
  • Qt 5.12 or later (required Qt modules: core, gui, widgets, script, network, xml, svg, uitools, printsupport)
  • tcl - dependency for ScriptingTcl plugin (optional - you can disable compiling ScriptingTcl by editing the Plugins.pro file). You get Tcl by default with the system (with xcode SDK you also get required headers), or you can install the ActiveTcl distribution.

Downloading source code

Downloading source code tar.gz 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.

  • Main source code (the application) and standard plugins:

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

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

Source code layout

MacOS X the directory structure is almost the same as for Linux, except we also use the lib and include directories for some extra dependencies (like under Windows):

$ tree -L 2
.
├── include
│   ├── sqlite.h
│   └── sqlite3.h
├── lib
│   ├── libsqlite.a
│   └── libsqlite3.dylib
└── sqlitestudio
    ├── Plugins
    └── SQLiteStudio3

During compilation the "output" directory will be created, just next to SQLiteStudio3 and Plugins. It will contain compilation objects in "build" subdirectory and the final executables in "SQLiteStudio" subdirectory.

Compilation

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

cd /Users/user/projects/sqlitestudio
mkdir output
cd output
mkdir 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
make

Note, that if you have multiple Qt versions installed on your system, you will need to make sure which qmake your running. Test it:

qmake --version

If it's not the one you want to build with, then you need to type full path to the qmake you want, for example:

/opt/myQtVersion/bin/qmake

External libraries, depencencies

Some plugins might depend on some external libraries. If dependency headers and libraries are in unusual directories, you will have to provide those directories in a standard manner for qmake, for example:

qmake "INCLUDEPATH += /my/custom/path/include" "LIBS += -L/my/custom/path/lib"

Don't execute it yet. This is just an example of additional parameters for qmake that you might need later on.

Main project

We will apply what we learned from above:

$ pwd
/Users/user/projects/sqlitestudio/output/build
$ qmake ../../SQLiteStudio3
$ make

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

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 a working application binary there.

Bundle and dmg file

This will create MacOS bundle that can be run on any other Mac:

$ make bundle

This will create the same bundle and additionally will create a dmg file, so it can be distributed for others to install:

$ make dmg

The OSX bundle also contains the CLI application, but to run it one has to type the full path to the binary in the terminal: SQLiteStudio.app/Contents/MacOS/sqlitestudiocli

Official plugins

$ pwd
/Users/user/projects/sqlitestudio/output/build
$ mkdir Plugins
$ cd Plugins

and then we go:

$ qmake ../../../Plugins
$ make

That's all. Plugin binary will be placed in /Users/user/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:

$ pwd
/Users/user/projects/sqlitestudio/output/build
$ mkdir MyPlugin
$ cd MyPlugin

and then we go:

$ qmake ../../../MyPlugin
$ make

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

Optional compilation settings

Additional paths for headers and libraries

You might want to provide paths for headers and libraries that the project depends on (for SQLite library for example). Here's how you do it:

  • For headers:

    qmake ../../SQLiteStudio3 "INCLUDEPATH += /path/to/includes/dir"
  • For libraries:

    qmake ../../SQLiteStudio3 "LIBS += /path/to/libraries/dir"

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=/usr/lib/sqlitestudio" "DEFINES += ICONS_DIR=/usr/share/sqlitestudio/icons" \
      "DEFINES += FORMS_DIR=/usr/share/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:

make -j 4

Automatic updates

Since version 3.0.6 automatic updates are compiled always when the portable distribution is being compiled (and only then). Otherwise automatic updates are disabled.

Before 3.0.6:

Prior to version 3.0.6 automatic updates were enabled by default and could be disabled by flag NO_AUTO_UPDATES passed to qmake:

qmake "DEFINES += NO_AUTO_UPDATES"

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