I have compiled TBB from source using Mingw following the comment #5 in this post: http://software.intel.com/en-us/forums/topic/291331. That went ok.
When I try to use the new TBB library in a QtCreator project, I end with this errors (ignore the warning messages): http://postimage.org/image/yrrecugix/
Here's the sample code I tried (I omit the non-tbb code):
#include "tbb/task_scheduler_init.h"
int main()
{
tbb::task_scheduler_init init;
/// more things.
}
And here's the .pro file:
TEMPLATE = app
CONFIG += console
CONFIG -= qt
SOURCES += main.cpp
#QMAKE_CXXFLAGS += -fopenmp
#QMAKE_LFLAGS += -fopenmp
INCLUDEPATH += "E:\TRABAJO\LIBRERIAS\tbb-4.1_src\include"
LIBS += -L"E:\TRABAJO\LIBRERIAS\tbb-4.1_src\build\windows_intel64_gcc_mingw4.5.4_debug\" \
-ltbb_debug
Any idea?.
Thanks!.
When built with MinGW on Windows, TBB binaries are tbb.dll and tbb_debug.dll. The option -ltbb_debug in your configuration files probably causes the linker to look for libtbb_debug.<something>. It can't find such a binary and reports about unresolved symbols.
Related
I have the following configuration in the .pro file
TEMPLATE = app
CONFIG += console c++11
CONFIG -= app_bundle
CONFIG -= qt
CONFIG += thread
SOURCES += main.cpp
INCLUDEPATH += /usr/local/include/opencv4
LIBS += -L/usr/local/lib/
LIBS += -lopencv_core
LIBS += -lopencv_highgui
LIBS += -lopencv_imgproc
LIBS += -lopencv_videoio
QMAKE_CXXFLAGS += -D_GLIBCXX_USE_CXX11_ABI=0
INCLUDEPATH += /path/to/libtorch/include
INCLUDEPATH += /path/to/libtorch/include/torch/csrc/api/include
LIBS += -L/path/to/libtorch/lib
LIBS += -ltorch -lc10
OpenCV works absolutely fine without "QMAKE_CXXFLAGS += -D_GLIBCXX_USE_CXX11_ABI=0". With this, however, I get this following errors:
OpenCV works fine with "QMAKE_CXXFLAGS += -D_GLIBCXX_USE_CXX11_ABI=1" as well. But it throws a different set of errors:
Setting "QMAKE_CXXFLAGS += -D_GLIBCXX_USE_CXX11_ABI=0" has been recommended for Libtorch in most of the forums to avoid the errors above.
What could be a solution or some solutions to work around this?
(I am a newbie to both Libtorch and Qt Creator.)
Maybe OpenCV and Libtorch were compiled with a different version of GCC (and different values of _GLIBCXX_USE_CXX11_ABI).
Try recompiling them by yourself and see if things change.
The problem is that you downloaded the wrong ABI version of LibTorch. It looks like that you downloaded the Pre-CXX11 ABI version of LibTorch and OpenCV is compiled with CXX11 ABI. So if you set _GLIBCXX_USE_CXX11_ABI=0, OpenCV throws errors, and if you set _GLIBCXX_USE_CXX11_ABI=1, LibTorch throws errors.
Download the CXX11 ABI LibTorch from PyTorch official website and you won't need to set the _GLIBCXX_USE_CXX11_ABI flag.
About the dual ABI problem of GCC, see https://gcc.gnu.org/onlinedocs/libstdc++/manual/using_dual_abi.html
I tried a simple dylib in macOS and compiled with g++. I made a small sample to test the lib, it works perfect.
Now I made a simple QT app, linked the lib and added the header to the mainwindow.cpp and I always got a fail message Reason: image not found
I read the web and also some other cases here but all is basing on paths.I think it is is not a path problem. Because I made all changes I read in all the cases and also copied the lib in all needed folders, like project folder, build folder. Nothing helps.
I think that QT cannot work with the library and I missed some needed code, like for initialize or export. So that the problem is more inside the dylib and not in QT or Paths values.
Maybe someone can help me here out?
I have tried:
INCLUDEPATH += $$PWD/mylib
DEPENDPATH += $$PWD/mylib
macx: LIBS += -L$$PWD/mylib/ -lmylib
I tried to copy the lib to the build folder and also to the executable folder.
Also edited:
/Users/ingoforster/Documents/Development/Playground/TestGround/mylib:/Users/ingoforster/Qt/5.9.1/clang_64/lib
in Project settings DYLD_LIBRARY_PATH
Set also to DYLD_FRAMEWORK_PATH
Cpp
#include "mylib.hpp"
char *mMessage(void) {
return "Ein sonniger Tag";
}
header
#include <stdio.h>
#include <iostream>
using namespace std;
char *mMessage(void);
compiled with
g++ -std=c++0x --verbose -dynamiclib -o libmylib.dylib mylib.cpp
Sample
#include "mylib.hpp"
int main(void){
char* Ingo = mMessage();
std::cout << mMessage();
}
compiled with
g++ -std=c++0x test.cpp -L./ -lmylib
Actual result is that the sample runs perfect.
But in QT I got:
dyld: Library not loaded: libmylib.dylib
Referenced from: /Users/ingoforster/Documents/Development/Playground/build-TestGround-Desktop_Qt_5_9_1_clang_64bit-Debug/TestGround.app/Contents/MacOS/TestGround
Reason: image not found
10:09:05: The program has unexpectedly finished.
10:09:05: The process was ended forcefully.
/Users/ingoforster/Documents/Development/Playground/build-TestGround-Desktop_Qt_5_9_1_clang_64bit-Debug/TestGround.app/Contents/MacOS/TestGround appears to be compile-linked to your library code but perhaps has not been formally installed to the executable. macdeployqt usually deals with this issue.
You may also do this manually with otool and install_name_tool:
otool -L /path/to/executable
This will list the installed paths to the dylibs in use. You will see your dylib, that is the "/old/path/to/libmylib.dylib"
install_name_tool -change /old/path/to/libmylib.dylib /new/path/to/libmylib.dylib /path/to/executable
Usually, in an .app, the dylib is installed to a subdirectory within the .app folder.
Application.app/
Contents/
MacOS/
executable
Frameworks/
libmylib.dylib
With install_name_tool you can point to the dylib relative to the executable path to make the app portable.
install_name_tool -change /old/path/to/libmylib.dylib #executable_path/../Frameworks/libmylib.dylib /path/to/executable
After some hard investigation and running into the wrong direction with the given answers here I found out, that QTCreator will do all its own:
QTCreator Pro file have to contain:
macx: LIBS += -L$$PWD/mylib/ -lmylib
INCLUDEPATH += $$PWD/mylib
DEPENDPATH += $$PWD/mylib
MediaFiles.files += mylib/libmylib.dylib
MediaFiles.path = Contents/MacOS
QMAKE_BUNDLE_DATA += MediaFiles
When trying to run a simple program using the hdf5-file format i get these messages and the program crashes:
I found posts to other problems like this, but most of them refer to linux and python. I use C++ (Qt Creator) and Windows (Windows 7 64bit) with the MSVC17 64bit Compiler, so these solutions dont work for me.
I don't understand why this occurs, because i simply donwloaded the HDF5 version 1.10.2 and installed it, i don't know why it says something about the version 1.8.15. Where could this come from?
I guess "library version" (1.8.15) is the version of my hdf5.lib file, right?
What does "header version" (1.10.2) mean? I simply #include <hdf5.h> and #include <H5Cpp.h> in the main.cpp and added paths in the hdf5_test_2.pro (my project) file.
Here is my code:
hdf5_test.pro:
TEMPLATE = app
CONFIG += console c++11
CONFIG -= app_bundle
CONFIG -= qt
SOURCES += \
main.cpp
win32: LIBS += -L'C:/Program Files/HDF_Group/HDF5/1.10.2/lib/' -lhdf5 -lhdf5_cpp -lhdf5_hl_cpp
INCLUDEPATH += 'C:/Program Files/HDF_Group/HDF5/1.10.2/include'
DEPENDPATH += 'C:/Program Files/HDF_Group/HDF5/1.10.2/include'
win32:!win32-g++: PRE_TARGETDEPS += 'C:/Program Files/HDF_Group/HDF5/1.10.2/lib/libhdf5.lib'
else:win32-g++: PRE_TARGETDEPS += 'C:/Program Files/HDF_Group/HDF5/1.10.2/lib/liblibhdf5.a'
main.cpp:
#include <iostream>
#include <hdf5.h>
#include <H5Cpp.h>
using namespace std;
using namespace H5;
int main()
{
hid_t file_id;
herr_t status;
file_id = H5Fcreate("file.h5", H5F_ACC_TRUNC, H5P_DEFAULT, H5P_DEFAULT);
status = H5Fclose(file_id);
cout << "Hello World!" << endl;
return 0;
}
The code example i tried to use comes from High Level Introduction to HDF5 (Pages 16/17).
Solved (meaning next error)
I think i solved the problem: There was another Version of HDF5 installed (1.8.15) on the system (the one who used this PC before me installed it).
I told my programm to link my lib (1.10.2) and passed the path, but somehow he found the 1.8.15 version previously installed. I now told my program to link the old version and it worked.
My hdf5_test_2.pro (my project) looks now like this:
TEMPLATE = app
CONFIG += console c++11
CONFIG -= app_bundle
CONFIG -= qt
SOURCES += \
main.cpp
win32: LIBS += -LC:/Anaconda2/Library/lib/ -lhdf5 -lhdf5_cpp
INCLUDEPATH += C:/Anaconda2/Library/include
DEPENDPATH += C:/Anaconda2/Library/include
Nice so far, but i get these two warnings now:
Any ideas, what that means?
I'm trying to use the Sha512 function in openSSL but can't seem to get it to work as I get compiler errors just starting into the code. I include #include <openssl/sha.h> at the top of the .cpp file, then in the action of a button event I put just the following code below.
SHA512_CTX ctx;
SHA512_Init(&ctx);
//Will uncomment below in later if I get SHA512_Init to work
//SHA512_Update(&ctx, string, strlen(string));
//SHA512_Final(digest, &ctx);
I get a linker error telling my undefined symbols for architecture x86_64, implying the function does not exist?
I'm aware QT 5 has a hash function, but I'm limited to QT 4.8 so I can not use the cryptographic sha512 hash function available in the QT 5+ framework.
Any help is appreciated!
Used macports to install openssl
I'm using Mac OS 10.9.2
MAKE FILE
#-------------------------------------------------
#
# Project created by QtCreator 2014-06-11T20:27:49
#
#-------------------------------------------------
QT += core gui network
greaterThan(QT_MAJOR_VERSION, 4): QT += widgets
TARGET = ExchangeTab
TEMPLATE = app
LIBS += -L/usr/include/openssl -openssl
INCLUDEPATH += /usr/include/openssl
SOURCES += main.cpp\
mainwindow.cpp \
httpsocket.cpp \
cloaksend.cpp \
exchange.cpp
HEADERS += mainwindow.h \
httpsocket.h \
cloaksend.h \
exchange.h
FORMS += mainwindow.ui
RESOURCES += \
AppResources.qrc
Looking for cross platform solution please.
You need to link to the right library (openSSL)
Have a look here: How to Include OpenSSL in a Qt project
Specifically, add this to your .pro file.:
LIBS += -L/opt/local/lib/ -lcrypto
For including .h files add this line to your .pro file :
INCLUDEPATH += /opt/local/include
[1] says that the default include path will be /opt/local/include/.
LIBS += -L/usr/include/openssl -openssl
INCLUDEPATH += /usr/include/openssl
This looks incorrect. The OpenSSL libraries are libcrypto (-lcrypto) and libssl (-lssl). There is nolibopenssl(-lopenssl). Try:
LIBS += -L/usr/lib -lcrypto
INCLUDEPATH += /usr/include/openssl
But the libraries are version 0.9.8. You might consider upgrading to 1.0.1h.
$ ls /usr/lib | grep crypto
libcrypto.0.9.7.dylib
libcrypto.0.9.8.dylib
libcrypto.dylib
libk5crypto.dylib
And
$ /usr/bin/openssl version
OpenSSL 0.9.8y 5 Feb 2013
If you choose to upgrade, OpenSSL will install into /usr/local/ssl. Avoid mixing/matching version of OpenSSL with the following.
INCLUDEPATH += /usr/local/ssl/include/openssl
LIBS += /usr/local/ssl/lib/libcrypto.a
Its OK to specify objects and archives in LIBS. See How to add object files to a project in Qt.
Okay so I may have answered my own question but I will need some help understanding why it worked.
My make file was indeed the problem. I added the following 3 lines.
INCLUDEPATH += $$OPENSSL_INCLUDE_PATH
LIBS += $$join(OPENSSL_LIB_PATH,,-L,)
LIBS += -lcrypto
Then it magically compiled just fine. I found these in another project made with QT that compiled for OpenSSL.
Interestingly enough. I removed the top two lines so only the following remained. Then ran the clean on my project to be sure the code was being recompiled.
LIBS += -lcrypto
This also just 'worked' without linker errors. It looks like that is the only command I need. Question is... will that be cross platform friendly if I take this code and compile on linux or windows? That I am not sure, but this worked.
I use Qt 5.0.2 with Mingw 4.7 on windows.
I'm working on a c++ program and i'm trying to get the duration of video files. I found ffmpeg. Now i tried to compile a simple program but I think it fails with the libraries. I've tried to include both the shared and dev but they both will fail. ( Zeranoe FFmpeg builds)
This is my pro file:
TEMPLATE = app
CONFIG += console
CONFIG -= app_bundle
CONFIG -= qt
SOURCES += main.cpp
INCLUDEPATH += C:\programming\ffmpeg-20130606-git--win32-shared\bin
LIBS += -LC:\programming\ffmpeg-20130606-git--win32-shared\bin -lavcodec-55.dll - lavformat-55.dll -lavutil-52.dll
i get errors like:
":-1: error: cannot find -lavcodec-55.dll"
":-1: error: cannot find -lavformat-55.dll"
I've also tried:
INCLUDEPATH += C:\programming\ffmpeg-20130606-git--win32-dev\include
INCLUDEPATH += C:\programming\ffmpeg-20130606-git--win32-dev\lib
LIBS += -LC:\programming\ffmpeg-20130606-git--win32-dev\lib -lavcodec -lavformat -lavutil
LIBS += -LC:\programming\ffmpeg-20130606-git--win32-dev\lib -llibavcodec.dll.a -llibavformat.dll.a -llibavutil.dll.a
Here it gives a error "During startup program exited with code 0x0000135'
I even tried to include each library individually. But no results..
This is my main file:
#include <iostream>
using namespace std;
extern "C" {
#include <libavcodec/avcodec.h> // required headers
#include <libavformat/avformat.h>
}
int main(int argc, char**argv) {
av_register_all(); // offending library call
return 0;
}
A program simple as this will have 2 outcomes:
the program runs but crashes if i call 'av_register_all()'
It just tells me he cannot find the libraries.
Can someone tell me what it is i'm doing wrong? Or even give me a hint? I can't really find a lot of good documentation on this one.
Thanks in advance!
Configure PRO-file as shown below:
INCLUDEPATH += C:\programming\ffmpeg-20130606-git--win32-dev\include
LIBS += -LC:\programming\ffmpeg-20130606-git--win32-dev\lib
LIBS += -lavcodec -lavformat -lavutil
Then, build the project, copy the all dll libraries from C:\programming\ffmpeg-20130606-git--win32-shared\bin to exe output path and run application.
UPD
Maybe you need to copy some of the following libraries from Qt\5.0.2\mingw47_32\bin\:
libgcc_s_sjlj-1.dll
libstdc++-6.dll
libwinpthread-1.dll