How to implement OpenSSL in Qt? - c++

Trying to use OpenSSL in my Qt project, here is my environment:
OS: Win7 32bit
Qt: Qt Creator 4.2.1 Community
Qt Kit: Qt_5_8_0_MSVC2015_32bit2
Openssl: Win32 OpenSSL v1.1.0e, downloaded form this site
I'm trying to include <openssl/evp.h> in my code, however, when I add #include <openssl/evp.h> in my main.cpp and build, Qt Creator shows the following error: D:\QtProjects\dialogs\findfiles\main.cpp:50: error: C1083: 'openssl/evp.h':No such file or directory
I have already followed the instructions in this question: How to Include OpenSSL in a Qt project
My .pro file looks like:
QT += widgets
HEADERS = window.h
SOURCES = main.cpp \
window.cpp
# install
target.path = $$[QT_INSTALL_EXAMPLES]/widgets/dialogs/findfiles
INSTALLS += target
# for openssl - I added these 2 lines
LIBS += -LC:/OpenSSL-Win32/lib -llibcrypto
INCLUDEPATH += C:/OpenSSL-Win32/include
Please help me fix this.

Posting this as an answer because iam pretty sure i figured it out.
You have to run Qmake before building, otherwise changes in your pro File will not be affected. Since Qmake is compiling your pro File into a makefile
Build->Run QMake
Worked for my OpenSSL library.
Good Luck!

Related

A problem about using opencv3.4 with qt creator under windows 8.1

First I follow the basic steps to compile and install opencv using mingw.Here is the result.
compile and install opencv with mingw
Then I add it to the PATH
MinGW64 bulid Environment PATH
Then I edit .pro file in my project like this
INCLUDEPATH += G:\Qt\libs\Eigen3\eigen-3.4-rc1
/
G:\Qt\libs\opencv\build_opencv\install\include
LIBS += G:\Qt\libs\opencv\build_opencv\install\x64\mingw\bin\libopencv_*.dll
.pro file
After qmake the project,I still got "opencv2/core/core.hpp file not found" like this
opencv2/core/core.hpp file not found
My project is under C:\Users\Jc\Desktop\CV\Homework\pastest\untitled1
Qt 5.15.2 MinGW 64-bit
CMake 3.19.2
How could I fix this?
Thanks a lot!
I fix this problem!
Real problem is I edit the .pro file incorrectly.
The correct code should be
INCLUDEPATH += G:\Qt\libs\opencv\build_opencv\install\include
INCLUDEPATH += G:\Qt\libs\Eigen3\eigen-3.4-rc1
CAN'T BE
INCLUDEPATH += G:\Qt\libs\Eigen3\eigen-3.4-rc1 / G:\Qt\libs\opencv\build_opencv\install\include

z.lib problems while porting qt creator projet to windows

I am trying to port a Qt5.9 project from Mac to Windows 10.
I was able to compile the project easily in a ubuntu installation.
While trying to build it for windows, i had problems with finding zlib include headers with
#include<zlib.h>
That i corrected after following answers here on Stack to
#include<QtZlib/zlib.h>
Now i have problems in LINK phase, it can not open the file z.lib
Problem is i downloaded zlib packages, builds, source code and could not find a z.lib. Only different named libs. Searching in google i could only find people with the same problem, z.lib is not one of the libs included in zlib installation.
This is my project file:
TEMPLATE = app
QT += qml quick widgets websockets
CONFIG += c++11
SOURCES += \
main.cpp \
api.cpp \
app.cpp
HEADERS += \
api.hpp \
app.hpp
RESOURCES += qml.qrc
LIBS += -lz
I tried putting all possible dll and lib files in the project folder. None of them is named z.lib though.
The symbols for zlib are already part of the qt libraries. As long as you do not try to link the zlib explicitly it should work. At least it does work for me.
add to your project file:
!win32 {
LIBS += -lz
}
I managed to solve my problem updating my Qt installation to use MinGw 5.3 32bit. I was using VisualStudio 2015 as the compiler before.
Only changing the compiler to MinGw (g++) 5.3 made everything work with the same pro file i posted in the original question. Thanks everybody who tried to help!

How to link QCA to my Qt project?

I have successfully cloned git repository of QCA and built it using
cmake .
make
sudo make install
This created bin directory with some executables and I can confirm everything works as should by running
$ bin/qcatool-qt5 plugins
/usr/lib/x86_64-linux-gnu/qt5/plugins
/home/metheuser/qtcreator/qca/bin
Available Providers:
qca-gnupg
qca-logger
qca-ossl
This product includes cryptographic software written by Eric Young
(eay#cryptsoft.com)
qca-softstore
However when I specify in my Qt project:
QT += crypto
I get this error
Unknown module(s) in QT: crypto
I have no idea how to include the library now. I have tried adding this to my .pro file:
LIBS += -lqca
and
LIBS += -lqca2
Both resulting in error:
cannot find -lqca
What should I do? I followed the official README/INSTALL instructions.
you need to add the lib path to your .pro file. So, Instead of
LIBS += -lqca
you need
LIBS += -L$${PATH_QCA_LIB} -lqca

Fail to link Pylon(Basler) SDK with Qt on Mac

I am trying to link Qt with the Pylon camera SDK in a Qt Creator project.
I install the pylon Camera Software Suite app from this pylon for OS X and the pylon framework is install at /Library/Frameworks/pylon.framework.
I first follow the pylon Programmer's Guide which is installed with the app to link the pylon with Xcode. It works perfectly.
Then I try to link with my Qt Project. I add this in the .pro file:
mac: LIBS += -F/Library/Frameworks/ -framework pylon
# add GenICam because pylon Programmer's Guide do so
INCLUDEPATH += /Library/Frameworks/pylon.framework/Headers/GenICam
DEPENDPATH += /Library/Frameworks
But this doesn't work. Qt cannot find the header files.
I also try:
QMAKE_LFLAGS += -F/Library/Frameworks/
LIBS += -framework pylon
as said in the document Using Frameworks. But still not working. Anyone help me to fix this? Thanks.
Update:
Weird is that Qt can detect auto-complete of the header files but when build it says no such file found.
I just answered this here:
A) If you are compiling this Pylon framework with source then In these cases you need source code installation, you need to go to your
Pylon source directory, e.g.:
<path-to-pylon>/src/include/
You can locate the directory where PylonIncludes.h is installed by
runing the following command:
find <path-to-Pylon> -name PylonIncludes.h
Once you locate the directory e.g. lets say
/Users/kevin/Pylon5.5 then you include add the following line in your
CMAkeLists.txt
INCLUDEPATH += /Users/kevin/Pylon5.5/src/include/
B) If you have binary framework itself then you can workaround by copying all headers to tmporary location under pylon/<all-headers>
cp -rf /Library/Frameworks/pylon.framework/Versions/A/Headers/* /tmp/pylonHeaders/pylon/ Then use following in .pro file
INCLUDEPATH += /tmp/pylonHeaders
LIBS += -framework pylon
There is an automatism in Xcode when you insert a framework it includes the header directory of the used frameworks automatically.
In your case, simple add this line and the compiler will find the pylon headers.
QMAKE_CXXFLAGS += -F/Library/Frameworks
I hope this will help you. With best regards

Qt iOS build does not find headers with path

I am building a working application (Mac and Linux) for iOS emulator in Qt 5.4 but when compiling the sources, compiler shows issues about header files not found. These files definitely are where they should be and the same code/pro builds without issues for desktop versions.
For example, in my code I have included:
#include <sndfile.h>
and in my .pro file I have:
LIBS += -L/usr/local/lib/ -lsndfile.1
INCLUDEPATH += /usr/local/include/
and the header file for libsndfile is definitely in /usr/local/include
I have tried adding this to .pro file
INCLUDEPATH+= $PWD
But no use, still all headers that are not directly in the same folder
as the .pro file cannot be found when compiling... What am I missing?
Is there some different way to define paths to iOS build sources?
I am able to build Qt iOS tutorial projects and run them on the emulator.
Perhaps your Makefile is outdated.
Run qmake again, after changing something in .pro file.