QtCreator and TBB under Windows - windows-7

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

OpenCV libraries not found in Qt5 on OSX 10.10

I am currently trying to use OpenCV in a Qt project. When I build it, i get the error:
error: 'opencv2/opencv.hpp' file not found
#include <opencv2/opencv.hpp>
I know that there are many similar questions out there in the web, but none of the answers was actually able to fix my problem so far.
My specifications:
Qt 5.4.0 (Clang 6.0 (Apple), 64 bit)
Mac OSX 10.10.1
OpenCV 2.4.9 installed from homebrew
My .pro file looks like this:
QT += core gui multimedia multimediawidgets
greaterThan(QT_MAJOR_VERSION, 4): QT += widgets
TARGET = MainProject
TEMPLATE = app
SOURCES += main.cpp mainwindow.cpp
HEADERS += mainwindow.h
FORMS += mainwindow.ui
INCLUDEPATH += /usr/local/include/opencv2
LIBS += -L/usr/local/lib
LIBS += -lopencv_core
LIBS += -lopencv_imgproc
LIBS += -lopencv_highgui
LIBS += -lopencv_ml
LIBS += -lopencv_video
LIBS += -lopencv_features2d
LIBS += -lopencv_calib3d
LIBS += -lopencv_objdetect
LIBS += -lopencv_contrib
LIBS += -lopencv_legacy
LIBS += -lopencv_flann
I made sure the links actually link to the right locations. All the header files and all the .dylib files are there as well. I checked the type of the libraries:
$ file libopencv_core.dylib
libopencv_core.dylib: Mach-O 64-bit dynamically linked shared library x86_64
In my project settings, the qmake command is:
qmake: qmake MainProject.pro -r -spec macx-clang CONFIG+=debug CONFIG+=x86_64
Unfortunately I only have a basic understanding of these compile-things, so I am not too sure, whether it has something to do with clang? I read something about clang behaving somehow different on OSX 10.10 Yosemite, but I did not completely understand why. Info about my clang:
$ clang --version
Apple LLVM version 6.0 (clang-600.0.56) (based on LLVM 3.5svn)
Target: x86_64-apple-darwin14.0.0
Thread model: posix
I also tried to use the gcc-kit in Qt (GCC x86 64bit in /usr/bin), but this messed up a lot more, which I did not understand.
Does somebody have an idea what I am doing wrong? Any help appreciated!
Patrick
You are already including the directory opencv2 in your #include statement. You should change your include path to just INCLUDEPATH += /usr/local/include.

How to install OpenCV with Visual Studio 2012 (64 bit) on Windows 7?

I'm following this guide to install OpenCV for Qt: http://www.laganiere.name/opencvCookbook/chap1s1_2.shtml. But this tutorial is made for Qt with mingw32 compiler kit.
Kindly suggest me the steps to install it on Visual Studio 2012 on Windows 7 64bit (with or without cmake).
You need to select your compiler not MinGW.
You then specify the compilers that will generate the project. In our case, they are the compilers of MinGW installed by default by Qt.
You need to select 64 bit Visual Studio 11.0. And when you finish configuration and click generate button cmake is going to generate you a solution file, all you need to do is open that solution file and compile it.
Use this guide http://docs.opencv.org/doc/tutorials/introduction/windows_install/windows_install.html. If you will have problems with building Qt 5.x, use Qt 4.x - it's much easier to build it.
Ok, I was able to solve this problem by following the guide mentioned by cyriel:http://docs.opencv.org/doc/tutorials/introduction/windows_install/windows_install.html.
And adding following lines to myproject.pro file:
INCLUDEPATH += C:\OpenCV\build\include
LIBS += C:\OpenCV\build\x64\vc11\lib\opencv_core244.lib
LIBS += C:\OpenCV\build\x64\vc11\lib\opencv_highgui244.lib
LIBS += C:\OpenCV\build\x64\vc11\lib\opencv_imgproc244.lib
LIBS += C:\OpenCV\build\x64\vc11\lib\opencv_calib3d244.lib
LIBS += C:\OpenCV\build\x64\vc11\lib\opencv_calib3d244d.lib
LIBS += C:\OpenCV\build\x64\vc11\lib\opencv_contrib244d.lib
LIBS += C:\OpenCV\build\x64\vc11\lib\opencv_core244d.lib
LIBS += C:\OpenCV\build\x64\vc11\lib\opencv_features2d244d.lib
LIBS += C:\OpenCV\build\x64\vc11\lib\opencv_flann244d.lib
LIBS += C:\OpenCV\build\x64\vc11\lib\opencv_gpu244d.lib
LIBS += C:\OpenCV\build\x64\vc11\lib\opencv_highgui244d.lib
LIBS += C:\OpenCV\build\x64\vc11\lib\opencv_imgproc244d.lib
LIBS += C:\OpenCV\build\x64\vc11\lib\opencv_legacy244d.lib
LIBS += C:\OpenCV\build\x64\vc11\lib\opencv_ml244d.lib
LIBS += C:\OpenCV\build\x64\vc11\lib\opencv_nonfree244d.lib
LIBS += C:\OpenCV\build\x64\vc11\lib\opencv_objdetect244d.lib
LIBS += C:\OpenCV\build\x64\vc11\lib\opencv_photo244d.lib
LIBS += C:\OpenCV\build\x64\vc11\lib\opencv_stitching244d.lib
LIBS += C:\OpenCV\build\x64\vc11\lib\opencv_ts244d.lib
LIBS += C:\OpenCV\build\x64\vc11\lib\opencv_video244d.lib
LIBS += C:\OpenCV\build\x64\vc11\lib\opencv_videostab244d.lib
By doing this, there is no need for additional compilation again by vsc2012. It also saves hard disk space. And anyone will be able to run their opencv project written in Qt5.1.

Qt5, Visual Studio 2012 Express and OpenMp. How to?

I am trying to compile http://www.kevinbeason.com/smallpt/ raytracer using Qt5 and Visual Studio 2012 compiler.
It works Okay but when I try to use openmp by adding
QMAKE_CXXFLAGS += -fopenmp
LIBS += -fopenmp
to project.pro
, Qt says that /fopenmp is not recognized and ignored.
When I compile using VS command
cl /c /O2 /EHsc /openmp main.cpp
it works and I get a program 3 times faster then the one compiled from Qt.
How to make Qt recognize openmp and how to enable the other optimizations in the command line?
Thanks in advance.
I finally got all the required elements to get it compiled with openmp from Qt Creator:
Add #include <omp.h> to the source, which is not required if you compile with
the command line mentioned above.
Add QMAKE_CXXFLAGS += -openmp to the project file. It wont work
with -fopenmp. No need for any openmp lib like I did ( LIBS += -openmp ) neither for QMAKE_LFLAGS += -openmp
Compile as release. With debug it has no impact on performance.
The other optimization options are already configured in mkspecs\win32-msvc2012\
qmake.conf
Hope this helps someone else.
I want to run Qt project with openmp. I have followed the above steps, I could build the project, but execution time is increasing instead of reducing.
Here is the configuration I used
CONFIG += console c++11
CONFIG -= app_bundle
#CONFIG -= qt
QMAKE_CXXFLAGS+= -openmp

Programs with Boost Dependency Fail to Compile in Qt Creator

I get undefined reference errors to various things in the boost:: namespace if I attempt to compile programs that use any parts of Boost Libraries in Qt Creator 2.5.2. At first I thought it's because I was mixing static Boost libraries with shared Qt libraries, so I recompiled Boost with link=shared runtime-link=shared build option, but the problem remains. I then started a Non-Qt, Plain C++ project that consists of nothing more than a main.cpp containing a slightly modified Boost test program:
// main.cpp, cin-less version of
// http://www.boost.org/doc/libs/1_51_0/more/getting_started/windows.html#test-your-program
#include <iostream>
#include <string>
#include <boost/regex.hpp>
int main() {
std::string headerLines = "To: George Shmidlap\n" \
"From: Rita Marlowe\n" \
"Subject: Will Success Spoil Rock Hunter?\n" \
"---\n" \
"See subject.\n";
boost::regex pat( "^Subject: (Re: |Aw: )*(.*)" );
boost::smatch matches;
std::string::iterator newLinePos = std::find(headerLines.begin(), headerLines.end(), '\n');
std::string::iterator startPos = headerLines.begin();
while(newLinePos != headerLines.end()) {
if (boost::regex_match(std::string(startPos, newLinePos++), matches, pat)) {
std::cout << "\nRegex Match: " << matches[2];
}
startPos = newLinePos;
newLinePos = std::find(startPos, headerLines.end(), '\n');
}
char temp[3];
std::cin.getline(temp, 2);
return 0;
}
Project file:
TEMPLATE = app
CONFIG += console
CONFIG -= qt
SOURCES += main.cpp
Debug {
LIBS += -lboost_regex-mgw46-mt-d-1_51
}
release {
LIBS += -lboost_regex-mgw46-mt-1_51
}
Compiling the above project from within Qt Creator, or using mingw32-make in command line, gives:
E:\BoostTest-483-MinGW_Debug\debug\main.o:-1: In function `ZN5boost13match_resultsIN9__gnu_cxx17__normal_iteratorIPKcSsEESaINS_9sub_matchIS5_EEEE17raise_logic_errorEv':
c:\tdm-mingw32\include\boost\regex\v4\match_results.hpp:562: error: undefined reference to `boost::throw_exception(std::exception const&)'
E:\BoostTest-483-MinGW_Debug\debug\main.o:-1: In function `ZN5boost9re_detail12perl_matcherIN9__gnu_cxx17__normal_iteratorIPKcSsEESaINS_9sub_matchIS6_EEENS_12regex_traitsIcNS_16cpp_regex_traitsIcEEEEE14construct_initERKNS_11basic_regexIcSD_EENS_15regex_constants12_match_flagsE':
c:\tdm-mingw32\include\boost\regex\v4\perl_matcher_common.hpp:55: error: undefined reference to `boost::throw_exception(std::exception const&)'
[etc...]
Compiling main.cpp from command line, without Qt Creator or mingw32-make, works just fine:
E:\BoostTest>g++ -s -O3 main.cpp -o main.exe -lboost_regex-mgw46-mt-1_51
E:\BoostTest>main.exe
Regex Match: Will Success Spoil Rock Hunter?
E:\BoostTest>g++ -s -O3 main.cpp -o main-dbg.exe -lboost_regex-mgw46-mt-d-1_51
E:\BoostTest>main-dbg.exe
Regex Match: Will Success Spoil Rock Hunter?
Tested with:
TDM-MinGW32 (MinGW 4.6.1)
My own builds of MinGW:
MinGW 4.6.3 with dwarf2 exceptions handling
MinGW 4.6.3 with SJLJ exceptions handling
Boost Libraries 1.51.0 (built from source with each of the above compiler builds, static and shared libraries)
Qt Framework 4.8.3 for MinGW, precompiled binaries.
Qt Creator 2.5.2 for Windows.
I've checked Qmake's makescpecs configuration files, among other things, but still cannot figure out the root of the problem. Any ideas?
This is most likely far too late to help you, but I've just had to figure this one out today. I too am using mingw32 and Qt and had the same undefined reference.
I first resolved it by adding the following in `some file', based on another StackOverflow question:
namespace boost
{
void throw_exception(std::exception const &e) { assert(false); }
}
However I actually wanted to throw an exception, so changed the assert(false); to a throw e;. That immediately threw up the compile error:
error: exception handling disabled, use -fexceptions to enable
...which gives a clue.
The trick turned out to be adding CONFIG += exceptions (along with console so cout/printf etc. actually do anything, that was a real pain!) to my qmake file. I have no idea what is really going on here, maybe most Linux distros add something special to the qmake spec files or whatever.

Compiling google test framework with Mingw compiler

I have a Qt project and i wanted to use google tests framework GoogleTestFramework in order to do google test. The framework compiled fine on Linux.
I have managed to compile the libraries on windows, using tips provided in the following link:
Installing Gtest without pthreads
The following advice do not let me compile the libraries, because of errors due to pthreads:
Sackoverflow compiling with MSYS
I have :
GNU Make 3.81 for make.exe
GNU Make 3.82 for mingw32-make
CMake 2.8.7
QT 4.7.4
Qt MingW gcc v 4.4.0
When i try to compile my test projet, i get an error saying:
undefined reference to '__chkstk_ms'
File not found: gtest-all.cc
Here is my qmake project code (I have semplified the code).
QT += core gui
DEPENDPATH += . headers src ../FastTrans/headers ../FastTrans/src ../FastTrans/forms C:/MinGW/msys/1.0/home/zakharan/gtest-1.6.0/include
INCLUDEPATH += . headers src ../FastTrans/headers ../FastTrans/src ../FastTrans/forms C:/MinGW/msys/1.0/home/zakharan/gtest-1.6.0/include
TARGET = tstall
#CONFIG += console
#CONFIG -= app_bundle
TEMPLATE = app
HEADERS += ../FastTrans/headers/shortcutsactionsitem.h \
../FastTrans/headers/shortcutsactionsmodel.h \
../FastTrans/headers/isavesettings.h
SOURCES += ../FastTrans/src/shortcutsactionsitem.cpp \
../FastTrans/src/shortcutsactionsmodel.cpp \
../FastTrans/src/isavesettings.cpp \
src/tstshortcutsactionsitem.cpp \
src/tstshortcutsactionmodel.cpp
INCLUDEPATH += $$PWD/
DEPENDPATH += $$PWD/
win32: LIBS += C:/MinGW/msys/1.0/home/zakharan/gtest-1.6.0/mybuid/libgtest.a
win32: LIBS += C:/MinGW/msys/1.0/home/zakharan/gtest-1.6.0/mybuid/libgtest_main.a
Google recommends the following for compiling in Windows:
### Windows Requirements ###
* Microsoft Visual C++ 7.1 or newer
### Cygwin Requirements ###
* Cygwin 1.5.25-14 or newer
I've heard of some people using MingW for compiling this. Supposedly compiling with MingW can be a little faster because there doesn't need to be a comparability layer between the OS and the application.
But, since this is just for dev testing purposes Cygwin should suffice. Just download the version that Google recommends.
See Also:
Compile Cygwin project in Eclipse
How Cygwin compares to MingW for porting Linux applications to Windows

Resources