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

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.

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 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.

linking libraries in qt creator for c++ project

I am creating normal c++ project using QT creator .
I need to link the boost library. I have used this in eclipse project under Project Properties/C C++ build/Gcc C++ linker/-l boost_filesystem but i am not sure how to do it in QT creator.
I use Qt, but not Qt-Creator so I'm not sure where in it's UI you might do this.
But in the .pro file (the input to the makefile), you would specify the library with:
LIBS += -lboost_filesystem # assuming 'boost_filesystem' is the name of the lib file
LIBS += -L/[wherever boost lib files are on your system]
"-l" is the file name and "-L" is the library path name.
LIBS += -lboost_filesystem -L/[wherever boost lib files are on your system]
works too.
"+=" appends it to the current QMake variables, be careful about using "=", unless you really intend to replace the values.
I don't know, if this is still an issue for you, but I answer because it may help some others like me who had a similar issue.
As far as I understood it: When you use QtCreator with normal C++ you will be asked which build tool to use. I have chosen CMake, so from now on everything goes via CMake and less things go directly via QtCreator. That's the reason that there is no .pro file anymore.
So what I did to resolve the issue was to add following line after the add_executable(...) line in the CMakeLists.txt file:
target_link_libraries(my_project_name -lboost_system)
Note: I just needed lboost_system, but I think that just expanding the list with -lboost_filesystem etc.. will do the job.
Hope that it helps somebody.

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.

How can I force qtcreator to create non-universal binaries

When I use qtcreator on mac, it creates universal binaries.
Does anyone know how to set it so it just creates a 'native' binary? (So i386' in my case?)
Qtcreator uses qmake as a buildsystem.
Google hasn't been my friend so far, I hope stackoverflow will.
EDIT:
my config file so far:
TARGET = mongowriter
CONFIG += console
CONFIG -= app_bundle
CONFIG += x86
#CONFIG -= ppc
TEMPLATE = app
INCLUDEPATH += /opt/local/include/.
INCLUDEPATH += ../mongodb/.
SOURCES += main.cpp
LIBS += /usr/local/lib/libmongoclient.a
LIBS += /opt/local/lib/libboost_thread-mt.a
LIBS += /opt/local/lib/libboost_filesystem.a
LIBS += /opt/local/lib/libboost_program_options.a
It still gives the error on the libmongoclient.a
The libboost libraries are all ok, but this is because I got them from macports with the +universal option.
Since mongoclient doesn't support universal I'm currently removing all the universal stuff. I was hoping to get 3 errors for the boost libs and that at l;east mongoclient would link.
At that point I could redo the whole macport story again but this time with universal removed.
Unfortunately it seems it still builds a universal binary since I still have the same linker errors.
thanks for the help
you can use the 'CONFIG' variable in your project file to specify which plattforms shall be supported to create a universial binary you use
CONFIG += x86 ppc
if you only need x86 you use
CONFIG += x86

Resources