I tried to link against Vulkan with:
LIBS += -L$$(VK_SDK_PATH)/Bin -lvulkan-1 # Doesn't work at all
LIBS += -L$$(VK_SDK_PATH)/Lib -lvulkan-1 # Works with MSVC
But I couldn't get it linking with MinGW.
INSTALLED:
VulkanSDK (1.2.148.1)
Qt (5.15.0; MSYS2)
MinGW (10.2.0; MSYS2)
I installed the Vulkan Runtime and retried
LIBS += -L$$(VK_SDK_PATH)/Lib -lvulkan-1
with MinGW again and it works. Nevertheless, thank you for helping me out.
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 am trying to run a QT project on Windows that I have developed on Linux Ubuntu. Unfortunately, I cannot manage it to properly link the boost library. Here is a detailed description of the problem.
I downloaded MinGW from https://nuwen.net/mingw.html, version 13.5, such that the gcc version 5.3.0 matches the MinGW version of QT. The reason to choose this version of MinGW is that it contains the boost libraries for compression such as zlib. From the command line I compile and run my program without any problems:
g++ -std=c++11 -w -IC:/MinGW/include -LC:/MinGW/lib bAya.cpp A.o B.o C.o -o baya -lboost_iostreams -lz -lbz2
where A,B, C are my pre-compiled object files.
In QT creator I selected the MinGW compiler (C:\MinGW_53\MinGW\bin\g++.exe) and created a new default kit with the compiler.
My .pro file looks as follows:
MAKE_CXXFLAGS += -std=c++11
INCLUDEPATH += C:/MinGW_53/MinGW/include \
C:/Users/kuzk/Documents/src
LIBS += -LC:/MinGW_53/MinGW/lib/mylib \
-lboost_system \
-lboost_iostreams \
-lz \
-lbz2
greaterThan(QT_MAJOR_VERSION, 4): QT += widgets
SOURCES += main.cpp\
mainwindow.cpp \
../src/A.cpp \
../src/B.cpp \
../src/C.cpp
HEADERS += mainwindow.h \
../src/A.h \
../src/B.h \
../src/C.h
The folder C:/MinGW_53/MinGW/lib/mylib contains my .a files such as libboost_iostreams.a
When I build it, I get many undefined reference errors such as
error: undefined reference to `boost::iostreams::zlib::default_strategy'
Interestingly, if C:/MinGW_53/MinGW/lib/mylib contains also libstdc++.a I also get linking errors to std::cout, std::ifstream etc.
I am currently stuck and I will be very helpful for any feedback.
Best,
Konstantin
Adding the library path for boost_iostreams:
-LC:/MinGW/lib \
after the line:
LIBS += -LC:/MinGW_53/MinGW/lib/mylib \
should fix it.
At the end I was able to resolve the problem. Here is what I did. I am using QT 5.7 on Windows 10.
I compiled boost using QT's console as described here: http://cpp-qt-mac-win.blogspot.co.uk/2011/10/qt-boost-for-beginners-step-by-step.html
Then I created a new project and added the paths to boost and the necessary libraries, as described in my question.
An important note. I tried to update the paths in the existing project, by running qmake and then rebuilding the project. I was getting the very same errors as I was getting with the old paths to "standard" boost. Apparently, something was cached and the changes didn't do anything. However, if I give a wrong path to a library it complained. So, QT has very confusing behavior. If someone can explain it, it will be helpful.
I have started a project with Qtcreator on linux. This project uses the Openssl library to work.
So In my .pro file I have added theses lines :
LIBS += -lssl
LIBS += -lcrypto
So on linux it works perfectly.
But, I have to continue my project on windows. I had to install Openssl with cygwin, I have chosen this package : "cygwin32-openssl-1.0.1e-1.tar.bz2" because I compile in 32bits.
I have created a sub-repertory, named libs, in my program folder and I put the three openssl folders (bin, include and lib) in my "libs" repertory.
The content of the lib directory is :
libcrypto.a
libcrypto.dll.a
libssl.a
libssl.dll.a
pkgconfig/libcrypto.pc
pkgconfig/libssl.pc
pkgconfig/openssl.pc
In the bin directory I have 2 .dll, cygcrypto-1.0.0.dll and cygssl-1.0.0.dll
I added in my .pro file these lines :
LIBS += -lssl
LIBS += -lcrypto
LIBS += -L"$$PWD/libs/openssl/lib/"
INCLUDEPATH += $$PWD/libs/openssl/include/
If I change -L"$$PWD/libs/openssl/lib/" by -L"$$PWD/libs/openssl/bin/", the compilator don't recognized the -lssl and -lcrypto options.
QtCreator recognized the headers files (for example ) and when I compile, no error occurred.
But when I launch my program, it doesn't work and no error appears.
So I put a breaking point at the begining of my main function, and I re-launch the program. After that a little window indicates to me this error :
Executable failed: During startup program exited with code 0xc0000135
I use Qt 5.4.0 and Mingw 32bits
I don't undertsand why it doesn't work. Can you help me please ?
Thank you.
The entirety of your project needs to use cygwin, or none of it. Since I assume you're compiling using a Visual Studio compiler, you'll need to use an OpenSSL build that isn't cygwin-dependent. For example, the one from Shining Light Productions, the de-fact OpenSSL binary purveyor for Windows.
I would like to use boost/filesystem.hpp in my Qt app but the builder keeps saying:
Library not loaded: libboost_filesystem.dylib
Reason: image not found
here is how I try to link it:
INCLUDEPATH+= /installdir/boost_1_50_0
LIBS += -L/installdir/boost_1_50_0/stage/lib -lboost_filesystem
I've tried linking directly, too. I've also tried rebuilding boost according to jschoen's answer, no difference.
Im running a MacOSX Lion. How do I have to link boost properly?
In the meantime I have found a solution.
install boost with macports (sudo port install boost) Thanks to dies and Tim Cooper.
then link against:
INCLUDEPATH += /opt/local/include
LIBS += -L/opt/local/lib
LIBS += -lboost_system-mt -lboost_filesystem-mt
I currently run Arch Linux on my laptop and was hoping to know why Qt Creator isn't finding my glut library (which exists on my system).
My setup qmake file looks as follows:
...
/*sources and headers above*/
QT += opengl
LIBS += -lfreeglut
INCLUDEPATH += -L/usr/lib/
And when I run a locate glut, I get the following:
/usr/include/kwinglutils.h
/usr/include/kwinglutils_funcs.h
/usr/include/GL/freeglut.h
/usr/include/GL/freeglut_ext.h
/usr/include/GL/freeglut_std.h
/usr/include/GL/glut.h
/usr/lib/libglut.a
/usr/lib/libglut.so
/usr/lib/libglut.so.3
/usr/lib/libglut.so.3.9.0
/usr/share/avogadro/fragments/amino_acids/D-glutamic_acid.cml
/usr/share/avogadro/fragments/amino_acids/D-glutamine.cml
/usr/share/avogadro/fragments/amino_acids/L-glutamic_acid.cml
/usr/share/avogadro/fragments/amino_acids/L-glutamine.cml
/usr/share/licenses/freeglut
/usr/share/licenses/freeglut/LICENSE
/var/lib/pacman/local/freeglut-2.6.0-1
/var/lib/pacman/local/freeglut-2.6.0-1/changelog
/var/lib/pacman/local/freeglut-2.6.0-1/desc
/var/lib/pacman/local/freeglut-2.6.0-1/files
Note that I have tried -lglut32 in my qmake file as well.
What could I be missing here?
When you specify -lfoobar in your .pro file (or with gcc in general), you're directing the compiler to search for the library libfoobar.a. Judging from your locate output it looks like you want:
LIBS += -lglut
Oh, silly me. I just realized that the correct lib to add was just -lglut and not -lglut32. This is because there exists libglut.so, and not libglut32.so.