Seeking for help with linking intel TBB and Qt compiling with MSVC. I don't have any problems when using Visual Studio and linking there, but Qt redflags errors in profiling file as follows:
C:\Program Files (x86)\Intel\oneAPI\tbb\2021.1.1\include\oneapi\tbb\profiling.h(229): error C2059: syntax error: ')'
C:\Program Files (x86)\Intel\oneAPI\tbb\2021.1.1\include\oneapi\tbb\profiling.h(229): error C2334: unexpected token(s) preceding '{'; skipping apparent function body
C:\Program Files (x86)\Intel\oneAPI\tbb\2021.1.1\include\oneapi\tbb\profiling.h(231): error C2059: syntax error: 'const'
C:\Program Files (x86)\Intel\oneAPI\tbb\2021.1.1\include\oneapi\tbb\profiling.h(231): error C2334: unexpected token(s) preceding '{'; skipping apparent function body
My guess it's just qmake options problem, I've searched everywhere to find proper instructions how to link with Qt and couldn't find any.
My .pro file:
QT -= gui
CONFIG += c++17 console
CONFIG -= app_bundle
SOURCES += \
main.cpp
# Default rules for deployment.
qnx: target.path = /tmp/$${TARGET}/bin
else: unix:!android: target.path = /opt/$${TARGET}/bin
!isEmpty(target.path): INSTALLS += target
#TBB
INCLUDEPATH += 'C:\Program Files (x86)\Intel\oneAPI\tbb\2021.1.1\include'
win32:CONFIG(release, debug|release): LIBS += -L'C:/Program Files (x86)/Intel/oneAPI/tbb/2021.1.1/lib/intel64/vc_mt/' -ltbb
else:win32:CONFIG(debug, debug|release): LIBS += -L'C:/Program Files (x86)/Intel/oneAPI/tbb/2021.1.1/lib/intel64/vc_mt/' -ltbb_debug
INCLUDEPATH += 'C:/Program Files (x86)/Intel/oneAPI/tbb/2021.1.1/lib/intel64/vc_mt'
DEPENDPATH += 'C:/Program Files (x86)/Intel/oneAPI/tbb/2021.1.1/lib/intel64/vc_mt'
and main:
#include <QCoreApplication>
#include <oneapi/tbb.h>
int main(int argc, char *argv[])
{
QCoreApplication a(argc, argv);
return a.exec();
}
Related
I'm having an error when I integer libarchive in Qt 5.14.2. I'm on windows.
This is the error:
undefined reference to `archive_read_new'
In my main.cpp file, I have:
struct archive *a;
a = archive_read_new();
I compile sucessfully libarchive 3.4.2 with mingw64 but I'm having trouble to integer it in Qt.
In my libarchive folder I have:
include (containing archive.h & archive_entry.h)
lib (containing libarchive.dll.a & libarchive.dll)
In my .pro file:
INCLUDEPATH += "path\libarchive\include"
DEPENDPATH += "path\libarchive\include"
LIBS += -Lpath\libarchive\lib -larchive
But still, there is some thing I'm missing.
Do you have an idea ?
Found it.
I compile libarchive with Mingw64 so I have to compile my Qt application with the 64bit version of Mingw.
I'm attempting to build an application with QTCreator on Windows10 that uses the QVTKWidget, but I get linker error(s):
mainwindow.obj:-1: error: LNK2019: unresolved external symbol "__declspec(dllimport) public: __cdecl QVTKWidget::QVTKWidget(class QWidget *,class QFlags<enum Qt::WindowType>)" referenced in function "public: void __cdecl Ui_MainWindow::setupUi(class QMainWindow *)"
I've downloaded Qt5.5 for msvc2013 and msvc2013_64. I've downloaded VTK7, and built it with Qt support using CMake. I built a vtk32 and vtk64. I've copied D:\VTK\vtk32\bin\Release\QVTKWidgetPlugin.dll to C:\Qt\Tools\QtCreator\bin\plugins\designer and when I start QTCreator, the QVTKWidget shows up on the bottom under the QVTK section of the available form controls.
I add the QVTKWidget to my form and build the application using msvc2013 Release. Then I get the linker errors. What lib am I missing?
Below is my .pro file
QT += core gui
greaterThan(QT_MAJOR_VERSION, 4): QT += widgets
TARGET = MIViewer
TEMPLATE = app
SOURCES += main.cpp\
mainwindow.cpp
HEADERS += mainwindow.h
FORMS += mainwindow.ui
win32 {
INCLUDEPATH += D:\VTK\VTK-7.0.0\GUISupport\Qt
INCLUDEPATH += D:\VTK\VTK-7.0.0\Common\Core
INCLUDEPATH += D:\VTK\VTK-7.0.0\Rendering\Core
}
win32-msvc2013 {
INCLUDEPATH += D:\VTK\vtk32\GUISupport\Qt
INCLUDEPATH += D:\VTK\vtk32\Interaction\Style
INCLUDEPATH += D:\VTK\vtk32\Rendering\Core
INCLUDEPATH += D:\VTK\vtk32\Rendering\OpenGL2
INCLUDEPATH += D:\VTK\vtk32\Common\Core
LIBS += -LD:\VTK\vtk32\lib\Release
}
win32-msvc2013_64 {
INCLUDEPATH += D:\VTK\vtk64\GUISupport\Qt
INCLUDEPATH += D:\VTK\vtk64\Interaction\Style
INCLUDEPATH += D:\VTK\vtk64\Rendering\Core
INCLUDEPATH += D:\VTK\vtk64\Rendering\OpenGL2
INCLUDEPATH += D:\VTK\vtk64\Common\Core
LIBS += -LD:\VTK\vtk64\lib\Release
}
LIBS += -lQVTKWidgetPlugin \
-lvtkGUISupportQt-7.0 \
-lvtkRenderingQt-7.0
Just wanted to answer my own question in case anyone else comes across this post with a similar program. I was able fix this by re-compiling the 32-bit VTK with all of the Cmake Qt options selected and paths filled out. I didn't have the correct paths in CMake, but cmake didn't complain and generated the VS solution files. And I didn't notice that 20% of the projects had failed until I tried to re-compile VTK.
When trying to diagnose linker errors, it's nothing mysterious. There's something missing! Just going through the checklist of dependencies one by one solved it for me.
I cannot understand why this Qt pro file does not work:
QT += core
QT += gui
TARGET = PrjName
CONFIG += qt
CONFIG += console
TEMPLATE = app
INCLUDEPATH += C:/Qt/4.8.4/include/Qt
QMAKE_LIBDIR += C:/Qt/4.8.4/bin
LIBS += -lQtCore4
LIBS += -lQtGui4
SOURCES += ...
HEADERS += ...
These are the linker errors:
error: cannot find -lQtGui
error: cannot find -lQtCore
The C:\Qt\4.8.4\bin directory exists, and the DLLs are there.
Thank you.
Platform: Windows 7, MinGW, Qt 4.8.4, QtCreator 2.8.0
I have the following main.cpp file:
#include <amp.h>
using namespace concurrency;
int main()
{
int arr[] = {42};
array_view<int, 1> v(1, arr);
return 0;
}
and a .pro file:
TEMPLATE = app
CONFIG += console
CONFIG -= app_bundle
CONFIG -= qt
QMAKE_CXXFLAGS += -EHsc
SOURCES += main.cpp
If I compile main.cpp from the Visual Studio 2012 command line (just using cl /EHsc main.cpp), everything works fine. But if I use qmake and nmake there is alway a link error, that there are unresolved external symbols (coming from amp). Does anybody know how to resolve this problem?
I figured out, what the problem is: In the mkspec file qmake.conf the compiler flag Zc:wchar_t- causes the compiler to translate some types relatet to wchar_t incorrectly and hence the resulting symbols could not be resolved.
To solve this problem, change the above .pro file to
TEMPLATE = app
CONFIG += console
CONFIG -= app_bundle
CONFIG -= qt
QMAKE_CXXFLAGS += -EHsc -Zc:wchar_t
SOURCES += main.cpp
(add -Zc:wchar_t to QMAKE_CXXFLAGS).
You forget to add
LIBS += -lname_of_the_amp_lib
Sorry but I don't know the name of the lib...
I can't use the ffmpeg in QT.
My Steps :
-1. compile the ffmpeg as normal
-2. add lib/include path in QT .pro
LIBS += -L/home/kim/ffmpeg/lib -lavcodec -lavformat
INCLUDEPATH += /home/kim/ffmpeg/include
-3. in code
extern "C" {
#include <libavcodec/avcodec.h>
#include <libavformat/avformat.h>
}
and just call a function named av_register_all();
then I got the following bulid issues< many functions undefined reference >
in function `rl2_read_packet`: undefined reference to `av_free_packet`
in function `av_register_all`: ....
I search a solution of the problem but not work for me.
Any other solution? Thanks.
This is an old post and it is almost solved. By the way, I faced to the problem and I had lots of time struggling with
undefined reference to av_register_all
I am using Qt Creator 5.3.2 and this is my MYPROJECT.pro file
MYPROJECT.pro
QT += core
QT -= gui
TARGET = MYPROJECT
CONFIG += console
CONFIG -= app_bundle
TEMPLATE = app
SOURCES += main.cpp
QMAKE_CXXFLAGS += -D__STDC_CONSTANT_MACROS
LIBS += -LC:\ffmpeg-20151219-git-2dba040-win32-dev\lib
LIBS += -lavcodec -lavformat -lavutil -lswscale
INCLUDEPATH +=C:\ffmpeg-20151219-git-2dba040-win32-dev\include
Setting up project.pro
It is recommended to build ffmpeg from scratch, but if you are on windows and if you are not willing to compile this masterpiece, then congrats! you are like me! Go for pre-built in zereanoe and download both the latest shared and dev win-32 versions. Extract the latter two packages in a place where there is no spaces in the path, i.e. mine is in: C:\ffmpeg-20151219-git-2dba040-win32-dev
I recommend that don't rename the main folder because it is highly informative. Set the include folder of the [PATH TO ffmpg-YYYYMMDD-git-win32-dev]/include to your project's search space by the following line of code:
INCLUDEPATH +=C:\ffmpeg-20151219-git-2dba040-win32-dev\include
You should also use libraries in [PATH TO ffmpeg-YYYYMMDD-git-win32-dev]/lib to your project as below:
LIBS += -LC:\ffmpeg-20151219-git-2dba040-win32-dev\lib
LIBS += -lavcodec -lavformat -lavutil
You can call libraries other than lavcodec, lavformat and lavutil. In your cpp file you should enclose headers corresponding to ffmpeg in extern "C" block.
DLLs should be added
The final step is to add all the dll files in the shared version of ffmpeg that you have recently downloaded.
Copy *.dll files within
[PATH TO ffmpeg-YYYYMMDD-git-2dba040-win32-shared]/bin
and paste them wherever your executable exists. Fo instance, my project is located on C:/QtProjects/MYPROJECT, then my binaries are located on:
C:/QtProjects/build-MYPROJECT-Desktop_Qt_5_3_MinGW_32bit-Debug
Now, copy all the dlls to your project's debug or release folder.
My main.cpp
This is my main.cpp :
main.cpp
#include <iostream>
extern "C" {
#include <libavcodec/avcodec.h>
#include <libavformat/avformat.h>
#include <libswscale/swscale.h>
}
using namespace std;
int main(int argc, char *argv[])
{
cout<<"I have included FFMPEG in my project"<<endl;
av_register_all();
cout<<"If everything goes well you will see ME"<<endl;
return 0;
}
I had the same problems, it worked using the following trick.
In code cpp source:
#define __STDC_CONSTANT_MACROS
extern "C" {
#include "libavcodec/avcodec.h"
#include "libavformat/avformat.h"
}
And in your .pro file:
LIBS += -LC:/Users/tom/bla/ffmpeg/lib/ -lavcodec -lavformat -lavutil
I think in your case, you need the -lavutil lib parameter.