Qt project files: win32 or win 64 - windows

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

Related

QMake - Find library names based on kit/target as well as build type

I am trying to link against libraries that are all in the same directory and use the following naming convention:
libFoo64.a # 64-bit release
libFoo32.a # 32-bit release
libFood64.a # 64-bit debug
libFood32.a # 32-bit debug
What can I put in the QMake .pro file so that the right library will be found for each build?
I am using QtCreator 4.9.0 (MSYS2 build) with the default kits enabled:
Desktop Qt MinGW-w64 32-bit (MSYS2)
Desktop Qt MinGW-w64 64-bit (MSYS2)
and for a 32-bit debug build I will choose the 32-bit kit and then the Release configuration under that, etc.
I saw this question which indicates how to set different QMake options for Debug vs. Release but I'm not sure how to extend that to also use different options depending on which Kit is in use.
Based on this question I successfully achieved the goal with the following code in the .pro file:
contains(QT_ARCH, i386) {
CONFIG(debug, debug|release) {
message("32-bit debug")
LIBS += -lFooBard32 -lFooBazd32 -lFooQuxd32 -lFooCorged32 -lFooGraultd32
}else {
message("32-bit release")
LIBS += -lFooBar32 -lFooBaz32 -lFooQux32 -lFooCorge32 -lFooGrault32
}
}else {
CONFIG(debug, debug|release) {
message("64-bit debug")
LIBS += -lFooBard64 -lFooBazd64 -lFooQuxd64 -lFooCorged64 -lFooGraultd64
}else {
message("64-bit release")
LIBS += -lFooBar64 -lFooBaz64 -lFooQux64 -lFooCorge64 -lFooGrault64
}
}
which works although it's not particularly pretty.
I also had to modify my kit configuration so that the 32-bit compiler has 32-bit QT enabled (even though I'm doing a non-QT application , I just use QtCreator because I like the IDE, and I didn't previously have 32-bit QT even installed). The QT_ARCH variable seems to be based on the "Qt Version" configured in the kit, not the actual compiler selected in the kit.

64 bit LAPACK precompiled Windows Mingw

I'm trying to build a 64 bit executable on Windows using MinGW that links to LAPACK and BLAS. Several sources referred me to the prebuilt MinGW 64 bit lib and dll files here:
https://icl.cs.utk.edu/lapack-for-windows/lapack/
However, linking to those files fails with message "skipping incompatible x64_mingw/liblapack.dll when searching for -llapack" when I use x86_64-w64-mingw32-gcc.exe to compile and link. Anyone know why that is?

What is the correct package name for gcc in cygwin?

I need gcc installed on cygwin,
but when I search for gcc in the cygwin setup application, I get several results with the string "gcc" in their names, for example:
cygwin32-gcc-ada
cygwin32-gcc-core
cygwin32-gcc-fortran
cygwin32-gcc-g++
cygwin32-gcc-objc++
...
gcc-ada
gcc-core
gcc-fortran
gcc-g++
...
libgcc1
minigw-gcc-core
minigw-gcc-g++
....
minigw64-i686-gcc-core
minigw64-i686-gcc-g++
...
when I am searching for gcc in synaptic in ubuntu, I have a very obvious result
what am I suppose to do with these names? install all?
install a random one and then create symlinks to where ever it's binary may land to /usr/bin/gcc ?
what usefulness and productivity can be achieved from these many packages names showing up when I attempt searching for that one gcc that I keep reading online that I need to build packages that aren't on cygwin installer?
everywhere I read about "install gcc on cygwin and then continue to do this and that" they never mention which of the gcc packages above is single correct one,
its like everyone everywhere somehow already knows which gcc is the correct one and that information is no where to be found online.
I would appreciate clarification and further help.
EDIT:
sometime in the past, there actually used to be a package called just "gcc",
I found that from the screenshots here:
http://www.eecg.utoronto.ca/~aamodt/ece242/cygwin.html
I can't tell how many years ago that was.
The things that make Cygwin GCC packages confusing are:
gcc-core and cygwinXX-gcc-core are confusingly related (XX is 32 or 64 depending on your Cygwin architecture).
There are packages for both MinGW and MinGW-w64, which are different projects, although many people are unaware of their coexistence (I was).
As of Oct 2015, Cygwin GCC packages are broken down like this.
In Cygwin x86 (32-bit):
PROJECT: Cygwin GCC (Windows POSIX-enabled executables via linking to cygwin1.dll)
PACKAGE TARGET ARCH MAIN BINARY + LINKS (except versioned link)
gcc-core x86 /usr/bin/gcc.exe
/usr/bin/cc (symlink)
/usr/bin/i686-pc-cygwin-gcc.exe (hard link)
cygwin64-gcc-core x86_64 /usr/bin/x86_64-pc-cygwin-gcc.exe
PROJECT: MinGW (Windows 32-bit standalone executables)
PACKAGE TARGET ARCH MAIN BINARY + LINKS (except versioned link)
mingw-gcc-core x86 /usr/bin/i686-pc-mingw32-gcc.exe
PROJECT MinGW-w64 (fork from MinGW for building 64-bit)
PACKAGE TARGET ARCH MAIN BINARY + LINKS (except versioned link)
mingw64-i686-gcc-core x86 /usr/bin/i686-w64-mingw32-gcc.exe
mingw64-x86_64-gcc-core x86_64 /usr/bin/x86_64-w64-mingw32-gcc.exe
In Cygwin x86_64 (64-bit):
PROJECT: Cygwin GCC (Windows POSIX-enabled executables via linking to cygwin1.dll)
PACKAGE TARGET ARCH MAIN BINARY + LINKS (except versioned link)
gcc-core x86_64 /usr/bin/gcc.exe
/usr/bin/cc (symlink)
/usr/bin/x86_64-pc-cygwin-gcc.exe (hard link)
cygwin32-gcc-core x86 /usr/bin/i686-pc-cygwin-gcc.exe
PROJECT: MinGW (Windows 32-bit standalone executables)
PACKAGE TARGET ARCH MAIN BINARY + LINKS (except versioned link)
mingw-gcc-core x86 /usr/bin/i686-pc-mingw32-gcc.exe
PROJECT MinGW-w64 (fork from MinGW for building 64-bit)
PACKAGE TARGET ARCH MAIN BINARY + LINKS (except versioned link)
mingw64-i686-gcc-core x86 /usr/bin/i686-w64-mingw32-gcc.exe
mingw64-x86_64-gcc-core x86_64 /usr/bin/x86_64-w64-mingw32-gcc.exe
The following are for compiling 32-bit binaries in 64-bit Cygwin:
cygwin32-gcc-ada
cygwin32-gcc-core
cygwin32-gcc-fortran
cygwin32-gcc-g++
cygwin32-gcc-objc++
...
The following are the main gcc pieces. If you don't need some of these specific languages, like Ada or Fortran, don't install them.
gcc-ada
gcc-core
gcc-fortran
...
This is a library required by gcc.
libgcc1
The mingw (not minigw...those appear to be typos) version are for compiling programs in Cygwin that do not depend on Cygwin1.dll. Programs built with these use the Microsoft C RTL, and can be installed on systems that don't have Cygwin. They also are not subject to Cygwin's rather restrictive Open Source License. The ones whose names do not contain 64-i686 are for producing 32-bit binaries, while the ones that do are for producing 64-bit binaries.
mingw-gcc-core
mingw-gcc-g++
....
mingw64-i686-gcc-core
mingw64-i686-gcc-g++
Note that you can see all of this information at http://cygwin.com/packages.

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.

QT + CUDA setting qmake.pro file

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.

Resources