qmake not finding opencv package when built from within Qt creator - macos

I am fairly new to the Qt environment and I am running into an error when I try to build. I am also new to StackOverflow so pardon me if I miss format. When I run qmake from the command line it finds the opencv package and generates a Makefile, however when I run it from Qt Creator, it fails to find OpenCV.
Here is my .pro file
#-------------------------------------------------
#
# Project created by QtCreator 2013-03-24T21:23:01
#
#-------------------------------------------------
QT += core
QT -= gui
TARGET = cvtest
CONFIG += console
CONFIG -= app_bundle
CONFIG+=link_pkgconfig
PKGCONFIG+=opencv
TEMPLATE = app
SOURCES += main.cpp
I think it has to do with fully qualifying the path to qmake.
If I run
qmake /Users/matt/untitled1/untitled1.pro -r -spec macx-g++ CONFIG+=x86_64
on the command line it works fine, however if I fully qualify the path to qmake in the manner that Qt Creator does it;
/Users/matt/Qt5.0.0/5.0.0/clang_64/bin/qmake /Users/matt/untitled1/untitled1.pro
I get the following error:
Project ERROR: Package opencv not found
Any ideas on how to make this work in Qt Creator without going to the command line?

Try adding this to your .pro file:
QT_CONFIG -= no-pkg-config
I believe Qt for the Mac is built with the --no-pkg-config configure option.

Related

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.

Configure qxt library under Windows

I want to include into my Qt 4.8.1 project the Qxt 0.6.2 library.
I followed the steps from their user guide and at the end the library was installed in: C:\Qxt. I have added these two lines in my project .pro file:
CONFIG += qxt
QXT += core gui
and when i compile the following error appears:
error: cannot find -lQxtGuid
Also in C:\Qxt\doc no documentation was generated and the command assistant -addContentFile C:\libqxt\doc\html\qxt.dcf is not working nor the file qxt.dcf exists.
Edit 1: My problem was solved by selecting to use release libs from Qt compile options

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

How do I make apps smaller with qmake and macdeployqt

How do I make apps smaller with qmake and macdeployqt?
I have set QT = core gui in the projects .pro file and run qmake and macdeployqt on the resulting app.
The problem is that the program is bundling QtNetwork, QtScript, QtSvg etc. I've tried setting QT -= network script svg (and then make clean, rm -rf *.app, qmake, make).
In total the app is 32 MB.
.pro file:
TEMPLATE = app
TARGET = throw
DEPENDPATH += .
INCLUDEPATH += .
CONFIG += x86_64 release
QT = core gui
unix {
CONFIG += link_pkgconfig
PKGCONFIG += glib-2.0
}
# Input
SOURCES += main.cpp
# Headers
HEADERS += throw.h
RESOURCES += throw.qrc
ICON = throw.png
mac {
QMAKE_INFO_PLIST = Info.plist
ICON = throw.icns
}
This is a great article about (re)building Qt statically and dynamically to reduce its size considerably: Building Qt Static (and Dynamic) and Making it Small with GCC, Microsoft Visual Studio, and the Intel Compiler
While this is talking about Qt in the windows context, it does give some good insight into how one would go about compiling for minimal size.
You could strip the binary afterwards in a post-build step. The Qt libraries themselves are shared by default.

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