diff --git a/BUILDING.md b/BUILDING.md index 65868933d..32c6e168d 100644 --- a/BUILDING.md +++ b/BUILDING.md @@ -1,49 +1,52 @@ ## BUILD INSTRUCTIONS AND REQUIREMENTS -DB Browser for SQLite requires Qt as well as SQLite. For more information on Qt -please consult http://www.qt.io and for SQLite please see https://sqlite.org/. +DB Browser for SQLite requires Qt as well as SQLite.
+For more information on Qt please consult http://www.qt.io and for SQLite please see https://sqlite.org/. Please note that all versions after 3.12.1 will require: * A C++ compiler with support for C++14 or later - -All versions after 3.9.1 will require: -* Qt 5.5 or later, however we advise you to use 5.7 or later -* A C++ compiler with support for C++11 or later +* Qt 5.15.9 later Without these or with older versions you won't be able to compile DB Browser for -Sqlite anymore. This applies to all platforms. However, most likely you won't +SQLite any more.
This applies to all platforms. However, most likely you won't have to worry about these as most systems meet these requirements today. -If you have any chance, please use Qt 5.7 or any later version. Even though Qt +If you can, please use Qt 5.15.9 or any later version.
Even though Qt 5.5 and 5.6 are supported by us, there might be glitches and minor problems -when using them. +when using them.
+Also, it is not possible to build universal binary for macOS using Qt versions lower than 5.15.9. + +The wiki has information that is a bit more detailed or less common, but may be useful: https://github.com/sqlitebrowser/sqlitebrowser/wiki ---- -## Table of Contents -- [Generic Linux and FreeBSD](#generic-linux-and-freebsd) -- [Ubuntu / Debian Linux](#ubuntu--debian-linux) -- [CentOS / Fedora Linux](#centos--fedora-linux) -- [OpenSUSE](#opensuse) -- [macOS](#macos) - - [Building a single executable binary](#building-a-single-executable-binary) - - [Building an .app bundle](#building-an-app-bundle) -- [Compiling on Windows with MSVC](#compiling-on-windows-with-msvc) +- [BUILD INSTRUCTIONS AND REQUIREMENTS](#build-instructions-and-requirements) + - [Linux](#linux) + - [Generic Linux and FreeBSD](#generic-linux-and-freebsd) + - [CentOS / Fedora Linux](#centos--fedora-linux) + - [Debian / Ubuntu Linux](#debian--ubuntu-linux) + - [OpenSUSE](#opensuse) + - [macOS](#macos) + - [Build an `.app` bundle](#build-an-app-bundle) + - [Add the extension to the app bundle (Optional)](#add-the-extension-to-the-app-bundle-optional) + - [Windows](#windows) + - [Compiling on Windows with MSVC](#compiling-on-windows-with-msvc) - [Cross compiling for Windows](#cross-compiling-for-windows) - [Build with SQLCipher support](#build-with-sqlcipher-support) - [Building and running the Unit Tests](#building-and-running-the-unit-tests) - - [Build the unit tests](#build-the-unit-tests) - - [Run the unit tests](#run-the-unit-tests) + - [Build the unit tests](#build-the-unit-tests) + - [Run the unit tests](#run-the-unit-tests) ---- -### Generic Linux and FreeBSD +### Linux +#### Generic Linux and FreeBSD The only requirements for building this code are the presence of Qt5 and -sqlite3. Qt can be included as a static or shared library, depending on the +SQLite 3.
Qt can be included as a static or shared library, depending on the current Qt configuration on the building machine. Provided you have Qt and cmake installed and configured, simply run: - $ cmake . + cmake . There is one potential problem... several Linux distributions provide a QScintilla package compiled for (only) Qt4. If it's present it can confuse @@ -51,102 +54,95 @@ CMake, which will use it during compiling. The resulting program just crashes instead of running. If you experience that kind of crash, try using this cmake command instead when compiling: - $ cmake -DFORCE_INTERNAL_QSCINTILLA=ON + cmake -DFORCE_INTERNAL_QSCINTILLA=ON That tells cmake to compile QScintilla itself, using the source code version we bundle. After the cmake line, run this: - $ make + make in the main directory. This will generate the sqlitebrowser (or `sqlitebrowser.exe`, or `sqlitebrowser.app`) application in the src subdirectory. On some distributions you can then install this in the correct places by running: - $ sudo make install + sudo make install The same process works for building the code in any platform supported by Qt (including other Unix systems with X11.) +#### CentOS / Fedora Linux -### Ubuntu / Debian Linux +>**Note** - On CentOS or an older version of Fedora, you may need to use `yum` instead of `dnf`.
+>**Note 2** - On CentOS 7.x, you need to replace the `qwt-qt5-devel` package name with +`qt5-qtbase-devel` in the `dnf install` line.
+>**Note 3** - On CentOS 8 (Stream), you need to replace the `qt-devel` package name with `qt5-devel` in the `dnf install` line below.
+>Make sure the `PowerTools` repo is enabled. For further information: https://access.redhat.com/discussions/5417621 ```bash -$ sudo apt install build-essential git cmake libsqlite3-dev qtchooser qt5-qmake qtbase5-dev-tools\ - qttools5-dev-tools libsqlcipher-dev qtbase5-dev libqt5scintilla2-dev libqcustomplot-dev\ - qttools5-dev -$ git clone https://github.com/sqlitebrowser/sqlitebrowser -$ cd sqlitebrowser -$ mkdir build -$ cd build -$ cmake -Dsqlcipher=1 -Wno-dev .. -$ make -$ sudo make install +sudo dnf install cmake gcc-c++ git qt-devel qt5-linguist qwt-qt5-devel sqlite-devel +git clone https://github.com/sqlitebrowser/sqlitebrowser +cd sqlitebrowser +mkdir build && cd build +cmake .. +make +sudo make install ``` -**Note** - Use `cmake -DFORCE_INTERNAL_QSCINTILLA=ON -Dsqlcipher=1 -Wno-dev ..` if you're using Debian and meet errors during compiling. - -This should complete without errors, giving you a binary file called 'sqlitebrowser'. - -Done. :) - -### CentOS / Fedora Linux - -**Note** - On CentOS or an older version of Fedora, you may need to use `yum` instead of `dnf`. - -**Note 2** - On CentOS 7.x, you need to replace the `qwt-qt5-devel` package name with -`qt5-qtbase-devel` in the `dnf install` line below. - +This should complete without errors, and `sqlitebrowser` should now be launch-able from the command line. -**Note 3** - On CentOS 8 (Stream), you need to replace the `qt-devel` package name with -`qt5-devel` in the `dnf install` line below. Make sure the `PowerTools` repo is enabled. +#### Debian / Ubuntu Linux -``` -$ sudo dnf install cmake gcc-c++ git qt-devel qt5-linguist qwt-qt5-devel \ - sqlite-devel -$ git clone https://github.com/sqlitebrowser/sqlitebrowser -$ cd sqlitebrowser -$ cmake -Wno-dev . -$ make -$ sudo make install +```bash +sudo apt install build-essential cmake git libqcustomplot-dev libqt5scintilla2-dev libsqlcipher-dev \ + libsqlite3-dev qt5-qmake qtbase5-dev qtbase5-dev-tools qtchooser qttools5-dev qttools5-dev-tools +git clone https://github.com/sqlitebrowser/sqlitebrowser +cd sqlitebrowser +mkdir build && cd build +cmake .. +make +sudo make install ``` -This should complete without errors, and `sqlitebrowser` should now be launch-able from the command line. +>**Note** - Use `cmake -DFORCE_INTERNAL_QSCINTILLA=ON -Dsqlcipher=1 -Wno-dev ..`
+>if you're using Debian and meet errors during compiling. -### OpenSUSE +This should complete without errors, giving you an executable file called `sqlitebrowser`. Done. :) -```bash +> Also, we have a CI workflow for Ubuntu, you can check it out [here](https://github.com/sqlitebrowser/sqlitebrowser/blob/master/.github/workflows/build-ubuntu.yml) +#### OpenSUSE -$ zypper in -y build git-core, libQt5Core5, libQt5Core5-32bit, libqt5-qtbase, libqt5-qtbase-devel, libqt5-qttools, libqt5-qttools-devel, build, gcc-c++, gcc, sqlite3-devel, libsqlite3-0, cmake, sqlcipher-devel -$ git clone https://github.com/sqlitebrowser/sqlitebrowser -$ cd sqlitebrowser -$ mkdir build -$ cd build -$ cmake -Dsqlcipher=1 -Wno-dev -DFORCE_INTERNAL_QSCINTILLA=ON .. -$ make -$ sudo make install +```bash +zypper in -y build build, cmake, gcc, gcc-c++, git-core, libQt5Core5, libQt5Core5-32bit, libqt5-qtbase, libqt5-qtbase-devel, libqt5-qttools, libqt5-qttools-devel, libsqlite3-0, sqlcipher-devel, sqlite3-devel +git clone https://github.com/sqlitebrowser/sqlitebrowser +cd sqlitebrowser +mkdir build && cd build +cmake -DFORCE_INTERNAL_QSCINTILLA=ON .. +make +sudo make install ``` - ### macOS +#### Build an `.app` bundle The application can be compiled to an .app bundle, suitable for placing in /Applications. -### Building an .app bundle - -Building an .app bundle version takes a bit more effort, but isn't too hard. -It requires SQLite and Qt 5.x to be installed first. These are the +Building an .app bundle version takes a bit more effort, but isn't too hard.
+It requires SQLite and at least Qt 5.15.9 to be installed first. These are the [Homebrew](http://brew.sh) steps, though other package managers should work: - $ brew tap sqlitebrowser/sqlite3 - $ brew install sqlitefts5 - $ brew install qt@5 - $ brew install cmake - $ brew link sqlitefts5 --force +```bash +brew tap sqlitebrowser/tap +# If you are using Apple Silicon Mac +brew install db4subqt@5 db4subsqlcipher db4subsqlitefts@5 +# If you are using Intel Mac +brew install db4sqt@5 db4ssqlcipher db4ssqlitefts@5 +``` +> You can don't need SQLCipher support, you can skip `db4ssqlcipher` and `db4ssqlitefts@5`. Then it's just a matter of getting the source: @@ -157,110 +153,60 @@ its name (eg ~/tmp/foo'), as compiling will error out. And compiling it: - $ cd sqlitebrowser - $ mkdir build # You can easily make a fresh build again by removing this directory - $ cd build - $ cmake -DCMAKE_PREFIX_PATH=/usr/local/opt/qt@5 .. - $ cmake --build . - $ brew unlink sqlitefts5 - $ mv sqlitebrowser.app /Applications/DB\ Browser\ for\ SQLite.app - -An icon for "DB Browser for SQLite" should now be in your main OSX Applications -list, ready to launch. - -### Building a universal binary -Building a universal binary is only possible on ARM64 architecture Macs. - -#### Install dependencies -```bash -$ brew tap sqlitebrowser/ub -$ brew install db4sqtub@5 db4ssqlcipherub db4ssqliteftsub@5 -``` -> If you don't need SQLCipher support, you don't need to install `db4ssqlcipherub`.
-> No bottles are provided for Homebrew Formulae, so you have to build them from source, which can take a while.
-> Took 1 hour based on testing on a M2 Mac Mini. - -#### Get the source code -```bash -$ git clone https://github.com/sqlitebrowser/sqlitebrowser -or -$ git clone git@github.com/sqlitebrowser/sqlitebrowser -``` - -#### Change prefix for CMakelists.txt ```bash -$ sed -i '' 's|/opt/homebrew/opt/qt5|/opt/homebrew/opt/db4sqtub@5|g' CMakeLists.txt -$ sed -i '' 's|/opt/homebrew/opt/sqlitefts5|/opt/homebrew/opt/db4ssqliteftsub@5|g' CMakeLists.txt +cd sqlitebrowser +mkdir build && cd build +cmake -DcustomTap=1 .. +cmake --build . +mv DB\ Browser\ for\ SQLite.app /Applications ``` -#### Configure build and build -```bash -$ mkdir build && cd build -# For SQLite -$ cmake -DCMAKE_OSX_ARCHITECTURES="arm64;x86_64" .. -# For SQLCipher -$ cmake -DCMAKE_OSX_ARCHITECTURES="arm64;x86_64" -Dsqlcipher=1 .. -$ cmake --build . -``` +> If you want to build universal binary, change the `cmake` command to
+> `cmake -DcustomTap=1 -DCMAKE_OSX_ARCHITECTURES="arm64;x86_64" ..`
+> Of course, this requires you to have an Apple Silicon Mac and an installation of formula starting with `db4sub`. -#### Prepare for add the extension to the app bundle (Optional) -```bash -$ /opt/homebrew/opt/db4sqtub@5/bin/macdeployqt DB\ Browser\ for\ SQLite.app -``` +An icon for "DB Browser for SQLite" should now be in your main macOS Applications list, ready to launch. #### Add the extension to the app bundle (Optional) -```bash -$ mkdir build/DB\ Browser\ for\ SQLite.app/Contents/Extensions -$ clang -I /opt/homebrew/opt/db4ssqliteftsub@5/include -L /opt/homebrew/opt/db4ssqliteftsub@5/lib -fno-common -dynamiclib src/extensions/extension-formats.c -o formats-arm64.dylib -$ arch -x86_64 clang -I /opt/homebrew/opt/db4ssqliteftsub@5/include -L /opt/homebrew/opt/db4ssqliteftsub@5/lib -fno-common -dynamiclib src/extensions/extension-formats.c -o formats-x86_64.dylib -$ lipo -create -output build/DB\ Browser\ for\ SQLite.app/Contents/Extensions/formats.dylib formats-arm64.dylib formats-x86_64.dylib -$ install_name_tool -id "@executable_path/../Extensions/formats.dylib" build/DB\ Browser\ for\ SQLite.app/Contents/Extensions/formats.dylib -$ ln -s formats.dylib build/DB\ Browser\ for\ SQLite.app/Contents/Extensions/formats.dylib.dylib - -$ clang -I /opt/homebrew/opt/db4ssqliteftsub@5/include -L /opt/homebrew/opt/db4ssqliteftsub@5/lib -fno-common -dynamiclib src/extensions/extension-functions.c -o math-arm64.dylib -$ arch -x86_64 clang -I /opt/homebrew/opt/db4ssqliteftsub@5/include -L /opt/homebrew/opt/db4ssqliteftsub@5/lib -fno-common -dynamiclib src/extensions/extension-functions.c -o math-x86_64.dylib -$ lipo -create -output build/DB\ Browser\ for\ SQLite.app/Contents/Extensions/math.dylib math-arm64.dylib math-x86_64.dylib -$ install_name_tool -id "@executable_path/../Extensions/math.dylib" build/DB\ Browser\ for\ SQLite.app/Contents/Extensions/math.dylib -$ ln -s math.dylib build/DB\ Browser\ for\ SQLite.app/Contents/Extensions/math.dylib.dylib - -$ curl -L -o src/extensions/fileio.c 'https://sqlite.org/src/raw?filename=ext/misc/fileio.c&ci=trunk' -$ curl -L -o src/extensions/test_windirent.c 'https://sqlite.org/src/raw?filename=src/test_windirent.c&ci=trunk' -$ curl -L -o src/extensions/test_windirent.h 'https://sqlite.org/src/raw?filename=src/test_windirent.h&ci=trunk' -$ clang -I /opt/homebrew/opt/db4ssqliteftsub@5/include -L /opt/homebrew/opt/db4ssqliteftsub@5/lib -fno-common -dynamiclib src/extensions/fileio.c src/extensions/test_windirent.c -o fileio-arm64.dylib -$ arch -x86_64 clang -I /opt/homebrew/opt/db4ssqliteftsub@5/include -L /opt/homebrew/opt/db4ssqliteftsub@5/lib -fno-common -dynamiclib src/extensions/fileio.c src/extensions/test_windirent.c -o fileio-x86_64.dylib -$ lipo -create -output build/DB\ Browser\ for\ SQLite.app/Contents/Extensions/fileio.dylib fileio-arm64.dylib fileio-x86_64.dylib -$ install_name_tool -id "@executable_path/../Extensions/fileio.dylib" build/DB\ Browser\ for\ SQLite.app/Contents/Extensions/fileio.dylib -$ ln -s fileio.dylib build/DB\ Browser\ for\ SQLite.app/Contents/Extensions/fileio.dylib.dylib -``` -#### Copy the license file and translations (Optional) -```bash -$ cp LICENSE LICENSE-PLUGINS build/DB\ Browser\ for\ SQLite.app/Contents/Resources/ -$ mkdir -p build/DB\ Browser\ for\ SQLite.app/Contents/translations -$ for i in ar zh_CN zh_TW cs en fr de it ko pl pt pt_BR ru es uk; do - cp -v /opt/homebrew/opt/db4sqtub@5/translations/qt_${i}.qm build/DB\ Browser\ for\ SQLite.app/Contents/translations/ - cp -v /opt/homebrew/opt/db4sqtub@5/translations/qtbase_${i}.qm build/DB\ Browser\ for\ SQLite.app/Contents/translations/ - cp -v /opt/homebrew/opt/db4sqtub@5/translations/qtmultimedia${i}.qm build/DB\ Browser\ for\ SQLite.app/Contents/translations/ - cp -v /opt/homebrew/opt/db4sqtub@5/translations/qtquick1_${i}.qm build/DB\ Browser\ for\ SQLite.app/Contents/translations/ - cp -v /opt/homebrew/opt/db4sqtub@5/translations/qtscript_${i}.qm build/DB\ Browser\ for\ SQLite.app/Contents/translations/ - cp -v /opt/homebrew/opt/db4sqtub@5/translations/qtxmlpatterns_${i}.qm build/DB\ Browser\ for\ SQLite.app/Contents/translations/ - done -``` +> **Note**: The following lines look a bit complicated, but are all commands that you need to run. -#### Add the icon file (Optional) ```bash -$ cp installer/macos/macapp.icns build/DB\ Browser\ for\ SQLite.app/Contents/Resources/ -$ /usr/libexec/PlistBuddy -c "Set :CFBundleIconFile macapp.icns" build/DB\ Browser\ for\ SQLite.app/Contents/Info.plist +/opt/homebrew/opt/db4sqtub@5/bin/macdeployqt DB\ Browser\ for\ SQLite.app +mkdir build/DB\ Browser\ for\ SQLite.app/Contents/Extensions +clang -I /opt/homebrew/opt/db4ssqliteftsub@5/include -L /opt/homebrew/opt/db4ssqliteftsub@5/lib -fno-common -dynamiclib src/extensions/extension-formats.c -o formats-arm64.dylib +arch -x86_64 clang -I /opt/homebrew/opt/db4ssqliteftsub@5/include -L /opt/homebrew/opt/db4ssqliteftsub@5/lib -fno-common -dynamiclib src/extensions/extension-formats.c -o formats-x86_64.dylib +lipo -create -output build/DB\ Browser\ for\ SQLite.app/Contents/Extensions/formats.dylib formats-arm64.dylib formats-x86_64.dylib +install_name_tool -id "@executable_path/../Extensions/formats.dylib" build/DB\ Browser\ for\ SQLite.app/Contents/Extensions/formats.dylib +ln -s formats.dylib build/DB\ Browser\ for\ SQLite.app/Contents/Extensions/formats.dylib.dylib + +clang -I /opt/homebrew/opt/db4ssqliteftsub@5/include -L /opt/homebrew/opt/db4ssqliteftsub@5/lib -fno-common -dynamiclib src/extensions/extension-functions.c -o math-arm64.dylib +arch -x86_64 clang -I /opt/homebrew/opt/db4ssqliteftsub@5/include -L /opt/homebrew/opt/db4ssqliteftsub@5/lib -fno-common -dynamiclib src/extensions/extension-functions.c -o math-x86_64.dylib +lipo -create -output build/DB\ Browser\ for\ SQLite.app/Contents/Extensions/math.dylib math-arm64.dylib math-x86_64.dylib +install_name_tool -id "@executable_path/../Extensions/math.dylib" build/DB\ Browser\ for\ SQLite.app/Contents/Extensions/math.dylib +ln -s math.dylib build/DB\ Browser\ for\ SQLite.app/Contents/Extensions/math.dylib.dylib + +curl -L -o src/extensions/fileio.c 'https://sqlite.org/src/raw?filename=ext/misc/fileio.c&ci=trunk' +curl -L -o src/extensions/test_windirent.c 'https://sqlite.org/src/raw?filename=src/test_windirent.c&ci=trunk' +curl -L -o src/extensions/test_windirent.h 'https://sqlite.org/src/raw?filename=src/test_windirent.h&ci=trunk' +clang -I /opt/homebrew/opt/db4ssqliteftsub@5/include -L /opt/homebrew/opt/db4ssqliteftsub@5/lib -fno-common -dynamiclib src/extensions/fileio.c src/extensions/test_windirent.c -o fileio-arm64.dylib +arch -x86_64 clang -I /opt/homebrew/opt/db4ssqliteftsub@5/include -L /opt/homebrew/opt/db4ssqliteftsub@5/lib -fno-common -dynamiclib src/extensions/fileio.c src/extensions/test_windirent.c -o fileio-x86_64.dylib +lipo -create -output build/DB\ Browser\ for\ SQLite.app/Contents/Extensions/fileio.dylib fileio-arm64.dylib fileio-x86_64.dylib +install_name_tool -id "@executable_path/../Extensions/fileio.dylib" build/DB\ Browser\ for\ SQLite.app/Contents/Extensions/fileio.dylib +ln -s fileio.dylib build/DB\ Browser\ for\ SQLite.app/Contents/Extensions/fileio.dylib.dylib ``` -### Compiling on Windows with MSVC +> Also, we have a CI workflow for macOS, you can check it out [here](https://github.com/sqlitebrowser/sqlitebrowser/blob/master/.github/workflows/build-macos.yml) + +### Windows +#### Compiling on Windows with MSVC Complete setup, build, and packaging instructions with MSVC 2013 x64 are online here:     https://github.com/sqlitebrowser/sqlitebrowser/wiki/Setting-up-a-Win64-development-environment-for-DB4S -### Cross compiling for Windows +#### Cross compiling for Windows These are instructions to cross compile within a Linux system a Windows binary and installer. @@ -273,35 +219,35 @@ Requirements: Get the following mxe packages: - $ make gcc sqlite qt nsis + make gcc sqlite qt nsis After successful compilation go into your mxedir/usr/bin and add 3 symlinks: - $ ln -s i686-pc-mingw32-windres windres - $ ln -s i686-pc-mingw32-makensis makensis - $ ln -s /usr/bin/lrelease + ln -s i686-pc-mingw32-windres windres + ln -s i686-pc-mingw32-makensis makensis + ln -s /usr/bin/lrelease Now cd into your sqlitebrowser source directory and create a build directory for the windows binary and create the correct makefiles: - $ mkdir build-win - $ cd build-win - $ cmake -DCMAKE_TOOLCHAIN_FILE=/path to mxe/usr/i686-pc-mingw32/share/cmake/mxe-conf.cmake .. + mkdir build-win + cd build-win + cmake -DCMAKE_TOOLCHAIN_FILE=/path to mxe/usr/i686-pc-mingw32/share/cmake/mxe-conf.cmake .. Before compiling we have to add the mxe/usr/bin directory to the PATH (so windres and makensis can be found): - $ export PATH=/path to mxe/usr/bin:$PATH + export PATH=/path to mxe/usr/bin:$PATH Now compile: - $ make + make If you additionally want an NSIS installer: - $ make package + make package -done. +Done. ## Build with SQLCipher support @@ -332,15 +278,14 @@ DB Browser for SQLite has unit tests in the "src/tests" subdirectory. ### Build the unit tests -The unit tests are enabled using the cmake variable `ENABLE_TESTING`; +The unit tests are enabled using the cmake variable `ENABLE_TESTING`
it can be passed when running `cmake` to configure sqlitebrowser, for example like this: ```bash -$ mkdir build -$ cd build -$ cmake -DENABLE_TESTING=ON .. -$ make +mkdir build && cd build +cmake -DENABLE_TESTING=ON .. +make ``` ### Run the unit tests