QT + CUDA setting qmake.pro file - visual-studio-2010

I'm trying to do a simple Qt + Cuda framework with an Helloworld.cu example. It is the simplest Qt ever. I'm trying to create the project file using a .pro file. My setup is windows 7, Qt 4.7.4 and Cuda toolkit + SDK (last version). Everything for Qt is working. What is not working is the Cuda part of the code, and that's probably because there is something missing in the .pro file...is there a simple paste/copy i could use for cuda in my .pro file? thanks

Take a look at http://cudaspace.wordpress.com/2011/04/07/qt-creator-cuda-linux/
You must adjust
# Path to cuda SDK install
CUDA_SDK = /pathto/NVIDIA_GPU_Computing_SDK/C (note i'm using a linux machine)
# Path to cuda toolkit install
CUDA_DIR = /usr/local/cuda
# libs - note than i'm using a x_86_64 machine
LIBS += -lcudart -lcutil_x86_64
with your CUDA SDK, CUDA Toolkit directories under windows and the name of the LIBS.
Maybe you will need to adjust the architecture m32 or m64 for 32 and 64 bits.
Hope this help.

Related

Qt project files: win32 or win 64

I am confused about this:
My Qt creator is 32bit while my windows is 64 bit. In .pro file, should I use win 32{...} or win 64 {...}? If I want to link OpenCV libraries, in which one should I use, x64 or x86?
It would be better if you could give me a little explanation about this.
Thanks!
Qmake has some platform and compiler variables like: win32, unix, win32-msvc, ... which are available on mkspecs directory in the installed Qt directory. You can have conditional .pro file based on platform and compiler. For example you can have project which is able to compile both on Windows and Linux. You can linked to an external library conditionally :
win32: LIBS += -L$$PWD/Windows/Path/To/Library/ -lTheLibrary
else:unix: LIBS += -L$$PWD/Linux/Path/To/Library/ -lTheLibrary
If you want to detect whether you are compiling for 32-bit or 64-bit compilers on Windows and linked to relevant libraries accordingly you can use :
win32:contains(QMAKE_HOST.arch, x86_64) {
LIBS += -L$$PWD/Path/To/Library_64Bit/ -lTheLibrary
} else {
LIBS += -L$$PWD/Path/To/Library_32Bit/ -lTheLibrary
}
There are lot of posts that covered these differences, but the important part to remember is that you have to match the architecture between the compiler and the 3rd party libraries that you want to use.
For instance, I have a computer with Windows 64-bit where I use Qt Creator 3.2.1 (opensource) based on Qt 5.3.1 (MSVC 2010, 32 bit). Since my compiler is 32 bit, it's important that I use the 32 bit version of the OpenCV libraries.
So in the .pro file I'll use:
LIBS += -L"C:\\opencv\\build\\x86\\vc12\\lib" \
-lopencv_world300d

How to use QtCreator to statically link FLTK libraries

I am using Qt Creator (Qt 5.0.3 on Ubuntu 14) for a normal c++ project where I am using FLTK libraries. i want to link FLTK statically to my executable. How do I do that using Qt Creator( I am not using any of Qt libraries, just a normal c++ project with FLTK)
You can add suitable LIBS += -l... and INCLUDEPATH += /usr/... to your .pro

Qt Creator - LNK1104: cannot open file "glu32.lib"

I am using Qt and Qt Creator and I want to run a test file to see if my Installation is correct or not. I use Windows 8.1 64 bit. I installed the newest Qt OpenGL 64 bit Version for Windows.
I already included the file glu32.lib by doing this in my .pro file:
win32:CONFIG(release, debug|release): LIBS += -L$$PWD/C:/Program Files (x86)/Windows
Kits/8.1/Lib/winv6.3/um/x64/ -lGlU32
else:win32:CONFIG(debug, debug|release): LIBS += -L$$PWD/C:/Program Files (x86)/Windows Kits/8.1/Lib/winv6.3/um/x64/ -lGlU32d
INCLUDEPATH += $$PWD/C:/Program Files (x86)/Windows Kits/8.1/Include/um/gl
DEPENDPATH += $$PWD/C:/Program Files (x86)/Windows Kits/8.1/Include/um/gl
That did not fix it. The file exists in that Folder. Can you help me please?
First of all, it is case sensitive.
Secondly, you do not need to add the debug marker explicitly, so just write this:
LIBS += glu32
rather than:
LIBS += Glu32d
Also, as Martin pointed out in a comment, you better double quote strings containing spaces as follows:
-L"$$PWD/C:/Program Files (x86)/Windows"
or this if you fancy:
-L$$quote($$PWD/C:/Program Files (x86)/Windows)
Furthermore, this does not make any sense as the second branch will never satisfy:
win32: ...
else: win32: ...
If you do not want to go editing the project file, you can use the QtCreator GUI to add a system library like glu:
Furthermore, you seem to have 64 bit Qt installed on Windows, but you are trying to use 32 bit glu. Do not do that. Use either 32 bit for both or 64 bit.
Add
QMAKE_LIBDIR += "glu32_location"
to your .pro file, then it works.
When you make a project, at the kit selection, only select:
Desktop Qt 5.4.1 64bit
I had the same problem, then I made a new project without the 32 bit OpenGL Kit selected and it works fine for me. By default, Qt has both selected.
I know the question is about the QtCreator IDE, but I got this error when compiling from the command line. I had to run vcvars32.bat to fix it. Everything compiled fine because the msvc compiler was already in PATH, but linking was the problem.

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.

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