qmake not generating binary resource files - qt

Specs: Qt Creator 2.5.1, Qt 4.7.4(32bit)
It is my understanding from the Qt documentation that including a resource (.qrc) in the .pro file of Qt is all that is required to get qmake to generate the correct qrc_*.cpp files. That doesn't seem to be the case for my project. When running qmake the makes files are created and there are references to the qrc_ file I'm looking for under compiler_rcc_clean, just not in the build chain.
[Update]
At a suggestion from comments below the makefile generated by qmake was tested directly w/ NMAKE. The correct qrc_filter_ao.cpp file was created. However the IDE still fails to properly generate this file when I build from Qt Creator.
.pro:
include (../../shared.pri)
TARGET = filter_ao
QT += opengl
HEADERS += ./filter_ao.h
SOURCES += ./filter_ao.cpp
RESOURCES += \
filter_ao.qrc
shared.pri
include (./general.pri)
VCGDIR = ../$$VCGDIR
TEMPLATE = lib
CONFIG += plugin
CONFIG += resources
QT += opengl
QT += xml
QT += xmlpatterns
QT += script
win32-msvc2008: LIBS += ../../distrib/common.lib
win32-msvc2008:DEFINES += GLEW_STATIC _USE_MATH_DEFINES
INCLUDEPATH *= ../.. $$VCGDIR ../$$GLEWDIR/include
DEPENDPATH += ../.. $$VCGDIR
win32-msvc2008:DEFINES += _CRT_SECURE_NO_DEPRECATE
CONFIG(release,debug | release){
# Uncomment the following line to disable assert in mingw
#DEFINES += NDEBUG
}
DESTDIR = ../../distrib/plugins
contains(TEMPLATE,lib) {
CONFIG(debug, debug|release) {
unix:TARGET = $$member(TARGET, 0)_debug
else:TARGET = $$member(TARGET, 0)d
}
}
win32-msvc2008: RCC_DIR = $(ConfigurationName)
general.pri
VCGDIR = ../../../vcglib
GLEWDIR = ../external/glew-1.7.0
win32:DEFINES += NOMINMAX

I think #Pie_Jesu is correct. I have set up a directory structure with the files from the OP, and imported the .pro file into QtCreator. I have removed the "win32-msvc2008: " prefix from the line which sets RCC_DIR since I am using VS Express 2010.
Result was that I get a message like "Unable to open \qrc_filter_ao.cpp for writing: Access denied" and no qrc_file is being created.
I then set the line to /TEMP:
RCC_DIR = /TEMP
Result is that I find the qrc_ file below \TEMP.

Did you try with a simpler .pro file? For instance, the following works for me (On Linux, no MSVC env available currently):
TEMPLATE = lib
CONFIG += plugin
CONFIG += resources
QT += opengl
QT += xml
QT += xmlpatterns
QT += script
TARGET = filter_ao
QT += opengl
RESOURCES += \
filter_ao.qrc
Make sure that the output of from the build contain a call to $QTDIR/rcc, like
/usr/bin/rcc -name filter_ao filter_ao.qrc -o qrc_filter_ao.cpp

Related

Convert .pro lines in Qt to cmake lines

I need to convert two lines from .pro file in Qt to corresponding lines in CMake:
CONFIG -= staticlib
CONFIG += shared
what should I write in cmakelist file to generate teh same effect as this ?
.pro file :
#-------------------------------------------------
#
# Project created by QtCreator 2017-10-10T11:50:45
#
#-------------------------------------------------
QT += testlib network concurrent xml
QT -= gui
QT += xmlpatterns
DEFINES += CID_SDK_LIBRARY
CONFIG -= staticlib
CONFIG += shared
CONFIG(debug,debug|release) {
message(Compiled in Debug)
debug: DESTDIR = debug
} else {
message( Compiled in Release )
release: DESTDIR = release
}
OBJECTS_DIR = $$DESTDIR/.obj
MOC_DIR = $$DESTDIR/.moc
RCC_DIR = $$DESTDIR/.qrc
TARGET = lib/cid-sdk
TEMPLATE = lib
#CONFIG += staticlib c++11
CONFIG += sharedlib c++11
# The following define makes your compiler emit warnings if you use
# any feature of Qt which as been marked as deprecated (the exact warnings
# depend on your compiler). Please consult the documentation of the
# deprecated API in order to know how to port your code away from it.
DEFINES += QT_DEPRECATED_WARNINGS
# You can also make your code fail to compile if you use deprecated APIs.
# In order to do so, uncomment the following line.
# You can also select to disable deprecated APIs only up to a certain version of Qt.
DEFINES += QT_DISABLE_DEPRECATED_BEFORE=0x060000 # disables all the APIs deprecated before Qt 6.0.0
#TEMPLATE = subdirs
#SUBDIRS += \
# tests\UnitTests # an "app" project
#UnitTests.depends = Nl.Aet.Cid.Client.Sdk Nl.Aet.Cid.Client.Sdk.Core Nl.Aet.Cid.Sdk.Desktop.Gateway
include(Nl.Aet.Cid.Client.Deps\Nl.Aet.Cid.Client.Deps.pri)
include(Nl.Aet.Cid.Client.Sdk.Core\Nl.Aet.Cid.Client.Sdk.Core.pri)
include(Nl.Aet.Cid.Client.Sdk\Nl.Aet.Cid.Client.Sdk.pri)
#include(Nl.Aet.Cid.Enabler\Nl.Aet.Cid.Enabler.pri)
##Desktop API
include(Nl.Aet.Cid.Sdk.Desktop.Gateway\Nl.Aet.Cid.Sdk.Desktop.Gateway.pri)
include(Nl.Aet.Cid.Client.Sdk.Desktop\Nl.Aet.Cid.Client.Sdk.Desktop.pri)
#Web API
include(Nl.Aet.Cid.Sdk.Web.Gateway\Nl.Aet.Cid.Sdk.Web.Gateway.pri)
include(Nl.Aet.Cid.Client.Sdk.Web\Nl.Aet.Cid.Client.Sdk.Web.pri)
unix {
target.path = /usr/lib
INSTALLS += target
}
note : I edited it to add the .pro file as requested.
Thanks in advance.
In qmake every .pro file yields a "module" in your project structure. The module has a product. This product might be an executable/application, static library, or a dynamic/shared library.
CMake on the other hand does not do this implicitly. To add module one would normally use the add_library function.
To mimic this particular behavior you would write either
project("my_library")
set(sources <your source files go here>)
add_library("my_library" STATIC ${sources})
or
project("my_library")
set(sources <your source files go here>)
add_library("my_library" SHARED ${sources})
Now the problem here is that we're missing the list of sources. In your case they are defined in the .pri files.

qmake, build producing a custom library name

I have a .pro file named XYZ.pro. Here is it.
QT += core gui
TARGET = XYZ
TEMPLATE = lib
CONFIG += plugin
DESTDIR = $$[QT_INSTALL_PLUGINS]/generic
SOURCES += cc.cpp
HEADERS += cc.h
DISTFILES += XYZ.json
I want the build to product a library ABC.o.
How do I do this?
TARGET = ABC
And make sure qmake is re-run after the change.

Linking dll to c++ in qt for reading .mat files

I am using Qt Creator 2.4.1(Based on Qt 4.7.4) ..
Now I want to open the .mat file which I got from Matlab.
I am using the basic function matOpen
Initially, I knew the headers required. They are mat.h, matrix.h and tmw.h.
Now, before running the code, I need to link the libraries. The required libraries as far as I know are libmat.dll and libmw.dll . I added them to the .pro file as follows.
QT += core
QT -= gui
TARGET = mat_open_test
CONFIG += console
CONFIG -= app_bundle
TEMPLATE = app
SOURCES += main.cpp
HEADERS += \
mat.h \
matrix.h \
tmwtypes.h
LIBS += -L"C:\Users\skanduri\Documents\C ++\mat_open_test-build-desktop- Qt_4_8_1_for_Desktop_-_MinGW__Qt_SDK__Debug\debug\libmat.dll"
LIBS += -L"C:\Users\skanduri\Documents\C ++\mat_open_test-build-desktop-Qt_4_8_1_for_Desktop_-_MinGW__Qt_SDK__Debug\debug\libmx.dll"
Still I get error as : undefined reference to matOpen.. m sure the problem is with the linking.. But I dunno how to solve it. and the compiler Qt is using is MinGw .
You are specifying library path only, not the libraries itself. Try
LIBS += -L"C:\Users\skanduri\Documents\C ++\mat_open_test-build-desktop-Qt_4_8_1_for_Desktop_-_MinGW__Qt_SDK__Debug\debug"
LIBS += -llibmx
LIBS += -llibmat

Run time error for a missing DLL which exists

I am writing a tool with Qt Creator which builds but immediately crashes with the message:
"The program can't start because pthreadVC2.dll is missing from your
computer. Try reinstalling the program to fix this problem".
Of course, the "pthreadVC2.dll" library is not missing (and is not corrupted, since it works with other projects), and it is located in the path specified in the Qt pro file:
# DeltaPlots.pro
TARGET = DeltaPlots
QT += core gui
CONFIG += console
greaterThan(QT_MAJOR_VERSION, 4): QT += widgets
TEMPLATE = app
win32 {
INCLUDEPATH += S:\\3rdparty\\DFS.Infrastructure.ThreadingW \
S:\\3rdparty\\DFS.Infrastructure.File \
"C:\\path\\to\\boost\\boost_1_51_0"
win32-g++:LIBS += -L"S:\\lib\\" -lMyLib
win32-g++:LIBS += -L"S:\\3rdparty\\DFS.Infrastructure.File\\" -lDFS.Infrastructure.FileSystem
win32-g++:LIBS += -L"S:\\3rdparty\\DFS.Infrastructure.ThreadingW\\" -lDFS.Infrastructure.Threading -lpthreadVC2
}
SOURCES += MainWindow.cpp \
entrypoint.cpp
HEADERS += MainWindow.h
FORMS += MainWindow.ui
OTHER_FILES += ProjectList.txt \
ImageList.txt
Platform:
Windows 7
MinGW
Qt 4.8.3
Qt Creator 2.6.0
[Edit: This answer refers to the original question]
Usually you would add
LIBS += -LS:/3rdparty/DFS.Infrastructure.ThreadingW \
-lpthreadVC2
This adds your library's folder as a library search path (Note the capital -L) and pthreadVC2.lib as a library to link against (lower case -l).
You do not need to add the .dll to the LIBS path, as the .dll is loaded at runtime.
But: This approach only works when the .lib is in the same folder as the .dll. I'm a bit surprised you have yours in different locations.
Maybe adding
LIBS += -LS:/3rdparty
would work, but I'm not sure about that.
In any event, you need to deploy the .dll with your .exe for releases.

Howto use QCA(http://delta.affinix.com/qca/) with Qt4.7 (Qt Creator)?

I want to use the QCA Library with QT4.7 and QTCreator as IDE.
I downloaded the "qca-2.0.2-mingw" Version and try to link them in my ".Pro"-file:
QT += core
QT -= gui
LIBS += -L"\qca-2.0.2-mingw\lib\"
LIBS += -lqca2
CONFIG *= qt
CONFIG += console
CONFIG -= app_bundle
INCLUDEPATH += "\qca-2.0.2-mingw\include\QtCrypto"
INCLUDEPATH += "\qca-2.0.2-mingw\bin"
TARGET = untitled1
TEMPLATE = app
LINKAGE = -lqca
CONFIG(debug, debug|release) {
windows:LINKAGE = -lqcad
mac:LINKAGE = -lqca_debug
}
LIBS += $$LINKAGE
SOURCES += main.cpp
it compiles but when I run a HMAC sample, copied from this location, http://delta.affinix.com/docs/qca/mactest_8cpp-example.html#_a6
the application stuck with the following error:
Starting C:\Qt\2010.04\qt\untitled1\release\untitled1.exe...
C:\Qt\2010.04\qt\untitled1\release\untitled1.exe exited with code -1073741515
Commenting out some lines doesn't bring the effect. Even the first line of the HMAX Example, will lead to the results described above "QCA::Initializer init;"
I've tried the "qca-2.0.0-mingw" also, but the same effect occurres.
Greets and Thanks first,
Marco
If it builds, that's already good. If it doesn't start, usually DLLs are not found, at runtime. Try adding the path to the qca DLLs to your PATH. In creator you can configure that in the Run Environment section of your Run configuration (Project/Run Settings).

Resources