Reputation: 2879
I try to use dlib in Qt project on Windows. After downloading I did this in the dlib root:
cd examples
mkdir build
cd build
cmake .. -G"Visual Studio 14 2015 Win64"
cmake --build . --config Release
And this(again in dlib root):
mkdir build
cd build
cmake .. -G"Visual Studio 14 2015 Win64" -DCMAKE_INSTALL_PREFIX=D:\dlib_build
cmake --build . --config Release --target install
My .pro file:
QT += core
QT -= gui
CONFIG += c++11
TARGET = dlibWin2
CONFIG += console
CONFIG -= app_bundle
TEMPLATE = app
SOURCES += main.cpp
INCLUDEPATH += "D:\dlib_build\include"
LIBS += -L"D:\dlib_build\lib" -ldlib
QMAKE_CXXFLAGS_RELEASE += /arch:AVX
QMAKE_CXXFLAGS += -DDLIB_JPEG_SUPPORT
main.cpp:
#include <QCoreApplication>
#include <dlib/image_processing/frontal_face_detector.h>
#include <dlib/image_processing/render_face_detections.h>
#include <dlib/image_processing.h>
#include <dlib/gui_widgets.h>
#include <dlib/image_io.h>
#include <iostream>
using namespace dlib;
using namespace std;
int main(int argc, char *argv[])
{
QCoreApplication a(argc, argv);
try
{
frontal_face_detector detector = get_frontal_face_detector();
}
catch (exception& e)
{
cout << "\nexception thrown!" << endl;
cout << e.what() << endl;
}
return a.exec();
}
Compilation output for MSVC2015 64bit Release:
D:\dlib_build\include\dlib\config.h:19: Warning: C4005: DLIB_JPEG_SUPPORT
Runtime output for MSVC2015 64bit Release:
The program has unexpectedly finished... Exited with code -1073741795
Please note that I did this after Windows reinstalling, and before this I got absolutely the same issue.
How can I solve this or how can I use dlib in Qt on Windows?
Upvotes: 1
Views: 831
Reputation: 2511
As you dont see an exception output - the problem should be in /arch:AVX part. May be your processor does not support AVX instructions. In x64 mode SSE2 will be enabled automatically
Try this .pro file:
QT += core
QT -= gui
CONFIG += c++11
TARGET = dlibWin2
CONFIG += console
CONFIG -= app_bundle
TEMPLATE = app
SOURCES += main.cpp
INCLUDEPATH += "D:\dlib_build\include"
LIBS += -L"D:\dlib_build\lib" -ldlib
No need to rebuild examples and dlib. -DDLIB_JPEG_SUPPORT removed because you have C4005 warning.
You are one one step from success!
Upvotes: 2