I followed the instructions for the Qt static build as described in https://wiki.qt.io/Building_a_static_Qt_for_Windows_using_MinGW. Running the script on my Windows 10 machine just works fine and builds Qt statically. However, since I require OpenSSL support I can not compile my program with the static build produced from the .psscript.
Therefore, I slightly changed the configure.bat options of the .ps script from -no-openssl to
-openssl-linked
-I C:\OpenSSL-Win32\include
-L C:\OpenSSL-Win32\lib\VC\static
OPENSSL_LIBS="-lUser32 -lAdvapi32 -lGdi32 -lCrypt32"
OPENSSL_LIBS_DEBUG=-"lssleay32MTd -llibeay32MTd"
OPENSSL_LIBS_RELEASE="-lssleay32MT -llibeay32MT
to enable OpenSSL support in a static Qt build, based on the anwseres from:
QT https SSL support for static QT static program build - getting 'Protocol "https" is unknown'
and
Is there any way to building static Qt with static OpenSSL?
Running the script now produces not further specified errors in the make install steps. The -lUser32 -lAdvapi32 -lGdi32 -lCrypt32 libs are not in any subfolder of my OpenSSL-Win32 installation but can be found in C:\Windows\System32\.
I interpret the question as:
How can I build Qt static from source enabling OpenSSL support at the
project installation target?
One of possible ways is:
Static Qt build: configure -static -debug-and-release -openssl -I %OPENSSL_HOME%\include -L %OPENSSL_HOME% and more options
Link the project executable with same SSL at %OPENSSL_HOME%
Distribute the corresponding libeay32.dll and ssleay32.dll altogether with the rest of executables
Related
So I follow the official tutorial for the installation : https://mongodb.github.io/mongo-cxx-driver/mongocxx-v3/installation/
Neverless, I can't use the produced libraries as static.
So I managed to compile the C version of the driver as described, I've enabled the flag --enable-static=yes with the ./configure before doing make && sudo make install and I got the libmongoc-1.0.a and the libbson-1.0.a which are static. So this far, everything it's alright.
Then I have done the cxx version of the driver, except that there is no configuration file as in the C version. So I've juste done a
cmake -DCMAKE_BUILD_TYPE=Release -DBSONCXX_POLY_USE_BOOST=1 -DCMAKE_INSTALL_PREFIX=/usr/local
from the build folder, followed by a make && sudo make install
So I got the libmongocxx.a and the libbsoncxx.a, but when I try to compile with them, I can't run the binary because I got the following error :
error while loading shared libraries: libmongocxx.so._noabi: cannot open shared object file: No such file or directory
So I understand that is because there is some symbols missing and then I need to use the shared library to run the binary but I don't want this to happend, I want the symbols within the binary that I can run it without any LD_PRELOAD.
Any suggestions ?
I had the same issue in an Ubuntu 16.04 and I run a apt-get update & apt-get upgrade and the problem was solved.
It seems that there were some update to the compiler and some libraries that prevent some test from reaching the shared libraries.
I have a similar question, and solved, now I compiled and run my binary with static libs successfully.
I write my build script using newlisp, but the static link options are very helpful, I paste it here.
c++ /to/your/path/site/code/back_end/builder/object/files1.cc.o ... /to/your/path/site/code/back_end/builder/object/files10.cc.o -o bin/site -static-libgcc -static-libstdc++ -L/usr/lib -lpthread -l:libmongocxx.a -l:libbsoncxx.a -l:libmongoc-1.0.a -l:libbson-1.0.a -lrt -lssl -lcrypto -lsasl2 -l:libboost_log.a -l:libboost_log_setup.a -l:libboost_system.a -l:libboost_thread.a -l:libboost_filesystem.a -lcppcms -lbooster -lcurl -ljsoncpp
In order to add the protobuf library from google to my Qt Project I did the following steps. I use Windows 10 and Qt 5.6 with the mingw32compiler.
1 Install protobuf
Therefore I installed MSYS with mingw and cd to the protobuf-3.0.0-beta-2 directory where I ran the configure script ./configure --prefix= 'cd /c/qt/Tools/mingw492_32/ ; pwd -W making sure to install protobuf in the Qt compiler directory. Afterwards I ran makeand make install.
2 Compile Project with protobuf
Now I add the include path INCLUDEPATH += C:/qt/tools/mingw492_32/includeand the library path LIBS += $$PWD/../protobuf-3.0.0-beta-2/src/libs/libprotobuf.a to my Qt project files to make the google protobuf available.
Compiling my project works but I receive a lot of warnings since the protobuf library has a lot of unused parameters / dummy functions. Is there any way to turn of the warnings obtained from the external protobuf library?
You need to tell the compiler that the protobuf headers are system headers. The -I flag tells the compiler where to look for non-system headers, whereas -isystem gives directories containing system headers. System headers do not produce warnings. But INCLUDEPATH uses -I.
Instead of:
INCLUDEPATH += C:/qt/tools/mingw492_32/include
Try:
QMAKE_CXXFLAGS += -isystem C:/qt/tools/mingw492_32/include
I am trying to build a standalone Qt app without any DLLs needed. I recompiled Qt 5.4.1 statically. When I compile and run an application, it doesn't require any Qt DLLs, but it requires libgcc_s_dw2-1.dll instead. I have also edited my mkspecs before configuring and building Qt, I edited these values:
QMAKE_CFLAGS = -pipe -fno-keep-inline-dllexport -static -static-libgcc
QMAKE_CXXFLAGS = -pipe -fno-keep-inline-dllexport -static -static-libgcc -static-libstdc++
(added -static -static-libstdc++ and -static-libgcc)
I also added a QMAKESPECS environment variable.
When I build something using Qt, I can always see this options in the output, so I am sure that the mkspecs are applying.
When I build a non-Qt program with these options (-static -static-libgcc -static-libstdc++), it doesn't need any DLLs when I run it.
Can somebody help me?
I use Qt 5.4.1 and MinGW-w64 4.9.2
I solved my problem now. The problem was that although I edited the variable QMAKE_CXXFLAGS, it was still linking the standard libraries dynamically when linking the application itself, because it doesn't use this variable in the final step of the compilation. I only edited the mkspecs again and added the -static option to the variable QMAKE_LIBS and it works now, I have a standalone Qt application.
Can someone please guide me on the method,as to how I would compile wxwidget using windows command prompt or MSYS. [I can't seem to find anything on the wxwiki/wxwidget official book/anywhere else]
I have already compiled wxwidget from the instructions they have provided (using MSYS).
From searching on the Internet it seems one can (maybe?) do it through the use of MAKEFILE (is that correct?)
if yes: WHAT directory & HOW I should link the wx libraries in the MAKEFILE
if no: what is the way besides MAKEFILE?
I know I can use IDE's like code::block and make life simpler but I prefer to compile using the command prompt/msys.
Thanks in advance.
I have created a video on this topic https://www.youtube.com/watch?v=f6FDNR3lh8E
Here is small and simple steps to follow.
Pre-Requirements :
GNU g++ compiler downloaded and installed.
Set gcc/g++ path to Enviroment Variable.
Download WxWidgets Binaries : 1. Header Files, 2. Development Files, 3. DLLs.
Extract then one folder as it is. I have extracted them at D:\WxAPI Folder.
Looks Like :
D:
- WxAPI Folder
- include (Header files has this folder ziped in .7z)
- lib (Development Files & DLL has this folder ziped in .7z and both extracts in this save folder)
Set your project development structure.
My Project Development Structure :
WxExample (Project Folder)
- Build (Folder) : Contains debug and release dlls and exe
- debug (Folder) : Contains debug specific dlls and exe.
- release (Folder) : Contains release specific dlls and exe.
- inlcude (Folder) : Contains project header files.
- src (Folder) : Contains project .cpp files.
- wxCompiler.cmd : Contains compile command created with following steps.
Write Compilation Command
Link Following to Compile.
First Compile Project *.cpp Files :
g++ ".\src*.cpp"
Give Project Output .exe Name :
-o ".\build\release\Project_Name.exe"
Show Project .h File Location to g++ :
-I ".\include"
Provide WxWidget .h Files :
-I "D:\WxAPI\include"
Locate WxWidget setup.h File :
-I "D:\WxAPI\lib\gcc810_x64_dll\mswu"
Supply Binaries Location of WxWidgets :
-L "D:\WxAPI\lib\gcc810_x64_dll"
Provide Compile Flags :
-l wxbase31u
-l wxmsw31u_core
Here D:\WxAPI\lib\gcc810_x64_dll\libwxbase31u.a File Renamed To "wxbase31u"
& D:\WxAPI\lib\gcc810_x64_dll\libwxmsw31u_core.a File Renamed To "wxmsw31u_core" as flag.
You have to add similar file flag as you used in your project as .h
For Example :
-lwxmsw31u_core -lwxbase31u -lwxtiff -lwxjpeg -lwxpng -lwxzlib -lwxregexu -lwxexpat -lkernel32 -luser32 -lgdi32 -lcomdlg32 -lwinspool -lwinmm -lshell32 -lshlwapi -lcomctl32 -lole32 -loleaut32 -luuid -lrpcrt4 -ladvapi32 -lversion -lwsock32 -lwininet -loleacc -luxtheme
Here is Full Command :
g++ ".\src*.cpp" -o ".\build\release" -I "D:\WxExample\include" -I "D:\WxAPI\include" -I "D:\WxAPI\lib\gcc810_x64_dll\mswu" -L "D:\WxAPI\lib\gcc810_x64_dll" -l wxbase31u -l wxmsw31u_core
Run wxWidgets.cmd and that's it. Your exe is in your .\Build\release folder.
Set WxWidget DLL path in Enviroment Variable.
If you do not want to copy paste required dll to your release/debug folder.
It's me again. I just can't understand, why it goes that way!
I downloaded compiled static libs of OpenSSL, from here, this link is on the official cUrl site in Download page. I downloaded Zlib and compiled them, then I compiled libcurl with
mingw32-make mingw32-ssl-zlib
I changed in all makefile.m32 pathes to the Zlib and OpenSSL files. All went fine, I recieved libcurl.a and libcurldll.a. I added into lib folder of my project libcurl.a and libeay32.a, libssleay32.a and libz.a.
I built project - it says that everything is fine. I run - and it just terminated. I'm using MinGW and Eclipse.
It is compiled with this:
g++ -DCURL_STATICLIB -O0 -g3 -Wall -c -fmessage-length=0 -osrc\main.o ..\src\main.cpp
g++ -L..\lib -oYTUploader.exe src\main.o -lcurl -lws2_32 -lwldap32 -leay32 -lssleay32 -lz
I run DependencyWalker, and it says that it's missing ieshims.dll, libeay32.dll and ssleay32.dll. But WHY? Why it want OpenSSL dll, I'm using static linking! I built static libCurl library, with static libs of OpenSSL. About ieshims.dll I also can't get why it needs it!
Help, please, I have no idea what is wrong! I compiled cUrl according to the instruction, everything should be fine..
The openssl-libs you link against seem to be import-libraries. That means they only contain the information your code needs to call functions and then load and call the corresponding functions from the dll.
So the problem is: although you link to static libs, the libs then load and use dynamic dlls. They are no "real" static libs.
One solution is getting other libs (or compile them yourself), or even easier: you just copy the dlls into the directory where your .exe resides and you should be fine.
Use the configure script to tell ld where openssl has installed the files. the defaults are as follows:
tar -zxf curl-7.33.0.tar.gz
cd curl-7.33.0
./configure --prefix=/opt/curlssl --with-ssl=/usr/local/ssl --enable-http --enable-ftp LDFLAGS=-L/usr/local/ssl/lib CPPFLAGS=-I/usr/local/ssl/include
make
make install