Building Qt fro Source with MSYS2 / MinGW 64 - ICU headers not found - qt

I followed the instructions from MinGW-64-bit, using Option A: build Qt in MSYS2-shell & MinGW-w64 Win64 Shell.
I downloaded the source code
git clone https://code.qt.io/qt/qt5.git
cd qt5
perl init-repository
git checkout 5.8
After installing all prerequisites I build OpenSSL and ICU - installed in
/usr/local/openssl
/usr/local/icu
But from there on the instructions are not so clear. It's stated to use a windows command shell to set some environment variables. But later I'm using the MSYS2 64 Bit shell, so these have no effect. Here is what I did:
export INCLUDE=/usr/local/icu/include:/usr/local/openssl/include
export LIB=/usr/local/icu/lib:/usr/local/openssl/lib
export QMAKESPEC=
export QTDIR=
windows2unix() { local pathPcs=() split pathTmp IFS=\;; read -ra split <<< "$*"; for pathTmp in "${split[#],}"; do pathPcs+=( "/${pathTmp//+([:\\])//}" ); done; echo "${pathPcs[*]}"; }; systemrootP=$(windows2unix "$SYSTEMROOT"); export PATH="$PWD/qtbase/bin:$PWD/gnuwin32/bin:/c/msys64/mingw64/bin:/c/msys64/usr/bin:/c/msys64/usr/local/icu/lib"
export MAKE_COMMAND=
mkdir qt-build
cd qt-build
../qt5/configure -prefix /opt/qt -debug-and-release -opensource -confirm-license -platform win32-g++ -developer-build -icu -I /usr/local/icu/include -opengl desktop -openssl -plugin-sql-odbc -nomake examples -nomake tests
The configure script stops with the following error:
ERROR: Feature 'icu' was enabled, but the pre-condition 'libs.icu' failed.
In Qt's config.log I found:
looking for library icu
Trying source 0 (type inline) of library icu ...
=> source failed condition 'config.win32 && !features.shared'.
Trying source 1 (type inline) of library icu ...
+ cd C:\msys64\home\asp\qt-build\qtbase\config.tests\unix\icu && C:\msys64\home\asp\qt-build\qtbase\bin\qmake.exe "CONFIG -= qt debug_and_release app_bundle lib_bundle" "CONFIG += shared console" "LIBS += -licuin -licuuc -licudt" C:/msys64/home/asp/qt5/qtbase/config.tests/unix/icu
+ cd C:\msys64\home\asp\qt-build\qtbase\config.tests\unix\icu && set MAKEFLAGS=& C:/msys64/usr/bin/make
> g++ -c -pipe -fno-keep-inline-dllexport -g -frtti -Wall -Wextra -fexceptions -mthreads -DUNICODE -IC:/msys64/home/asp/qt5/qtbase/config.tests/unix/icu -I. -IC:/msys64/home/asp/qt5/qtbase/mkspecs/win32-g++ -o icu.o C:/msys64/home/asp/qt5/qtbase/config.tests/unix/icu/icu.cpp
> C:/msys64/home/asp/qt5/qtbase/config.tests/unix/icu/icu.cpp:40:28: fatal error: unicode/utypes.h: No such file or directory
> #include <unicode/utypes.h>
> ^
> compilation terminated.
> make: *** [Makefile:155: icu.o] Fehler 1
=> source failed verification.
Trying source 2 (type inline) of library icu ...
=> source failed condition '!config.win32'.
test config.corelib.libraries.icu FAILED
Why doesn't the script find the includes? I set them as
parameter '-I /usr/local/icu/include'
export INCLUDE=/usr/local/icu/include:/usr/local/openssl/include
I also tried
parameter '-I /C/msys64/usr/local/icu/include'
export INCLUDE=/C/msys64/usr/local/icu/include:/C/msys64/usr/local/openssl/include
Is there another possibility to give the correct INCLUDE path to the compiler?

Finally I solved this problem!
I removed the complete qt5 folder and started from the beginning. Then I got the following error:
looking for library icu
Trying source 0 (type inline) of library icu ...
=> source failed condition 'config.win32 && !features.shared'.
Trying source 1 (type inline) of library icu ...
+ cd C:\msys64\home\asp\qt-build\qtbase\config.tests\unix\icu && C:\msys64\home\asp\qt-build\qtbase\bin\qmake.exe "CONFIG -= qt debug_and_release app_bundle lib_bundle" "CONFIG += shared console" "INCLUDEPATH += C:/msys64/usr/local/icu/include" "LIBS += -licuin -licuuc -licudt" C:/msys64/home/asp/qt5/qtbase/config.tests/unix/icu
+ cd C:\msys64\home\asp\qt-build\qtbase\config.tests\unix\icu && set MAKEFLAGS=& C:/msys64/usr/bin/make clean && set MAKEFLAGS=& C:/msys64/usr/bin/make
> rm -f icu.o
> g++ -c -pipe -fno-keep-inline-dllexport -g -Wall -Wextra -fexceptions -mthreads -DUNICODE -IC:/msys64/home/asp/qt5/qtbase/config.tests/unix/icu -I. -IC:/msys64/usr/local/icu/include -IC:/msys64/home/asp/qt5/qtbase/mkspecs/win32-g++ -o icu.o C:/msys64/home/asp/qt5/qtbase/config.tests/unix/icu/icu.cpp
> g++ -Wl,-subsystem,console -mthreads -o icu.exe icu.o -licuin -licuuc -licudt
> C:/msys64/mingw64/bin/../lib/gcc/x86_64-w64-mingw32/6.3.0/../../../../x86_64-w64-mingw32/bin/ld.exe: cannot find -licuin
> C:/msys64/mingw64/bin/../lib/gcc/x86_64-w64-mingw32/6.3.0/../../../../x86_64-w64-mingw32/bin/ld.exe: cannot find -licuuc
> C:/msys64/mingw64/bin/../lib/gcc/x86_64-w64-mingw32/6.3.0/../../../../x86_64-w64-mingw32/bin/ld.exe: cannot find -licudt
> collect2.exe: error: ld returned 1 exit status
> make: *** [Makefile:62: icu.exe] Fehler 1
=> source failed verification.
Trying source 2 (type inline) of library icu ...
=> source failed condition '!config.win32'.
test config.corelib.libraries.icu FAILED
So the headers could be found this time! But now the ICU lib couldn't be linked. So I added '-L /C/msys64/usr/local/icu/lib' and tried again:
../qt5/configure -prefix /opt/qt -debug-and-release -opensource -confirm-license -platform win32-g++ -developer-build -icu -I /C/msys64/usr/local/icu/include -L /C/msys64/usr/local/icu/lib -opengl desktop -openssl -plugin-sql-odbc -nomake examples -nomake tests
Qt is now configured for building. Just run 'make'.
Once everything is built, you must run 'make install'.
Qt will be installed into 'C:\msys64\opt\qt'

Related

Mingw32-make Error 1 & 2 while compiling a Libary

I tried everything I could think of already to fix it but after several Hours I just give up. I want to compile a Lib with qmake to include a parse for csv files. Sadly when I use mingw32-make I get this Error:
C:\Users\Deto24\Downloads\qtcsv-1.5\build>qmake ..\qtcsv.pro CONFIG+=[release] DESTDIR=%cd%
Info: creating stash file C:\Users\Deto24\Downloads\qtcsv-1.5\build\.qmake.stash
Project MESSAGE: === Configuration of qtcsv ===
Project MESSAGE: Qt version: 6.0.2
Project MESSAGE: Library version: 1.5.0
Project MESSAGE: Library files will be created in folder: C:/Users/Deto24/Downloads/qtcsv-1.5/build
Project MESSAGE: === Configuration of qtcsv ===
Project MESSAGE: Qt version: 6.0.2
Project MESSAGE: Library version: 1.5.0
Project MESSAGE: Library files will be created in folder: C:/Users/Deto24/Downloads/qtcsv-1.5/build
Project MESSAGE: === Configuration of qtcsv ===
Project MESSAGE: Qt version: 6.0.2
Project MESSAGE: Library version: 1.5.0
Project MESSAGE: Library files will be created in folder: C:/Users/Deto24/Downloads/qtcsv-1.5/build
C:\Users\Deto24\Downloads\qtcsv-1.5\build>mingw32-make
mingw32-make -f Makefile.Release
mingw32-make[1]: Entering directory 'C:/Users/Deto24/Downloads/qtcsv-1.5/build'
g++ -c -fno-keep-inline-dllexport -O2 -std=gnu++1z -Wall -Wextra -Wextra -Werror -Wformat=2 -Wuninitialized -Winit-self -Wswitch-enum -Wundef -Wpointer-arith -Wdisabled-optimization -Wcast-align -Wcast-qual -fexceptions -mthreads -DUNICODE -D_UNICODE -DWIN32 -DMINGW_HAS_SECURE_API=1 -DQTCSV_LIBRARY -DQT_NO_DEBUG -DQT_CORE_LIB -I../../qtcsv-1.5 -I. -I../include -IC:/Qt/6.0.2/mingw81_64/include -IC:/Qt/6.0.2/mingw81_64/include/QtCore -Irelease -IC:/Qt/6.0.2/mingw81_64/mkspecs/win32-g++ -o release\writer.o ..\sources\writer.cpp
In file included from ..\sources\writer.cpp:1:
../../qtcsv-1.5/include/qtcsv/writer.h:6:10: fatal error: QTextCodec: No such file or directory
#include <QTextCodec>
^~~~~~~~~~~~
compilation terminated.
mingw32-make[1]: *** [Makefile.Release:248: release/writer.o] Error 1
mingw32-make[1]: Leaving directory 'C:/Users/Deto24/Downloads/qtcsv-1.5/build'
mingw32-make: *** [Makefile:45: release] Error 2
I'm fairly new to adding Lib's to QT and while there seems no real explains for how to compile those lib's step by step I could gather some Informations by myself. I created the PATH as you can see on the Picture, so I hope that is alright.
Any Ideas what I did wrong?

Conda build R package fails at C compiler issue on MacOS Mojave

I'm trying to install an R package called treatSens with conda to use it in Jupyter notebook. The commands I executed:
conda install conda-build
conda skeleton cran treatSens
conda build r-treatsens
conda install -c local r-treatsens
And I got the error about C compiler
* installing *source* package ‘dbarts’ ...
** package ‘dbarts’ successfully unpacked and MD5 sums checked
checking for gcc... x86_64-apple-darwin13.4.0-clang
checking whether the C compiler works... no
configure: error: in `/Users/myusername/anaconda3/conda-bld/r-dbarts_1543961434509/myenvname':
configure: error: C compiler cannot create executables
See `config.log' for more details
ERROR: configuration failed for package ‘dbarts’
My clang version:
clang version 4.0.1 (tags/RELEASE_401/final)
Target: x86_64-apple-darwin18.2.0
Thread model: posix
InstalledDir: /Users/myusername/anaconda3/envs/myenvname/bin
Looking into the config.log file I see
configure:3570: x86_64-apple-darwin13.4.0-clang -V >&5
clang-4.0: error: argument to '-V' is missing (expected 1 value)
clang-4.0: error: no input files
configure:3581: $? = 1
configure:3570: x86_64-apple-darwin13.4.0-clang -qversion >&5
clang-4.0: error: unknown argument: '-qversion'
clang-4.0: error: no input files
configure:3581: $? = 1
configure:3601: checking whether the C compiler works
configure:3623: x86_64-apple-darwin13.4.0-clang -march=core2 -mtune=haswell -mssse3 -ftree-vectorize -fPIC -fPIE -fstack-protector-strong -O2 -pipe -I/Users/myusername/anaconda3/envs/work/conda-bld/r-dbarts_1543961045662/_h_env_placehold_placehold_placehold_placehold_placehold_placehold_placehold_placehold_placehold_placehold_placehold_placehold_placehold_placehold_placehold_placehold_placehold_placehol/include -fdebug-prefix-map=/Users/myusername/anaconda3/envs/work/conda-bld/r-dbarts_1543961045662/work=/usr/local/src/conda/r-dbarts-0.9_5 -fdebug-prefix-map=/Users/myusername/anaconda3/envs/work/conda-bld/r-dbarts_1543961045662/_h_env_placehold_placehold_placehold_placehold_placehold_placehold_placehold_placehold_placehold_placehold_placehold_placehold_placehold_placehold_placehold_placehold_placehold_placehol=/usr/local/src/conda-prefix -D_FORTIFY_SOURCE=2 -mmacosx-version-min=10.9 -I/Users/myusername/anaconda3/envs/work/conda-bld/r-dbarts_1543961045662/_h_env_placehold_placehold_placehold_placehold_placehold_placehold_placehold_placehold_placehold_placehold_placehold_placehold_placehold_placehold_placehold_placehold_placehold_placehol/include -Wl,-pie -Wl,-headerpad_max_install_names -Wl,-dead_strip_dylibs -Wl,-rpath,/Users/myusername/anaconda3/envs/work/conda-bld/r-dbarts_1543961045662/_h_env_placehold_placehold_placehold_placehold_placehold_placehold_placehold_placehold_placehold_placehold_placehold_placehold_placehold_placehold_placehold_placehold_placehold_placehol/lib -L/Users/myusername/anaconda3/envs/work/conda-bld/r-dbarts_1543961045662/_h_env_placehold_placehold_placehold_placehold_placehold_placehold_placehold_placehold_placehold_placehold_placehold_placehold_placehold_placehold_placehold_placehold_placehold_placehol/lib conftest.c >&5
ld: warning: ignoring file /Library/Developer/CommandLineTools/SDKs/MacOSX10.14.sdk/usr/lib/libSystem.tbd, file was built for unsupported file format ( 0x2D 0x2D 0x2D 0x20 0x21 0x74 0x61 0x70 0x69 0x2D 0x74 0x62 0x64 0x2D 0x76 0x33 ) which is not the architecture being linked (x86_64): /Library/Developer/CommandLineTools/SDKs/MacOSX10.14.sdk/usr/lib/libSystem.tbd
ld: dynamic main executables must link with libSystem.dylib for architecture x86_64
clang-4.0: error: linker command failed with exit code 1 (use -v to see invocation)
It seems it's a problem about Conda build using the certain version of Apple C compiler. My guess is that I need to customize the C compiler for conda build. So my question becomes
What correct gcc version do I need.
How to set it for conda build.
As a quick and dirty workaround (from this comment), I was able to install packages in R using below code in RStudio (opened in conda env)
Sys.setenv(CONDA_BUILD_SYSROOT="/")
Now, you can install any R package via RStudio Console e.g.
install.packages("tidyverse")
Hope this helps.
There are several things you must do to get things building properly in MacOS Mojave. For reasons mysterious to me, the Anaconda folks are not keen to make this smooth, which is especially maddening for those of us who use esoteric R packages. I will write what seems current as of 2019-04-20:
1. Install Xcode (v10.2.1)
2. Install headers in the place open source tends to expect finding them. From the command line:
open /Library/Developer/CommandLineTools/Packages/macOS_SDK_headers_for_macOS_10.14.pkg
3. Install the command-line tools
As a belt-and braces approach, I downloaded and installed the DMG Command_Line_Tools_macOS_10.14_for_Xcode_10.2.1 from https://developer.apple.com/download/more/
I believe this is also what is done by xcode-select --install. If you run that command (once the tools are installed), you should see the message
xcode-select: error: command line tools are already installed, use "Software Update" to install updates
4. Download a copy of older MacOS SDK files. For example, from here
5. Create a directory /opt
sudo mkdir /opt
6. Copy the SDK files there
sudo cp -r ~/Downloads/MacOSX10.9.sdk /opt/
sudo chmod -R a+rX /opt
7. Create a conda_build_config.yaml file that will be referenced by Conda-build and related software. It should contain the following
macos_min_version:
- 10.9
macos_machine:
- x86_64-apple-darwin13.4.0
MACOSX_DEPLOYMENT_TARGET:
- 10.9
CONDA_BUILD_SYSROOT: # [osx]
- /opt/MacOSX10.9.sdk # [osx]
In a terminal you can do that with:
mkdir ~/.conda || echo 'Dir already present'
echo "macos_min_version:" >> ~/.conda/conda_build_config.yaml
echo " - 10.9" >> ~/.conda/conda_build_config.yaml
echo "macos_machine:" >> ~/.conda/conda_build_config.yaml
echo " - x86_64-apple-darwin13.4.0" >> ~/.conda/conda_build_config.yaml
echo "MACOSX_DEPLOYMENT_TARGET:" >> ~/.conda/conda_build_config.yaml
echo " - 10.9" >> ~/.conda/conda_build_config.yaml
echo "CONDA_BUILD_SYSROOT:" >> ~/.conda/conda_build_config.yaml
echo " - /opt/MacOSX10.9.sdk" >> ~/.conda/conda_build_config.yaml
8. Tell Conda about your YAML file via your .condarc. It should contain the lines:
conda_build:
config_file: ~/.conda/conda_build_config.yaml
which can be accomplished using
echo "conda_build:" >> ~/.condarc
echo " config_file: ~/.conda/conda_build_config.yaml" >> ~/.condarc

Building Qt for Linux x86 with fontconfig support

I'm porting my Qt app to Linux for x86 architecture, and since the last official release for that platform is 5.5, I'm trying to do my own build of Qt 5.11.3. I want to use fontconfig to enable use of system fonts. My build platform is Centos 7.5, and I'm using a GCC toolchain which builds x86 binaries with -m32 switch.
The problem is, I can't get it to see the fontconfig library. I've installed it with the package fontconfig-devel-2.13.0-4.3.el7.i686
When running configure with the option -fontconfig, I get the following error message:
ERROR: Feature 'fontconfig' was enabled, but the pre-condition '!config.win32 && features.system-freetype && libs.fontconfig' failed.
My understanding from this is that I have to use -system-freetype and can't use -qt-freetype, but when I try that (also with -feature-freetype), I get this message:
ERROR: Feature 'system-freetype' was enabled, but the pre-condition 'features.freetype && libs.freetype' failed.
The relevant messages in config.log are:
looking for library freetype
Trying source 0 (type pkgConfig) of library freetype ...
pkg-config use disabled globally.
=> source produced no result.
Trying source 1 (type freetype) of library freetype ...
+ cd /home/myuser/qt-build/config.tests/freetype && /home/myuser/qt-build/qtbase/bin/qmake "CONFIG -= qt debug_and_release app_bundle lib_bundle" "CONFIG += shared warn_off console single_arch" -early "CONFIG += cross_compile" 'LIBS += -lfreetype' /home/myuser/qt-build/config.tests/freetype
+ cd /home/myuser/qt-build/config.tests/freetype && MAKEFLAGS= /usr/bin/gmake
> g++ -c -m32 -pipe -O2 -std=gnu++11 -w -fPIC -I. -I/home/myuser/qt-everywhere-src-5.11.3/qtbase/mkspecs/linux-g++-32 -o main.o main.cpp
> main.cpp:2:22: fatal error: ft2build.h: No such file or directory
> #include <ft2build.h>
> ^
> compilation terminated.
> gmake: *** [main.o] Error 1
=> source failed verification.
test config.qtbase_gui.libraries.freetype FAILED
Now, I do also get this message:
WARNING: Cross compiling without sysroot. Disabling pkg-config
which I understand is the source of the "source 0" failure. I have however tried to point configure manually point it to the freetype include directory, by passing FREETYPE_INCDIR=/usr/include/freetype2 to configure; however, as can be seen in the log file, the value does not seem to be used when detecting freetype.
Am I missing a trick here, or are the configure scripts broken? And if it's the latter, is there a way to work around this?
EDIT: For completeness, the environment for running configure:
CFLAGS=-m32
CXXFLAGS=-m32 --std=c++1x
Configure flags:
-opensource
-xplatform linux-g++-32
-nomake tests -nomake examples -nomake tools
-prefix /home/myuser/qt_install/
-qpa xcb
-no-use-gold-linker
-icu ICU_PREFIX=/home/myuser/icu_install ICU_LIBS="-licui18n -licuuc -licudata"
-no-opengl
-fontconfig -feature-freetype -system-freetype FREETYPE_INCDIR=/usr/include/freetype2
Try using the Freetype library that is included inside Qt's sources: when running configure use the flag "-qt-freetype"
I've found it's possible to work around this by setting CPATH (and LIBRARY_PATH to point at a specific build of Freetype which it turned out I needed as well). It looks like the fact that FREETYPE_* variables are ignored when detecting the presence of Freetype is indeed a bug in the config scripts.

Why do I have put linker flags for X libraries in my Makefile when integrating static libQtGui and libQtCore

When I make static libraries of Qt (libQtCore.a and libQtGui.a) using following steps
1) cd to path for qt-x11-commercial-src-4.3.3
2) setenv PATH /pathto-qt-x11-commercial-src-4.3.3/bin:$PATH
3) gmake confclean
4) ./configure -release -static -largefile -qt3support -qt-libpng -qt-libmng -qt-libtiff -qt-libjpeg -glib -platform linux-g++-64 -confirm-license -no-openssl -no-qdbus -prefix ./static_new -prefix-install -opengl -sm -L/usr/lib64 -lSM -lICE -xshape -lX11 -xinerama -lXinerama -xcursor -lXcursor -xfixes -lXfixes -xrandr -lXrandr -xrender -lXrender -fontconfig -lfontconfig -tablet -lXi -xkb -glib -lglib-2.0 -lXext
5) gmake
6 gmake install
then I have to explicitly put following lines in my makefile to link X libraries in my final executable
SLIBS += SM ICE Xi Xrender Xfixes Xrandr Xcursor Xinerama freetype Xext z gthread-2.0 glib-2.0 QtGui QtCore fontconfig
otherwise I get undefined reference for symbols in above X libraries.
But when I make shared libraries of libQtGui.so and libQtCore.so using following steps
1) cd to path for qt-x11-commercial-src-4.3.3
2) setenv PATH /pathto-qt-x11-commercial-src-4.3.3/bin:$PATH
3) gmake confclean
4) configure -release -shared -largefile -qt3support -qt-libpng -qt-libmng\
-qt-libtiff -qt-libjpeg -glib -platform linux-g++-64 -confirm-license -no-openssl -no-qdbus -prefix ./static_new -prefix-install -opengl -sm -L/usr/lib64 -lSM -lICE -xshape -lX11 -xinerama -lXinerama \
-xcursor -lXcursor -xfixes -lXfixes -xrandr -lXrandr -xrender -lXrender \
-fontconfig -lfontconfig -tablet -lXi -xkb -glib -lglib-2.0 -lXext -lz \
-lgthread-2.0
5 gmake
6 gmake install
then I only have to put following lines in my makefile
SLIBS += QtGui QtCore
I do not have to put code in my makefile to link X libraries in the final executable
My question in why do have explicitly link X libraries while integrating static libraries libQtGui.a and libQtCore.a in my final executable

SQLCipher Windows Build

I am unable to build sqlcipher on Windows with following these steps.
install Win32 OpenSSL v0.9.8m
install TclTk
rename MINGWPATH/bin/tclsh84.exe to tclsh.exe
cd sqlcipher
$ ./configure --disable-tcl --disable-amalgamation
CFLAGS="-DSQLITE_HAS_CODEC -I../OpenSSL/include /c/Windows/System32/libeay32.dll"
$ make
$ make dll
$ make install
At the link stage, gcc gives this error:
libtool: link: gcc -g -O2 -DSQLITE_OS_WIN=1 -I. -I./src -I./ext/rtree -D_HAVE_SQ
LITE_CONFIG_H -DBUILD_sqlite -DNDEBUG -DSQLITE_THREADSAFE=1 -DSQLITE_OMIT_LOAD_E
XTENSION=1 -DHAVE_READLINE=0 -o .libs/sqlite3.exe ./src/shell.c ./.libs/libsqli
te3.a -lpthread -L/usr/local/lib
./.libs/libsqlite3.a(func.o): In function `sqlite3RegisterBuiltinFunctions':
c:\sqlcipher/./src/func.c:1439: **undefined reference to `sqlcipher_exportFunc**'
collect2: ld çıkış durumu 1 ile döndü
make: *** [sqlite3.exe] Error 1
You forget to define SQLITE_TEMP_STORE as document has specified.
I can confirm it's working smoothly on Ubuntu 12.04 LTS , with latest source on github:
In short for dynamic linking:
./configure --enable-tempstore=yes CFLAGS="-DSQLITE_HAS_CODEC -DSQLITE_TEMP_STORE=2" LDFLAGS="-lcrypto"

Resources