I work on Windows 10 x64
IDE: QtCreator 4.8.0 Based on Qt 5.12.0 (MSVC 2015, 32 bit)
Content of my .pro file is at the very bottom if it's needed.
There is a minimal OSG sample (main.cpp):
#include <osgDB/ReadFile>
#include <osgViewer/Viewer>
#include <ogrsf_frmts.h>
int main(int argc, char *argv[]) {
// OGRPoint p; //breakpoint 1
osg::ref_ptr<osg::Node> root = osgDB::readNodeFile("../resourses/cessna.osg"); //breakpoint 2
osgViewer::Viewer viewer;
viewer.setSceneData(root.get());
return viewer.run();
}
In the code above you can see, where i set breakpoints.
So:
In case with commented OGRPoint p;:
It compiles, runs, stops on "breakpoint 2" and when i go forward it shows the airplane (model "cessna.osg"). This is correct behavior.
In case with uncommented OGRPoint p;:
It compiles, runs and ignore both breakpoints. It doesn't show anything. As if i had nothing in my main. If i do it on Linux, then it works fine. Why does it can happen?
.pro file, if it affects :
TEMPLATE = app
TARGET = hello
QT -= gui
CONFIG += c++11 console
CONFIG -= app_bundle
# The following define makes your compiler emit warnings if you use
# any Qt feature that has been marked 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 it uses 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
SOURCES += \
main.cpp
# Default rules for deployment.
qnx: target.path = /tmp/$${TARGET}/bin
else: unix:!android: target.path = /opt/$${TARGET}/bin
!isEmpty(target.path): INSTALLS += target
#<--------------------- OSG Library
win32 {
OSG_LIB_DIRECTORY = $$(OSG_BIN)
OSG_INCLUDE_DIRECTORY = $$(OSG_INCLUDE)
CONFIG(debug, debug|release) {
TARGET = $$join(TARGET,,,_d)
LIBS += -L$$OSG_LIB_DIRECTORY -losgd
LIBS += -L$$OSG_LIB_DIRECTORY -losgViewerd
LIBS += -L$$OSG_LIB_DIRECTORY -losgDBd
LIBS += -L$$OSG_LIB_DIRECTORY -lOpenThreadsd
LIBS += -L$$OSG_LIB_DIRECTORY -losgUtild
LIBS += -L$$OSG_LIB_DIRECTORY -losgGAd
} else {
LIBS += -L$$OSG_LIB_DIRECTORY -losg
LIBS += -L$$OSG_LIB_DIRECTORY -losgViewer
LIBS += -L$$OSG_LIB_DIRECTORY -losgDB
LIBS += -L$$OSG_LIB_DIRECTORY -lOpenThreads
LIBS += -L$$OSG_LIB_DIRECTORY -losgUtil
LIBS += -L$$OSG_LIB_DIRECTORY -losgGA
}
INCLUDEPATH += $$OSG_INCLUDE_DIRECTORY
}
unix {
CONFIG(debug, debug|release) {
TARGET = $$join(TARGET,,,_d)
LIBS += -losgd
LIBS += -losgViewerd
LIBS += -losgDBd
LIBS += -lOpenThreadsd
} else {
LIBS += -losg
LIBS += -losgViewer
LIBS += -losgDB
LIBS += -lOpenThreads
}
}
#--------------------- OSG Library !>
HEADERS += $$OSG_INCLUDE_DIRECTORY
#<--------------------- GDAL Library
win32 {
INCLUDEPATH += D:/Interface/Work/Libs/gdal/include/
LIBS += D:/Interface/Work/Libs/gdal/lib/libgdal-20.dll
}
unix {
LIBS += -L/usr/local/lib -lgdal
}
#--------------------- GDAL Library !>
Problem was that the library needed libgdal-20.dll to work. I didn't specify the path to the .dll. So i resolved this problem by copiyng the .dll file into folder with binaries. Now it works fine.
Related
I'm trying to build gRPC library with Windows 10 with QT. Im using QT creator 5.15.2 MSVC 2019 compiler kit. I installed protobuf and grpc using vcpkg. I can able to successfully test protobuf libraries. But failing to do so with gRPC.
Getting the following error.
grpc.lib(check_gcp_environment_windows.cc.obj):-1: error: LNK2019: unresolved external symbol imp_RegGetValueA referenced in function "bool cdecl grpc_core::internal::check_windows_registry_product_name(struct HKEY *,char const *,char const *)" (?check_windows_registry_product_name#internal#grpc_core##YA_NPEAUHKEY##PEBD1#Z)
I have tried linking the libraries one by one in QT like below. Attached my .pro file here
QT -= gui
CONFIG += c++17 console
CONFIG -= app_bundle
# 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
LIBS += C:/vcpkg/installed/x64-windows/debug/lib/zlibd.lib
LIBS += C:/vcpkg/installed/x64-windows/debug/lib/abseil_dll.lib
LIBS += C:/vcpkg/installed/x64-windows/debug/lib/absl_cord_internal.lib
LIBS += C:/vcpkg/installed/x64-windows/debug/lib/absl_cordz_functions.lib
LIBS += C:/vcpkg/installed/x64-windows/debug/lib/absl_cordz_handle.lib
LIBS += C:/vcpkg/installed/x64-windows/debug/lib/absl_cordz_info.lib
LIBS += C:/vcpkg/installed/x64-windows/debug/lib/absl_cordz_sample_token.lib
LIBS += C:/vcpkg/installed/x64-windows/debug/lib/absl_flags.lib
LIBS += C:/vcpkg/installed/x64-windows/debug/lib/absl_flags_commandlineflag.lib
LIBS += C:/vcpkg/installed/x64-windows/debug/lib/absl_flags_commandlineflag_internal.lib
LIBS += C:/vcpkg/installed/x64-windows/debug/lib/absl_flags_config.lib
LIBS += C:/vcpkg/installed/x64-windows/debug/lib/absl_flags_internal.lib
LIBS += C:/vcpkg/installed/x64-windows/debug/lib/absl_flags_marshalling.lib
LIBS += C:/vcpkg/installed/x64-windows/debug/lib/absl_flags_parse.lib
LIBS += C:/vcpkg/installed/x64-windows/debug/lib/absl_flags_private_handle_accessor.lib
LIBS += C:/vcpkg/installed/x64-windows/debug/lib/absl_flags_program_name.lib
LIBS += C:/vcpkg/installed/x64-windows/debug/lib/absl_flags_reflection.lib
LIBS += C:/vcpkg/installed/x64-windows/debug/lib/absl_flags_usage.lib
LIBS += C:/vcpkg/installed/x64-windows/debug/lib/absl_flags_usage_internal.lib
LIBS += C:/vcpkg/installed/x64-windows/debug/lib/absl_low_level_hash.lib
LIBS += C:/vcpkg/installed/x64-windows/debug/lib/absl_random_internal_distribution_test_util.lib
LIBS += C:/vcpkg/installed/x64-windows/debug/lib/absl_statusor.lib
LIBS += C:/vcpkg/installed/x64-windows/debug/lib/absl_strerror.lib
LIBS += C:/vcpkg/installed/x64-windows/debug/lib/address_sorting.lib
LIBS += C:/vcpkg/installed/x64-windows/debug/lib/cares.lib
LIBS += C:/vcpkg/installed/x64-windows/debug/lib/descriptor_upb_proto.lib
LIBS += C:/vcpkg/installed/x64-windows/debug/lib/gpr.lib
LIBS += C:/vcpkg/installed/x64-windows/debug/lib/grpc.lib
LIBS += C:/vcpkg/installed/x64-windows/debug/lib/grpc_plugin_support.lib
LIBS += C:/vcpkg/installed/x64-windows/debug/lib/grpc_unsecure.lib
LIBS += C:/vcpkg/installed/x64-windows/debug/lib/grpc++.lib
LIBS += C:/vcpkg/installed/x64-windows/debug/lib/grpc++_alts.lib
LIBS += C:/vcpkg/installed/x64-windows/debug/lib/grpc++_error_details.lib
LIBS += C:/vcpkg/installed/x64-windows/debug/lib/grpc++_reflection.lib
LIBS += C:/vcpkg/installed/x64-windows/debug/lib/grpc++_unsecure.lib
LIBS += C:/vcpkg/installed/x64-windows/debug/lib/grpcpp_channelz.lib
LIBS += C:/vcpkg/installed/x64-windows/debug/lib/libcrypto.lib
LIBS += C:/vcpkg/installed/x64-windows/debug/lib/libprotobufd.lib
LIBS += C:/vcpkg/installed/x64-windows/debug/lib/libprotobuf-lited.lib
LIBS += C:/vcpkg/installed/x64-windows/debug/lib/libprotocd.lib
LIBS += C:/vcpkg/installed/x64-windows/debug/lib/libssl.lib
LIBS += C:/vcpkg/installed/x64-windows/debug/lib/re2.lib
LIBS += C:/vcpkg/installed/x64-windows/debug/lib/upb.lib
LIBS += C:/vcpkg/installed/x64-windows/debug/lib/upb_collections.lib
LIBS += C:/vcpkg/installed/x64-windows/debug/lib/upb_extension_registry.lib
LIBS += C:/vcpkg/installed/x64-windows/debug/lib/upb_fastdecode.lib
LIBS += C:/vcpkg/installed/x64-windows/debug/lib/upb_json.lib
LIBS += C:/vcpkg/installed/x64-windows/debug/lib/upb_mini_table.lib
LIBS += C:/vcpkg/installed/x64-windows/debug/lib/upb_reflection.lib
LIBS += C:/vcpkg/installed/x64-windows/debug/lib/upb_textformat.lib
LIBS += C:/vcpkg/installed/x64-windows/debug/lib/upb_utf8_range.lib
INCLUDEPATH += C:\vcpkg\installed\x64-windows\include
HEADERS += \
helloworld.grpc.pb.h \
helloworld.pb.h
SOURCES += \
main.cpp \
helloworld.grpc.pb.cc \
helloworld.pb.cc
# Default rules for deployment.
qnx: target.path = /tmp/$${TARGET}/bin
else: unix:!android: target.path = /opt/$${TARGET}/bin
!isEmpty(target.path): INSTALLS += target
There were few errors w.r.2 ws2_32 lib. which I have neglected using the following pragma statement.
#pragma comment(lib, "Ws2_32.lib")
But the error LNK2019: unresolved external symbol __imp_RegGetValueA referenced in function . I couldnt find any. I believe its something related to re2.lib linked. Kindly add your thoughts. Thanks
So, I'm trying to run this example program in qt using the tomcrypt library and when I tried to build the project the compiler threw this error: LNK1104: cannot open file 'tomcryptd.lib', I added the tomcrypt library using the "Add library" interface and these are the contents of the .pro file:
QT -= gui
CONFIG += c++17 console
CONFIG -= app_bundle
#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
TRANSLATIONS += \
ProjectM2_en_US.ts
CONFIG += lrelease
CONFIG += embed_translations
#Default rules for deployment.
qnx: target.path = /tmp/$${TARGET}/bin
else: unix:!android: target.path = /opt/$${TARGET}/bin
!isEmpty(target.path): INSTALLS += target
win32:CONFIG(release, debug|release): LIBS += -L$$PWD/../../libraries/libtomcrypt/lib/ -ltomcrypt
else:win32:CONFIG(debug, debug|release): LIBS += -L$$PWD/../../libraries/libtomcrypt/lib/ -ltomcryptd
INCLUDEPATH += $$PWD/../../libraries/libtomcrypt/include
DEPENDPATH += $$PWD/../../libraries/libtomcrypt/include
I have tried searching for solutions but so far, I have not found one that worked for me. I'll be really thankful if anyone has a solution for my problem
I'm a newbie in using cgal , I tried the following example :
#include <QGuiApplication>
#include <QQmlApplicationEngine>
#include <CGAL/Exact_predicates_inexact_constructions_kernel.h>
#include <CGAL/Polyhedron_3.h>
#include <CGAL/IO/Polyhedron_iostream.h>
#include <CGAL/draw_polyhedron.h>
#include <fstream>
typedef CGAL::Exact_predicates_inexact_constructions_kernel Kernel;
typedef CGAL::Polyhedron_3<Kernel> Polyhedron;
int main(int argc, char *argv[])
{
QCoreApplication::setAttribute(Qt::AA_EnableHighDpiScaling);
QGuiApplication app(argc, argv);
Polyhedron P;
std::ifstream in1((argc>1)?argv[1]:"data/bones.off");
in1 >> P;
CGAL::draw(P);
return app.exec();
}
.pro file :
QT += quick opengl
CONFIG += c++11
QT +=xml widgets
# The following define makes your compiler emit warnings if you use
# any feature of Qt which as been marked 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
SOURCES += \
main.cpp
RESOURCES += qml.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
unix:!macx: LIBS += -L$$PWD/../../CGAL-4.13/lib/ -lCGAL_Core
INCLUDEPATH += $$PWD/../../CGAL-4.13/include
DEPENDPATH += $$PWD/../../CGAL-4.13/include
unix:!macx: LIBS += -L$$PWD/../../CGAL-4.13/lib/ -lCGAL
INCLUDEPATH += $$PWD/../../CGAL-4.13/include
DEPENDPATH += $$PWD/../../CGAL-4.13/include
unix:!macx: LIBS += -L$$PWD/../../CGAL-4.13/lib/ -lCGAL_Qt5
INCLUDEPATH += $$PWD/../../CGAL-4.13/include
DEPENDPATH += $$PWD/../../CGAL-4.13/include
QMAKE_CXXFLAGS +=-DCGAL_USE_BASIC_VIEWER
LIBS+=-DCGAL_USE_BASIC_VIEWER
unix:!macx: LIBS += -L$$PWD/../../CGAL-4.13/lib/ -lCGAL_ImageIO
INCLUDEPATH += $$PWD/../../CGAL-4.13/include
DEPENDPATH += $$PWD/../../CGAL-4.13/include
unix:!macx: LIBS += -L$$PWD/../../../../lib64/ -lQt5Xml
INCLUDEPATH += $$PWD/../../../../lib64
DEPENDPATH += $$PWD/../../../../lib64
unix:!macx: LIBS += -L$$PWD/../../../../lib64/ -lQt5OpenGL
INCLUDEPATH += $$PWD/../../../../lib64
DEPENDPATH += $$PWD/../../../../lib64
unix:!macx: LIBS += -L$$PWD/../../../../lib64/ -lgmp
INCLUDEPATH += $$PWD/../../../../lib64
DEPENDPATH += $$PWD/../../../../lib64
unix:!macx: LIBS += -L$$PWD/../../../../lib64/ -lboost_system
INCLUDEPATH += $$PWD/../../../../lib64
DEPENDPATH += $$PWD/../../../../lib64
the source of example : https://doc.cgal.org/latest/Polyhedron/Polyhedron_2draw_polyhedron_8cpp-example.html#a2
the problem is it shows black viewer , I don't know what's the problem
I'm using qt-creator on Fedora OS
any help ,please?
I have created a project in qt creator with multiple subdirs and am deploying/running it on a beaglebone. Compiles fine, deploys fine, etc.
My issue is that when I try to debug, the only files I can set breakpoints in or step into are those in the same subdir where main.cpp is. Just to test, I duplicated the project with a flat folder structure and can set breakpoints and step into everything.
When the debugger starts up, the debug log tries to set the breakpoints and fails seemingly because it can't find the .cpp files:
"No source file named projectdir/dir1/myclass.cpp.\n"
8045^done,bkpt={number="1",type="breakpoint",disp="keep",enabled="y",addr="",pending="\"projectdir/dir1/myclass.cpp\":7",times="0",original-location="\"fullpathofprojectdir/dir1/myclass.cpp\":7"}
Whereas it says this for breakpoints in main:
8046^done,bkpt={number="2",type="breakpoint",disp="keep",enabled="y",addr="0x0001831c",func="main(int, char**)",file="projectdir/dir2/main.cpp",fullname="fullpathofprojectdir/dir2/main.cpp",line="27",thread-groups=["i1"],times="0",original-location="fullpathofprojectdir/dir2/main.cpp:27"}
Additionally, myclass.cpp doesn't show up in the source files panes either. How can I resolve this?
Here is the setup of my *.pro files:
Top level project file:
TEMPLATE = subdirs
SUBDIRS += \
dir1 \
dir2
unix {
target.path = /home/debian
INSTALLS += target
}
Project file of library (dir1, myclass.cpp, etc):
QT -= gui
TARGET = Common
TEMPLATE = lib
DEFINES += COMMON_LIBRARY
SOURCES += \
myclass.cpp
HEADERS += \
common_global.h \
myclass.h
unix {
target.path = /home/debian/lib
INSTALLS += target
}
CONFIG += debug
Project file containing main:
QT += core gui
greaterThan(QT_MAJOR_VERSION, 4): QT += widgets
TARGET = Test
TEMPLATE = app
SOURCES += \
main.cpp
win32:CONFIG(release, debug|release): LIBS += -L$$OUT_PWD/../Common/release/
-lCommon
else:win32:CONFIG(debug, debug|release): LIBS += -
L$$OUT_PWD/../Common/debug/ -lCommon
else:unix: LIBS += -L$$OUT_PWD/../Common/ -lCommon
INCLUDEPATH += $$PWD/../Common
DEPENDPATH += $$PWD/../Common
target.path = /home/debian
INSTALLS += target
Let me know if there's any other relevant data I forgot to provide. Qt Creator version is 4.5.0 and I'm running it on a 64 bit VM of ubuntu 16.04 if that's relevant.
I'm using QT(5)-Creator with 2 projects, that compile both with MinGW my C++ programs under Windows 7. One project generates a static library, and the other is just there to verify that the library is alright.
The error:
When building the library no errors are generated and it creates successfully the static lib MyClassName.a.
In turn, when trying to import the library, I get error messages durring building/compilation:
undefined reference to 'MyClassName::MyClassName()'
undefined reference to 'MyClassName::MyClassFunction()'
The files:
here's the main.cpp of my importer project
#include <QCoreApplication>
#include "MyClassName.h"
int main(int argc, char *argv[])
{
QCoreApplication a(argc, argv);
MyClassName *mainThread = new MyClassName();
mainThread->MyClassFunction();
return a.exec();
}
and it's .pro file
QT += core
QT += widgets
QT -= gui
TARGET = TESTerase
CONFIG += console
CONFIG -= app_bundle
CONFIG +=extserialport
CONFIG +=staticlib
TEMPLATE = app
HEADERS += \
MyClassName.h
SOURCES += main.cpp
unix:!macx: LIBS += -L$$PWD/../MyClassName-Release/ -lMyClassName
INCLUDEPATH += $$PWD
INCLUDEPATH += $$PWD/../MyClassName-Release/release
DEPENDPATH += $$PWD/../MyClassName-Release/release
unix:!macx: PRE_TARGETDEPS += $$PWD/../MyClassName-Release/release/MyClassName.a
btw I've used QT-Creator's include external library function
My guesses:
Since I'm able to [Strg+Click] the functions in the main, I assume the error is thrown by the Linker.
It may also be a manner of importing/creating/using libraries too, since I just started with that topic.
Anyways searching the Internet about it usually just results in the hint, to use the same compiler for both projects - which shouldn't matter in my case (since I'm building both projects with the same Creator and the same settings).
Has anybody an idea?
Thanks for your support
Kind Regards
[Update for Bogdans request]
the new .pro file
#-------------------------------------------------
#
# Project created by QtCreator 2015-04-29T19:46:22
#
#-------------------------------------------------
QT += core
QT += widgets
QT -= gui
TARGET = TESTerase
TEMPLATE = app
CONFIG += console
CONFIG -= app_bundle
CONFIG +=extserialport
HEADERS += \
MyClassName.h
SOURCES += main.cpp
unix:!macx: LIBS += -L$$PWD/../MyClassName-Release/ -lMyClassName
win32:CONFIG(release, debug|release): LIBS += -L$$PWD/../MyClassName-Release/release/ -lMyClassName
else:win32:CONFIG(debug, debug|release): LIBS += -L$$PWD/../MyClassName-Release/debug/ -lMyClassName
else:unix:!macx: LIBS += -L$$PWD/../MyClassName-Release/ -lMyClassName
INCLUDEPATH += $$PWD/../MyClassName-Release/release
DEPENDPATH += $$PWD/../MyClassName-Release/release
win32-g++:CONFIG(release, debug|release): PRE_TARGETDEPS += $$PWD/../MyClassName-Release/release/MyClassName.a
else:win32-g++:CONFIG(debug, debug|release): PRE_TARGETDEPS += $$PWD/../MyClassName-Release/debug/MyClassName.a
else:win32:!win32-g++:CONFIG(release, debug|release): PRE_TARGETDEPS += $$PWD/../MyClassName-Release/release/MyClassName.lib
else:win32:!win32-g++:CONFIG(debug, debug|release): PRE_TARGETDEPS += $$PWD/../MyClassName-Release/debug/MyClassName.lib
else:unix:!macx: PRE_TARGETDEPS += $$PWD/../MyClassName-Release/MyClassName.a
Your .pro file defines library dependencies only for unix platform unix:!macx:. I suppose there should be also win32 for Windows.
Had the same problem just now. Build was working fine on macOS/OSX but not on Windows with the same codebase.
It was caused by the fact I was not exporting my symbols, which is necessary on Windows.
Use Q_DECL_EXPORT on functions when building the lib.
And use Q_DECL_IMPORT when using the functions from the lib.
Example how to do this here: https://wiki.qt.io/How_to_create_a_library_with_Qt_and_use_it_in_an_application#Creating_a_shared_library
Solved the problem in my case, hope it helps!