I reinstalled windows. And after that, the path to my project changed. Qt gives me a build error.
Cannot find file: C:\Users\...
I've tried deleting all past builds. And ".pro.user" files, but that didn't help either.
This is files.pro code.
QT += quick
# You can make your code fail to compile if it uses deprecated APIs.
# In order to do so, uncomment the following line.
#DEFINES += QT_DISABLE_DEPRECATED_BEFORE=0x060000 # disables all the APIs deprecated before Qt 6.0.0
SOURCES += \
main.cpp
RESOURCES += qml.qrc \
images.qrc
# Additional import path used to resolve QML modules in Qt Creator's code model
QML_IMPORT_PATH =
# Additional import path used to resolve QML modules just for Qt Quick Designer
QML_DESIGNER_IMPORT_PATH =
# Default rules for deployment.
qnx: target.path = /tmp/$${TARGET}/bin
else: unix:!android: target.path = /opt/$${TARGET}/bin
!isEmpty(target.path): INSTALLS += target
This is qml.qrc code.
<RCC>
<qresource prefix="/">
<file>main.qml</file>
<file>Cell.qml</file>
<file>SliderCell.qml</file>
<file>Calendar1.qml</file>
<file>Calendar2.qml</file>
<file>FiltersCheckBox.qml</file>
<file>DropDownListCell.qml</file>
</qresource>
</RCC>
This is error image.
I changed the name of the folder. I was using russian symbols.
IF U HAVE THE SAME ERROR CHECK THE NAMES OF THE FOLDERS.
Related
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.
I have a QML plugin project and my application project plus subdirs project organized like that:
project.pro
plugin/
plugin.pro
Plugin.cpp
Plugin.h
qmldir
app/
app.pro
main.cpp
main.qml
qml.qrc
project.pro:
TEMPLATE = subdirs
SUBDIRS = app plugin
app.depends = plugin
plugin.pro:
TEMPLATE = lib
QT += qml quick
CONFIG += plugin c++11
TARGET = $$qtLibraryTarget(plugin)
PLUGIN_URI = com.test.plugin
SOURCES += Plugin.cpp
HEADERS += Plugin.h
app.pro:
QT += qml quick
SOURCES += main.cpp
RESOURCES += qml.qrc
It builds as expected and now I need to pass path to compiled libplugin.dylib/.so/.dll and qmldir to my application. I see two ways:
Copy plugin files into /path/to/qt/5.10.1/clang_64/qml/com/test/plugin/ using INSTALL qmake variable.
Copy plugin files near the application executable and add this path as relative to the executable using QQmlEngine::addImportPath().
What approach will be better? How to do it?
I found a few other hits when searching for this particular problem, but i cant get my setup to work with my unit test project(s).
project info: ( optional reading)
I am in the beginning of my final undergraduate project, where I am to
create an IDE for the language Promula and the the
verification tool Spin. The professor I am doing this with expects to
use it in his classes and for future undergraduates to keep improving. It is also meant to be a open source project everyone can contribute to.
Spin tool
my folder struture:
QSpin
-QSpin.pro
-QSpinApplication
--QSpinapplication.pro
--QSpinApplication.pri
--include
---Workspace
----*.h
--src
---Workspace
----*.cpp
-QSpinApplicationTests
--QSpinApplicationTests.pro
--WorkspaceGroupTests
---WorkspaceGroupTests.pro
----some cpp testfile
My QSpinApplication compiles and runs without any problems. The import of what i have so can be imported.
#include <Workspace/(file_name).h>
However in my test project WorkspaceGroupTests i want to include headers in the same way, but i cant get it to work. Beside that i assume the test project need to know where the cpp files are. If i dont use any of the application headers the test project compiles and runs with the default test case.
at the moment i am using a default shadow build with its root folder in the QSpin folder.
Any idea of how i get my test project working correctly, to actual be able to test my application classes?
QSpin.pro:
TEMPLATE = subdirs
CONFIG += ordered
SUBDIRS += \
QSpinApplication\QSpinApplication.pro \
QSpinApplicationTests
QSpinApplication.pro:
QT += quick qml gui
CONFIG += c++11
DEFINES += QT_DEPRECATED_WARNINGS
SOURCES +=src/main.cpp
include(QSpinApplication.pri)
RESOURCES += qml.qrc
qnx: target.path = /tmp/$${TARGET}/bin
else: unix:!android: target.path = /opt/$${TARGET}/bin
!isEmpty(target.path): INSTALLS += target
QSpinApplication.pri:
#//DEPENDPATH += $$PWD
INCLUDEPATH += ./include
SOURCES +=src/workspace/workspaceview.cpp \
src/workspace/groupitem.cpp \
src/workspace/groupitemsplitter.cpp \
src/workspace/workspacegroup.cpp \
src/workspace/workspaceviewattached.cpp \
src/workspace/workspaceviewiteminfo.cpp \
src/workspace/workspacegrouplinknode.cpp
HEADERS += \
include/workspace/workspaceview.h \
include/workspace/groupitem.h \
include/workspace/groupitemsplitter.h \
include/workspace/workspacegroup.h \
include/workspace/workspaceviewattached.h \
include/workspace/workspace.h \
include/workspace/workspaceviewiteminfo.h \
include/workspace/workspacegrouplinknode.h
QSpinApplicationTests.pro:
TEMPLATE = subdirs
SUBDIRS += \
WorkspaceGroupTests
WorkspaceGroupTests.pro:
QT += testlib
QT -= gui
DEPENDPATH+=./../../QSpinApplication
include(./../../QSpinApplication/QSpinApplication.pri)
CONFIG += qt console warn_on depend_includepath testcase
CONFIG -= app_bundle
TEMPLATE = app
SOURCES += tst_workspacegrouptests.cpp
Not sure if I understood well but in general, what I would advise is to create a separate structure for "lib" where you put logic code that can be tested, so default structure would look like that:
Structure:
├───app.pro
├───lib.pro
└───tests.pro
Then you put in your lib.pro:
TARGET = NameOfTarget
TEMPLATE = lib
CONFIG += staticlib
and add in your tests.pro, and in app.pro:
LIBS += -L../lib -lNameOfTarget
At end it should be possible without problems to include in app directory and in test:
#include "anyHeaderFromLib.h" .
As an extra addition for Michal Kalinowski answer:
Looks like this will work only for Linux/Mac, in case of Windows you should handle it on that way:
win32:CONFIG(release, debug|release): LIBS += -L../lib/debug -lNameOfTarget
else:win32:CONFIG(debug, debug|release): LIBS += --L../lib/release -lNameOfTarget
else:unix: LIBS += -L../lib -lNameOfTarget
Some more context can be get here: https://doc.qt.io/qtcreator/creator-project-qmake-libraries.html
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.
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).