Building Qt for Linux x86 with fontconfig support - qt

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.

Related

Compile CUDA (.cu) file into a shared object (.so) using Ubuntu [duplicate]

I'm trying to compile CUDA code using nvcc on Ubuntu. However, when I do, I get this output:
> make
/usr/local/cuda/bin/nvcc -m64 --ptxas-options="-v" -gencode arch=compute_11,code=sm_11 -gencode arch=compute_13,code=sm_13 -gencode arch=compute_20,code=sm_20 -gencode arch=compute_30,code=sm_30 -gencode arch=compute_35,code=sm_35 -o main main.cu
gcc: No such file or directory
make: *** [main] Error 1
Even when I'm trying to compile a file with only a main function in it, it still doesn't work:
> /usr/local/cuda/bin/nvcc main.cu
gcc: No such file or directory
nvcc seems to respond to --version, so it's definitely there. I'm not sure why it's invoking gcc though.
nvcc is not a compiler in itself. It's a "compiler driver", orchestrating the entire process of compiling device code, host code and linking it together. On Linux, it uses gcc for compiling the host code.
To install gcc on Ubuntu:
$ sudo apt-get --yes install build-essential

mingw cross compiler won't link qt libs statically

I'm having trouble getting Qt to statically link its libraries when cross compiling from my Linux machine to windows. I added this to my config to make compile statically.
win32:CONFIG += -static
And by looking at the output of make it seems to have passed the flags correctly (omitting object files to make it short)
i686-w64-mingw32-g++ -static -static-libstdc++ -static-libgcc -Wl,-subsystem,windows -mthreads [exe and object files] /usr/i686-w64-mingw32/lib/libQt5Widgets.dll.a -ldwmapi -luxtheme /usr/i686-w64-mingw32/lib/libQt5Gui.dll.a -lopengl32 -lgdi32 -lcomdlg32 -loleaut32 -limm32 -ljpeg -lpng -L/usr/i686-w64-mingw32/lib -lfreetype -lbz2 -lharfbuzz -lm -lintl -lglib-2.0 -lshlwapi -lpcre -lgraphite2 /usr/i686-w64-mingw32/lib/libQt5Core.dll.a -lz -lpcre2-16 -liconv -lversion -lnetapi32 -luserenv -lole32 -luuid -lwinmm -lws2_32 -ladvapi32 -lshell32 -luser32 -lkernel32 /usr/i686-w64-mingw32/lib/libglu32.a /usr/i686-w64-mingw32/lib/libopengl32.a /usr/i686-w64-mingw32/lib/libgdi32.a /usr/i686-w64-mingw32/lib/libuser32.a -lmingw32 /usr/i686-w64-mingw32/lib/libqt5main.a -lshell32
As you can see the static flags are being passed to the compiler correctly, however I tried running the resulting exe in both WINE, and on a windows machine but in both cases it tells me that it failed to find the Qt dlls. The wine error log had more info so that's the one im providing
0009:err:module:import_dll Library Qt5Core.dll (which is needed by L"Z:\\home\\zee\\mapper\\release\\mapper.exe") not found
0009:err:module:import_dll Library Qt5Gui.dll (which is needed by L"Z:\\home\\zee\\mapper\\release\\mapper.exe") not found
0009:err:module:import_dll Library Qt5Widgets.dll (which is needed by L"Z:\\home\\zee\\mapper\\release\\mapper.exe") not found
0009:err:module:LdrInitializeThunk Importing dlls for L"Z:\\home\\zee\\mapper\\release\\mapper.exe" failed, status c0000135
I'm running on an Arch Linux machine with the latest qt5base aur package (5.13.1), and the latest mignw package (g++ 9.2.0)
Your compiler command line has both static and dynamic libraries. For instance: "/usr/i686-w64-mingw32/lib/libQt5Core.dll.a" is the import library for the dynamic "Qt5Core.dll". The right file to be linked in static mode would be "libQt5Core.a". Your problem looks similar to this report of the mingw project: https://github.com/msys2/MINGW-packages/issues/4970

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

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'

Connecting kdb+ to R

I'm trying to run a make file to install qserver on my OSX machine.
The make file gives me an error when I try to run. see code below:
make
/Library/Frameworks/R.framework/Resources/bin/R CMD gcc -g -O -fpic -m64 -shared -D KXVER=3 -I. -I/Library/Frameworks/R.framework/Resources/share/include base.c c.o -lpthread -L/Library/Frameworks/R.framework/Resources/share/lib -lR -o qserver.so
/Library/Frameworks/R.framework/Resources/bin/R: /Library/Frameworks/R.framework/Resources/bin/R: cannot execute binary file
make: *** [all] Error 126
Hoping someone can give me a pointer here on how to fix it.
Do you have the right version of gcc? I build with gcc-4.8 and have no issues. I recall a thread on the kdb list that mentioned the build required some features available only in later gcc versions. Give that a try.
[EDIT]
Nevermind, just saw that the error says the R binary was not found. Edit the make file to use the appropriate path for your R installation. If you don't have R installed, I suggest installing with homebrew:
brew tap homebrew/science
brew install r
After that you can replace the path in the Makefile as appropriate. I personally changed the Makefile to use $(shell R RHOME) to find the R home path, rather than assume a specific location.
JPC was partially right about gcc.
My system had two different versions of gcc loaded and the default was the standard one. I changed the makefile to run 'gcc-4.8'.
Once I finished that I got a new error: the make file couldn't locate my 'R.h' file...so i just had to reference where my r h-files were located....once I did that the make problem executed.

/usr/bin/ld: cannot find -lfreetype qt

Compiling on Fedora 10.
I am using qt for the first time. I started by creating a simple GUI application with all the default settings. When I tried to build the project I got the following error messages.
However, when I did a search for -lfreetype I found it in the following directory.
/usr/lib/libfreetype.so.6
/usr/lib/libfreetype.so.6.3.18
Is there anyway to resolve this issue?
Many thanks for any advice
Running build steps for project test1...
Creating gdb macros library...
Configuration unchanged, skipping QMake step.
Starting: /usr/bin/make debug -w
make: Entering directory `/home/steve/projects/qt/test1/test1'
/usr/bin/make -f Makefile.Debug
make[1]: Entering directory `/home/steve/projects/qt/test1/test1'
g++ -Wl,-rpath,/opt/qtsdk-2009.01/qt/lib -o test1 debug/main.o
debug/mainwindow.o debug/moc_mainwindow.o
-L/opt/qtsdk-2009.01/qt/lib
-lQtGui -L/opt/qtsdk-2009.01/qt/lib -L/usr/X11R6/lib
-pthread -lfreetype
-lgobject-2.0 -lSM -lICE -pthread -pthread
-lXrender -lfontconfig
-lXext -lX11 -lQtCore -lm -pthread -lgthread-2.0 -lrt
-lglib-2.0 -ldl -lpthread
/usr/bin/ld: cannot find -lfreetype
collect2: ld returned 1 exit status
make[1]: *** [test1] Error 1
make[1]: Leaving directory `/home/steve/projects/qt/test1/test1'
make: *** [debug] Error 2
make: Leaving directory `/home/steve/projects/qt/test1/test1'
Exited with code 2.
Error while building project test1
When executing build step 'Make'
You have to install the freetype-devel package. The devel package contains the header files which in the case of freetype shoud be located at: /usr/include/freetype.
I had the same problem on Ubuntu 8.10, QT 4.5. I "fixed" it with the following bizarre hack:
After the build fails, rename the QT lib directory to something else - e.g. "mv ../../qtsdk-2009.01/qt/lib ../../qtsdk-2009.01/qt/lib2"
Run "make" again, and it will fail again.
Restore the lib directory
Run "make" again, and now it works.
I have no idea why this happens.
Install freetype1-dev libgtk2.0-dev
and it will compile ok.
On Ubuntu 9.04, installing freetype1-dev & libgtk2.0-dev solves this problem.
But to surprise everyone the hack mentioned by Ross also works, I would really like to know how and why.. M looking into the source code of QTcreator to see if i can find out the reason why. If any one already know the reason, please let me know.
Thanks..
Just installed a newly fresh ubuntu 9.04 (dell D820)- installed qt creator nothing else - same problem
use option from S R that works because it needs libgtk2.0-dev (this will also load freetype6 ) installed from package manager.
Same effect you will see if you also install qt designer from package manager (it will install all the right packages
regards
Nico
I had same problems with Elive, freetype1-dev and libgtk2.0-dev and for the /usr/bin/ld: cannot find -lSM thing xorg-dev fixed the problem.
The first thing you have to make sure is that you have libfreetype.so installed in your computer. Use the command 'locate libfreetype.so', and you may find there is a '/usr/lib/libfreetype.so.6' in the result. The compile software can't identify libfreetype.so.6 as a shared library, so, you have to make a symbolic link to the target. Use the command 'ln -s /usr/lib/libfreetype.so.6 /usr/lib/libfreetype.so', when you compile the program again, you will find the error had gone. You can also solve the errors likely. Good Luck!

Resources