Background
Basically I need a Openssl support for my application, preferably through dynamic linking. For this I have complied the Openssl libraries using the following:
perl configure VC-WIN32 no-asm --prefix=C:\Build-OpenSSL-VC-32
nmake -f ms\ntdll.mak
nmake -f ms\ntdll.mak test
nmake -f ms\ntdll.mak install
using VC 2017 x86 all tests passed. So far so good. Then I compiled qt5 from source using the following configuration:
configure -debug-and-release -opensource -nomake examples -nomake tests -confirm-license --prefix="C:\Work\qt-bin-5.9-VC-17" -skip webengine -platform win32-msvc -openssl -I C:\Build-OpenSSL-VC-32\include -L C:\Build-OpenSSL-VC-32\lib
The build process succeeded with VC 2017. After this I installed the latest version of qt-creator. Then I configured the qt versions/kits and paths to the newly complied version. No other versions are installed on this computer. Next I created a small program to test if everything is working properly. This resulted in QSslSocket::sslLibraryBuildVersionString() returning OpenSSL 1.0.2l 25 May 2017 (version I compiled) and QSslSocket::supportsSsl() returning false. Note I have included:
QT += network
INCLUDEPATH += C:\Build-OpenSSL-VC-32\include
LIBS += C:\Build-OpenSSL-VC-32\lib\libeay32.lib
LIBS += C:\Build-OpenSSL-VC-32\lib\ssleay32.lib
in the .pro file. I've tried adding the .dll instead of the .lib files but I then get the following error.
C:\Build-OpenSSL-VC-32\bin\libeay32.dll:-1: error: LNK1107: invalid or corrupt file: cannot read at 0x2B8
I would really appreciate any help and information about what I did wrong.
It is normal to have an error when you replace the ".lib" by the ".dll", you cannot link directly to a dll. You must link to a ".lib", the ".dll" will be required at execution. But you should not have to link directly to OpenSSL when building your own app, Qt will load them at run-time when they are needed.
QSslSocket::sslLibraryBuildVersionString() returns the version of the SSL library used when you built Qt.
You need to use QSslSocket::sslLibraryVersionString() to get the version number of the run-time SSL library. QSslSocket::supportsSsl() gives info about SSL support at run-time, which may not be available even if SSL support was available when you built Qt itself.
From what you described, it seems that your program fails to find the OpenSSL dll at run-time. Be sure to place libeay32.dll and ssleay32.dll next to your exe file or in your PATH.
Related
I am trying to install OpenCV on my Windows 10 following this guide. In order to install it with my own-build libraries, I need to build qt from the source. I downloaded the latest sources from the qt page (5.6.0, I didn't find any other sources availible), but after typing
configure -release -no-webkit -no-phonon -no-phonon-backend -no-script - no-scripttools
-no-qt3support -no-multimedia -no-ltcg
In VS2013/VS2015 command promt, I got an error:
Unknown option -no-webkit
Unable to detect the platform from environment. Use -platform command line
argument or set the QMAKESPEC environment variable and run configure again.
I have an option just to make everything. But I have to specify the platform. I didn't find how to do it.
Can anyone give me a hint, how to install qt correctly? I have VS 2013 and 2015. I am going to use VS2013, since VS2015 is not supported by CUDA toolkit 7.5.
Thanks,
Mikhail
Update: I was able to begin the installation process by typing configure -platform win32-msvc2013 -mp -release (although I have win64), but after accepting the licence, I got an error: execute: File or path was not found(nmake). Screenshot is attached
have you tried with the MSVC2013 command prompt:
configure -platform win32-msvc2013 -mp -release -no-webkit -no-phonon -no-phonon-backend -no-script -no-scripttools -no-qt3support -no-multimedia -no-ltcg
then type:
nmake
Update:
Also, before that, try adding the path to your Qt source code, with the bin folder, to the PATH variable of windows.
For instance, if your PATH variable is currently set to %SystemRoot%\system32;%SystemRoot%; and your Qt source code is at C:\dev\Qt-5.6\
then set your PATH variable to %SystemRoot%\system32;%SystemRoot%;C:\dev\Qt-5.6;C:\dev\Qt-5.6\bin
This website explains how to change the PATH variable on Windows, in case you're not familiar with it: http://www.computerhope.com/issues/ch000549.htm
Then restart the MSVC2013 Command Prompt, or Windows. I believe that should help the compilation. Let me know if it solves your problem.
What about this:
-skip qtwebkit
Excluding a Qt Submodule
Configure's -skip option allows certain Qt submodules to be excluded from the Qt build. These submodules correspond to the Git submodules in the standard Qt 5 repository. Note that many packages contain multiple Qt modules. For example, to exclude Qt NFC and Qt Bluetooth from the Qt build, provide -skip qtconnectivity as the argument to configure.
There already is a quite related question (rq) here, but it is not specialized enough and my reputation is not high enough to ask for more advice in the comments ... yet, time is running and I've got to get somewhere.
Once the original question is answered, this one can and should be deleted.
What I want: Working in Visual Studio 2015, using the qt-library. That's it.
What I did:
Install vs2015, works
Download the qt5.5.0 source, built it following the (rq) instruction using jom (nmake worked the same, just was slower)
Install the qt package extension for vs2015, also following (rq)
The first error: The building-process didn't create any mkspecs, so i wasn't able to set the directory in the QT-options in visual studio: "This QT version uses an unsupported makefile generator (used:, supported: MSVN.NET, MSBUILD)"
I tried to hack that by replacing it with the mkspec-folder of an installed version to I was able to select the qtbase-folder in the Qt Options.
Played around with the library-directories, the include-directories and the additional-dependencies of the VS-Project. No matter what I did, the include-files where not found.
As this didn't work out, I installed qt 5.5.0 mingw492_32 with the installer. Using that I was able to create a new project with the QTCreator. It compiled in the QTCreator. After that I executed
qmake -platform win32-msvc2015 -tp vs
to convert the project into a Visual-Studio-project, while qmake was the executable from the previously BUILT version, not the installed one, the include-files where still not found in visual studio.
What am I doing wrong? The library-directories, the include-directories and the additional-dependencies look fine to me in the converted project.
EDIT 1:
I followed the walkthrough and everything built successfully. Yet, the mkspecs-folder is still empty. Creating a Qt-Widget-application with the Qt Creator endts up in a crashing app (no changes were made to the default code):
Second Chance Assertion Failed: File minkernel\crts\ucrt\src\appcrt\heap\debug_heap.cpp, Line 980
Calling
qmake -platform win32-msvc2015 -tp vs
also isn't successfull:
qmake -platform win32-msvc2015 -tp vs
WARNING: Unable to generate output for: D:/_Daten/_Studium/Bachelor-Thesis/Visual-Studio/VISAR-FSA/GuiTest/Makefile.Debug [TEMPLATE vsapp]
WARNING: Unable to generate output for: D:/_Daten/_Studium/Bachelor-Thesis/Visual-Studio/VISAR-FSA/GuiTest/Makefile.Release [TEMPLATE vsapp]
EDIT 2:
Concerning the mkspecs: Turns out I had to call both:
jom -j 8
jom install
Now all mkspecs are created. The official documentation made me think that the second one only was an option for the build when a destination path was set.
Yet, a freshly created Qt Widget Application in Qt Creator, with the built and installed QT-version and the correct compiler, still won't compile. A LNK2019 occures in [qtmain.lib(qtmain_win.obj)], telling me that there is a link to a symbol "__imp__CommandLineToArgvW#8" in function "_WinMain#16", that was not resolved.
Here is a complete walkthrough:
How to compile Qt 5 under Windows or Linux, 32 or 64 bit, static or dynamic on VS2010, VS2012, VS2013 or VS2015 Express or g++.
You might want to uninstall all previous Qt.
I have Qt built for VS2015 as well as VS2013 and for 5.50 onwards it shouldn't need anything particularly special to get it to build successfully. I tend to use a cut down version of the Walkthrough that #jafar's mentions (and also closer to the method in the official docs')
Clone the qt5 repository or unzip the source
Start a command prompt. IMPORTANT: create the correct 'VS2015 x86 or x64' prompt
DON'T edit the msvc-desktop.conf as mentioned in the Walkthrough. (Qt can't be built with the /MT flag)
Run configure:
configure -debug-and-release -opensource -platform win32-msvc2015 -opengl desktop -nomake examples -nomake tests
Build with jom -j 8 (I find you get diminishing returns beyond that) or nmake. If you omit the examples and tests I can build the whole of qtbase in about 10-15 minutes
Run jom install or nmake install
I am porting code from qt4 to qt5. I added the following line to my .pro file, as suggested:
QT += webkitwidgets
However, when I run qmake, I get the this error:
Project ERROR: Unknown module(s) in QT: webkitwidgets
I am developing on Ubuntu 12.04 LTS and installed Qt as described.
You need to install the webkitwidgets library.
On Ubuntu, try this in a terminal:
sudo apt-get install libqt5webkit5-dev
On Fedora, the package has a different name, thus try:
sudo apt-get install qt5-qtwebkit-devel
Or on Fedora, via dnf:
sudo dnf install qt5-qtwebkit-devel
If you need to install the webkit* Windows library for Qt 5.7 you should compile it manually because in new version webkit (WebView?) replaced by WebEngine.
Read about Qt 5.7 release (comments): http://blog.qt.io/blog/2016/06/16/qt-5-7-released/
Build sequence (static OR shared):
1) Download Qt 5.7.0 sources: http://download.qt.io/community_releases/5.7/5.7.0/
2) Download required tools: ActiveState Perl (binary), Python (binary), Ruby (binary), GnuWin Bison (binary), GPref (binary), Grep (binary), WinFlex, LibIconv, make (binary), sqlite (source!), ICU (source), windows msys (binary) (unix like shell with the tools), mingw-w64 (bin+dev) for build Qt with QtWebKit, see link on: https://trac.webkit.org/wiki/BuildingQtOnWindows
3) After download ICU source into C:\icu\icu. Open msys QT mingw console shell by open Start windows menu (msys should be downloaded and installed) and search or use fast search. In opened console start configure script and then compile and install:
$ cd C:\icu\icu\source
$ ./runConfigureICU
$ set PATH=%PATH%;C:\msys\1.0\bin\
$ make.exe
$ make.exe install
4) Build Qt with(!) ICU support (set "-icu" to configure) see compile script below. Change PATH to your environment.
Directory structure:
C:\Qt\5.7.0 - download binary version of Qt 5.7.0 here
C:\Qt\5.7.0n - directory for new (compiled) version of 5.7.0 (just make dir)
C:\Qt\Src - download source of Qt 5.7.0 here
C:\Qt\Src\qtbase\compile.bat
set INCLUDE=C:\icu\icu\dist\include
set LIB=C:\icu\icu\dist\lib
set QTDIR=C:\Qt\5.7.0n
set PATH=%PATH%;C:\Qt\Qt5.7.0\5.7\mingw53_32\bin;C:\Qt\Qt5.7.0\Tools\QtCreator\bin;C:\Qt\Qt5.7.0\Tools\mingw530_32\bin;C:\Qt\Src\qtbase\bin;C:\Program Files (X86)\GnuWin32\bin;C:\winflex;C:\Ruby23-x64\bin;C:\Python27;C:\mingw-w64\i686-1\mingw32\bin;C:\icu\bin
set QMAKESPEC=win32-g++
set BUILD_DIR=C:\Qt\Qt5.7.0n
call C:\Qt\Src\qtbase\configure.bat -prefix %BUILD_DIR% -platform %QMAKESPEC% -confirm-license -debug-and-release -opensource -opengl desktop -no-compile-examples -icu -I C:/icu/icu/dist/include -L C:/icu/icu/dist/lib
jom.exe -j 4
pause
Run command in exmaple in Windows Power Shell:
$ cd C:\Qt\Src\qtbase
$ ./compile.bat
After pass through compile use it to install files in the BUILD_DIR (install Qt files):
$ C:\mingw-w64\i686-1\mingw32\bin\mingw32-make.exe install
Qt should start to install
5) Download Qtwebkit sources to C:\Qt\Src\qtwebkit. Use compile script below to compile the qtwebkit using new Qt 5.7.0 build with files in C:\Qt\5.7.0n with ICU.
C:\Qt\Src\qtwebkit\Tools\Scripts\compile.bat
set INCLUDE=C:\sqlite
set LIBS=C:\sqlite
set SQLITE3SRCDIR=C:\sqlite
set QTDIR=C:\Qt\Qt5.7.0n
set PATH=%PATH%;C:\Qt\Qt5.7.0n\bin;C:\Qt\Src\qtbase\bin;C:\winflex;C:\Ruby23-x64\bin;C:\Python27;C:\mingw-w64\i686-1\mingw32\bin;C:\icu\bin;C:\Program Files (x86)\GnuWin32\bin
set QMAKESPEC=win32-g++
call perl.exe .\build-webkit --qt --release
Compile the qtwebkit:
$ cd C:\Qt\Src\qtwebkit\Tools\Scripts
$ ./compile.bat
$ cd C:\Qt\Src\qtwebkit\WebKitBuild\Release
$ C:\mingw-w64\i686-1\mingw32\bin\mingw32-make.exe install
It should be possible to compile your application with the qtwebkit after successfull compile and install.
BUILD QT FOR STATIC
Edit file C:\Qt\Src\qtbase\compile.bat and pass through build.
...
call C:\Qt\Src\qtbase\configure.bat -prefix %BUILD_DIR% -platform %QMAKESPEC% -confirm-license -debug-and-release -opensource -opengl desktop -static -no-compile-examples -icu
echo "QMAKE_FLAGS += -static -static-libgcc" >> .mkspecs/%QMAKESPEC%/qmake.conf
...
POSSIBLE ERRORS
1) While build qtwebkit: "fatal error: unicode/uchar.h: No such file or directory"
Check that your Qt 5.7.0n build with ICU. IT also could notify you about "ICU required" at configure in qtwebkit.
2) flex: unknown flag '-'. For usage, try
You should use correct version of Flex that is "win_flex" in this case. You should rename files to use win_flex instead of just flex (and bison).
1) rename C:\Program Files (x86)\GnuWin32\bin\flex.exe to some unused name.
2) rename C:\Program Files (x86)\GnuWin32\bin\bison.exe to some unused name.
3) rename C:\winflex\win_bison.exe to bison.exe.
3) While build qtwebkit: "fatal error: sqlite3.h: No such file or directory"
Edit file C:\Qt\Src\qtwebkit\Tools\Scripts\compile.bat and check for correct path to sqlite:
set SQLITE3SRCDIR=C:\(path to some SQLITE .h/source files)
4) skipping incompatible ... when searching for ...
You should download right library arch (32bit or 64bit)
5) View.cpp ... undefined reference to WKPageCanGoBack
Could happens when pass through some test or MiniBrowser. You can search in files for the "UIProcess/API/qt" and "MiniBroswer" and remove it from
Makefile's and some other files and then start build again.
LINKS
Build Qt5: https://wiki.qt.io/Building_Qt_5_from_Git Qt WebKit build
like how to: https://trac.webkit.org/wiki/BuildingQtOnWindows ICU
build with GNU: https://wiki.qt.io/Compiling-ICU-with-MinGW
The community builds referenced by Alex are only available until Qt 5.9.
If you want to use newer Qt5 (current version is 5.11), then another option is to port "QtWebKit" to "QtWebEngine".
See: https://wiki.qt.io/QtWebEngine/Porting_from_QtWebKit
I got it to work by copying the webkit and webkitwidgets pri files from a previous installation, 5.5.
~/Qt/5.5/clang_64/mkspecs/modules/
For windows, I just downloaded https://github.com/annulen/webkit/releases/tag/qtwebkit-tp5 and copied the folders to relevant Qt installation folder. Now I can use MinGW Qt5.8 with latest webkit. Thanks to Konstantin and all the contributors for this project!
Only one thing to note - I needed to use the release configuration in Qt.
What works for me is the combination of two answers, I used what #user1251007 suggested + this command
sudo apt-get install libqt5websockets5-dev
find this command line here : link to the stackoverflow response
I'm trying to compile Qt 5.0.1 for Windows under Visual Studio 2010 (VS2010), because of the famous problem with OpenGL, where the only the ES version of OpenGL is with the precompiled version of Qt.
I'm getting the error at qeglplatformcontext_p.h:
fatal error C1083: Cannot open include file 'EGL/egl.h': No such file or directory
However, the designated file and directory exist in the 3rdparty files of the Qt source in qtbase\src\3rdparty\angle\include.
The Qt I'm using is qt-everywhere-opensource-src-5.0.1.zip
The steps I follow for compiling are
1- extract files in D:\Qt\Qt5.0.1
2- Open Visual Studio Command Prompt
3- Run the following commands in the directory mentioned in step 1:
set QMAKESPEC=win32-msvc2010
set QTDIR=D:\Qt\Qt5.0.1\qtbase
set PATH=%PATH%;D:\Qt\Qt5.0.1\qtbase\bin
configure -opensource -debug-and-release -developer-build -accessibility -opengl desktop -openvg -platform win32-msvc2010
..\jom\jom.exe -j 32
And then happens the error of EGL/egl.h after approx. 5 minutes.
What should I do to fix this compile error? Please advise.
Another question I have is about exceptions. How can I enable exceptions in this version of Qt? The command -exceptions or -no-exceptions is not valid anymore. Any ideas?
Thanks for any efforts.
I could fix it. I downloaded the repository version using Git, and then used the following commands and it worked. Probably downloading it from the repository wasn't necessary, but this is what I got working so far (still compiling since half an hour with no errors).
set QMAKESPEC=win32-msvc2010
set QTDIR=D:\Qt\Qt5.0.1
set PATH=D:\Qt\Qt5.0.1\bin;%PATH%
configure -debug-and-release -opensource -platform win32-msvc2010 -exceptions
C:\Qt\jom\jom.exe -j 32
this will include OpenGL and the other libraries by default. It's not necessary to define them explicitly.
Good luck guys :)
I've downloaded Qt 4.8.2 library, Qt Creator 2.5.2, and manually installed MingW with w32api version 3.13 and GCC/g++ version 4.7.0.1. My OS is Windows 7 Ultimate x64.
I can create a sample "Plain C++ project" in Qt Creator; compile and run that console application using g++ without any issue.
But I cannot run a Qt application. I used Qt Creator, created a dummy Qt Application using Creator's "Qt Gui Application" template. The project can be compiled successfully, without any error or warning. But the binary keeps crashing when I try to run (both from Qt Creator and Windows Explorer) it. Both debug and release builds crash. It crashes even before showing main window.
MingW is installed in C:\MingW and C:\MingW\bin is in PATH. Qt is installed in C:\Qt\4.8.2 and C:\Qt\4.8.2\bin is in PATH.
I analyzed generated exe of the Qt Gui Application output with Dependency Walker and found that it found all required DLLs:
c:\windows\system32\KERNEL32.DLL
c:\windows\system32\MSVCRT.DLL
c:\mingw\bin\LIBGCC_S_DW2-1.DLL
c:\mingw\bin\LIBSTDC++-6.DLL
c:\qt\4.8.2\bin\QTCORE4.DLL
c:\qt\4.8.2\bin\QTGUI4.DLL
So, what's causing the runtime crash?
EDIT
I also tried Qt's example projects: 2dpainting and addressbook - both crashed when they were launched.
You should build Qt with the MinGW compiler you're using to build your application. GCC is generally less sensitive to binary compatibility issues than MSVC is, but Qt is a big, complex framework library. If anything would expose those kinds of issues, Qt would probably be on the short list.
Building Qt is pretty straightforward, but it takes a lot of time and there always seems to be two or three patches I need to make to get things to build successfully.
The last time I built Qt (4.7.3) with MinGW, I had to make the following patches - I'm not sure whether they will still apply to Qt 4.8:
make sure not to enable C++11 mode in the compiler - there are several macros with concatenated string literals that break under the new C++11 extended literal syntax
there is a problem with how some distributions of MinGW incorporate the Microsoft extensions to float.h - I had to sometimes had to add the line:
#include_next <float.h>
to the end of the MinGW-specific float.h so the generic GCC float.h would get processed properly. I had to do this for nuwen 4.7.0 lib/gcc/i686-pc-mingw32/4.7.0/include/float.h and TDM 4.6.1 32-bit distro lib/gcc/mingw32/4.6.1/include/float.h (the 64-bit distro of TDM didn't need this patch).
patch qmake\Makefile.win32-g++ and qmake\Makefile.win32-g++-sh to remove the -static-libstdc++ option that GCC doesn't recognize (and now errors out on instead of ignores)
patch mkspecs/win32-g++/qmake.conf to move the -Wl, in the QMAKE_LFLAGS_EXCEPTIONS_ON macro to its proper place in QMAKE_FLAGS:
QMAKE_LFLAGS = -Wl,-enable-stdcall-fixup -Wl,-enable-auto-import -Wl,-enable-runtime-pseudo-reloc
QMAKE_LFLAGS_EXCEPTIONS_ON = -mthreads
copy make.exe to mingw32-make.exe in MinGW's bin directory if there's not already a mingw32-make.exe
Then building Qt consists of:
set QTDIR=<location of Qt source directory> # where configure.exe is
set PATH=%QTDIR%\bin;c:\MinGW\bin;%PATH%
set INCLUDE=
set LIB=
cd %QTDIR%
mingw32-make confclean # (this should fail the first time, since there's nothing to clean)
configure.exe -opensource -debug-and-release -nomake examples -nomake demos -nomake tests -platform win32-g++ # and accept the GPL license
mingw32-make
This takes a while... hopefully nothing else will need patching.
I also got this problem. I'm a Qt n00b and tought, when installing Qt-libraries, that "well I already have Mingw installed so I skip installing the Mingw that comes with Qt". That gave me prolems. When installing mingw that came with Qt everything worked ok.
So my advice to anyone googling to this question (like I did) is to instead of using your already installed Mingw, install the one with Qt and use that (otherwise you have to build the Qt libraries within your Mingw, like the answer from Michael Burr)