qt - polyhedron viewer showing nothing - c++

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?

Related

Building gRPC with windows 10 and QT creator - C++

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

How to resolve link error in Qt using Telegram library (Td)

I have encountered with link error while building example app, this one (https://github.com/tdlib/td/blob/master/example/cpp/td_example.cpp) I created project in Qt creator and added td_example.cpp to project. Also previously I have build 32x Td library from sources using this instruction https://tdlib.github.io/td/build.html?language=C%2B%2B .
Td artifacts located in this path K:\QtProjects\Telegram\TelegramDependency\td\tdlib ,
here is located 3 folders (bin, include and lib).
in bin folder located 4 .dll files (libcrypto-1_1.dll, libssl-1_1.dll, tdjson.dll, zlibd1.dll)
in lib folder located (tdactor.lib, tdapi.lib, tdclient.lib, tdcore.lib, tddb.lib, tdjson.lib, tdjson_private.lib, tdjson_static.lib, tdnet.lib, tdsqlite.lib, tdutils.lib)
My project located under this path K:\QtProjects\Telegram\TelegramTestAPP
in folder TelegramTestAPP i have .pro file with such content.
QT += quick
CONFIG += c++20
# 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 += \
Logger.cpp \
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
HEADERS += \
Logger.h \
td_example.h
win32: LIBS += -L'$$PWD/../TelegramDependency/td/tdlib/lib/' -ltdjson
INCLUDEPATH += $$PWD/../TelegramDependency/td/tdlib/include
DEPENDPATH += $$PWD/../TelegramDependency/td/tdlib/include
i removed main function from td_example.cpp and renamed to td_example.h , after that I included this header file and called it from main.cpp inside main function
#include <QGuiApplication>
#include <QQmlApplicationEngine>
#include <QQmlContext>
#include "td_example.h"
int main(int argc, char *argv[])
{
#if QT_VERSION < QT_VERSION_CHECK(6, 0, 0)
QCoreApplication::setAttribute(Qt::AA_EnableHighDpiScaling);
#endif
QGuiApplication app(argc, argv);
QQmlApplicationEngine engine;
engine.rootContext()->setContextProperty(QStringLiteral("CLogger"), &Logger::GetInstance());
const QUrl url(QStringLiteral("qrc:/main.qml"));
QObject::connect(&engine, &QQmlApplicationEngine::objectCreated,
&app, [url](QObject *obj, const QUrl &objUrl) {
if (!obj && url == objUrl)
QCoreApplication::exit(-1);
}, Qt::QueuedConnection);
engine.load(url);
TdExample example;
example.loop();
return app.exec();
}
So the question is, why i get link error
example of error
main.obj:-1: error: LNK2019: unresolved external symbol "public: __thiscall td::td_api::tdlibParameters::tdlibParameters(void)" (??0tdlibParameters#td_api#td##QAE#XZ) referenced in function "class td::tl::unique_ptr<class td::td_api::tdlibParameters> __cdecl td::td_api::make_object<class td::td_api::tdlibParameters>(void)" (??$make_object#VtdlibParameters#td_api#td##$$V#td_api#td##YA?AV?$unique_ptr#VtdlibParameters#td_api#td###tl#1#XZ)
compiler: Microsoft Visual C++ Complier 14.0 (amd64_x86)
I also copied all .dll from bin folder to debug folder (TelegramTestAPP/build/debug)
EDIT
Added all static libraries to .pro file
win32: LIBS += -L'$$PWD/../TelegramDependency/td/tdlib/lib/' -ltdapi
win32: LIBS += -L'$$PWD/../TelegramDependency/td/tdlib/lib/' -ltdutils
win32: LIBS += -L'$$PWD/../TelegramDependency/td/tdlib/lib/' -ltdclient
win32: LIBS += -L'$$PWD/../TelegramDependency/td/tdlib/lib/' -ltdnet
win32: LIBS += -L'$$PWD/../TelegramDependency/td/tdlib/lib/' -ltdcore
win32: LIBS += -L'$$PWD/../TelegramDependency/td/tdlib/lib/' -ltdsqlite
win32: LIBS += -L'$$PWD/../TelegramDependency/td/tdlib/lib/' -ltdactor
win32: LIBS += -L'$$PWD/../TelegramDependency/td/tdlib/lib/' -ltddb
INCLUDEPATH += $$PWD/../TelegramDependency/td/tdlib/include
DEPENDPATH += $$PWD/../TelegramDependency/td/tdlib/include
win32: PRE_TARGETDEPS += $$PWD/../TelegramDependency/td/tdlib/lib/tdcore.lib
win32: PRE_TARGETDEPS += $$PWD/../TelegramDependency/td/tdlib/lib/tdapi.lib
win32: PRE_TARGETDEPS += $$PWD/../TelegramDependency/td/tdlib/lib/tdclient.lib
win32: PRE_TARGETDEPS += $$PWD/../TelegramDependency/td/tdlib/lib/tdutils.lib
win32: PRE_TARGETDEPS += $$PWD/../TelegramDependency/td/tdlib/lib/tdactor.lib
win32: PRE_TARGETDEPS += $$PWD/../TelegramDependency/td/tdlib/lib/tddb.lib
win32: PRE_TARGETDEPS += $$PWD/../TelegramDependency/td/tdlib/lib/tdnet.lib
win32: PRE_TARGETDEPS += $$PWD/../TelegramDependency/td/tdlib/lib/tdsqlite.lib
win32: LIBS += -L'C:/Program Files (x86)/OpenSSL-Win32/lib/VC/' -llibcrypto32MDd
win32: LIBS += -L'C:/Program Files (x86)/OpenSSL-Win32/lib/VC/' -llibssl32MDd
INCLUDEPATH += 'C:/Program Files (x86)/OpenSSL-Win32/include'
DEPENDPATH += 'C:/Program Files (x86)/OpenSSL-Win32/include'
new Errors (compiler gcc 32 bit)
error: undefined reference to `td::ClientManager::execute(td::tl::unique_ptr<td::td_api::Function>&&)'
debug/TdController.o: In function `ZN12TdControllerC2Ev':
error: undefined reference to `td::td_api::setLogVerbosityLevel::setLogVerbosityLevel(int)'
debug/TdController.o: In function `ZN2td6td_api11make_objectINS0_20setLogVerbosityLevelEJiEEENS_2tl10unique_ptrIT_EEDpOT0_':
error: undefined reference to `vtable for td::td_api::setLogVerbosityLevel'
debug/TdController.o: In function `ZN2td6td_api20setLogVerbosityLevel
D1Ev':
I don't know those libs, but according to this https://core.telegram.org/tdlib/docs/classtd_1_1td__api_1_1tdlib_parameters-members.html the symbol you are missing is from td_api, which is not linked it seems. Did you try to link to other libs, in particular tdapi.lib?

Can't use OSG with GDAL on Windows

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.

undefined reference to own library function

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!

"cannot find -lQt5Core -lQt5Gui etc" when using other not related libraries

ISSUE SOLVED (scroll down)
Im on windows 7 and compilling with MinGW.
I made a new Qt application in QtCreator 3.01 (Qt 5.2.1). I compile it, the empty application window pops up everything is awesome. But as soon as i use any other library (like boost or gtest) im starting getting these errors when compiling
cannot find -lqtmain
cannot find -lQt5Widgets
cannot find -lQt5Gui
cannot find -lQt5Core
ld returned 1 exit status
This is my .pro file
#-------------------------------------------------
#
# Project created by QtCreator 2014-04-19T14:17:24
#
#-------------------------------------------------
QT += core gui
greaterThan(QT_MAJOR_VERSION, 4): QT += widgets
TARGET = Thermovision
TEMPLATE = app
include(Model/Model.pri)
include(Controller/Controller.pri)
include(View/View.pri)
include(Interface/Interface.pri)
SOURCES += \
main.cpp
HEADERS += \
logdebug.h
FORMS +=
OTHER_FILES += \
Model/Model.pri \
View/View.pri \
Controller/Controller.pri \
Interface/Interface.pri \
Globals/zGlobals.pri
INCLUDEPATH += $$PWD/
DEPENDPATH += $$PWD/
INCLUDEPATH += $$PWD/../../../../../../../MinGW/msys/1.0/local/include
DEPENDPATH += $$PWD/../../../../../../../MinGW/msys/1.0/local/include
win32:CONFIG(release, debug|release): LIBS += -L$$PWD/../../../../../Downloads/boost_1_54_0/boost_1_54_0/stage/lib/ -lboost_thread-mgw48-mt-1_54
else:win32:CONFIG(debug, debug|release): LIBS += -L$$PWD/../../../../../Downloads/boost_1_54_0/boost_1_54_0/stage/lib/ -lboost_thread-mgw48-mt-1_54d
this is the main.cpp
#include <iostream>
#include <QApplication>
#include "View/form.h"
#include <boost/thread.hpp>
using namespace std;
int main(int argc, char *argv[])
{
QApplication a(argc, argv);
Form w;
w.show();
boost::thread b;
return a.exec();
}
when i comment usage of boost thread, the include and the part in .pro file responsible for finding boost thread library everything compiles again. Same when im trying to use gtest.
The odd thing is that I havent found any information regarding this issue anywhere on the internet :<
Can someone help me?
=================================================================================
[SOLVED]
ok so it seems qt wanted me to explicitly add the libraries into project. I used the built-in tool which generated the following output
win32-g++:CONFIG(release, debug|release): PRE_TARGETDEPS += $$PWD/../../../../../../../Qt/Qt5.2.1/5.2.1/mingw48_32/lib/libQt5Core.a
else:win32-g++:CONFIG(debug, debug|release): PRE_TARGETDEPS += $$PWD/../../../../../../../Qt/Qt5.2.1/5.2.1/mingw48_32/lib/libQt5Cored.a
else:win32:!win32-g++:CONFIG(release, debug|release): PRE_TARGETDEPS += $$PWD/../../../../../../../Qt/Qt5.2.1/5.2.1/mingw48_32/lib/Qt5Core.lib
else:win32:!win32-g++:CONFIG(debug, debug|release): PRE_TARGETDEPS += $$PWD/../../../../../../../Qt/Qt5.2.1/5.2.1/mingw48_32/lib/Qt5Cored.lib
but im sure one can thin it down (im gonna stay with this)
Based on our comments and outcome, it seems that a quick solution is to add the libraries explicitly that you wish to use. It will generate something like this in the background, so basically using static libraries as opposed to dynamic:
win32-g++:CONFIG(release, debug|release): PRE_TARGETDEPS += $$PWD/../../../../../../../Qt/Qt5.2.1/5.2.1/mingw48_32/lib/libQt5Core.a
else:win32-g++:CONFIG(debug, debug|release): PRE_TARGETDEPS += $$PWD/../../../../../../../Qt/Qt5.2.1/5.2.1/mingw48_32/lib/libQt5Cored.a
else:win32:!win32-g++:CONFIG(release, debug|release): PRE_TARGETDEPS += $$PWD/../../../../../../../Qt/Qt5.2.1/5.2.1/mingw48_32/lib/Qt5Core.lib
else:win32:!win32-g++:CONFIG(debug, debug|release): PRE_TARGETDEPS += $$PWD/../../../../../../../Qt/Qt5.2.1/5.2.1/mingw48_32/lib/Qt5Cored.lib
Alternatively, which I would personally suggest more is to add the following line for now in your project file to get this working with dynamic libraries rather than static to make your application binary go up to the hill:
LIBS += -L$$PWD/../../../../../../../Qt/Qt5.2.1/5.2.1/mingw48_32/lib/