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?
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
SITUATION
I tried to create a dll for my project, but idk what am i doing wrong.
1 Step : Create a shared Lib
I went to create new project ->
library ->
c++ library ->
added some test method that returns a const int ->
built Realse and Debug versions
2 Step : Add lib to my project
what i did is : right click on my 'real' project ->
clicked on add Library ->
clicked on 'external library' option ->
in 'library path' section browsed to my .so file ->
Qt added auto-generated code to my .pro file
PROBLEM
i can NOT access to my header in my library.
here is my main.cpp
#include <QGuiApplication>
#include <QQmlApplicationEngine>
#include "StickyNotesCore.h" // <- says error: file not found
int main(int argc, char *argv[])
{
QCoreApplication::setAttribute(Qt::AA_EnableHighDpiScaling);
QGuiApplication app(argc, argv);
QQmlApplicationEngine engine;
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);
return app.exec();
}
my stickynotescore.h
#ifndef STICKYNOTESCORE_H
#define STICKYNOTESCORE_H
#include "stickynotescore_global.h"
class STICKYNOTESCORESHARED_EXPORT StickyNotesCore
{
public:
StickyNotesCore();
int Test();
};
#endif // STICKYNOTESCORE_H
my StickyNotes.pro
QT += quick
CONFIG += c++11
# 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). Refer to the documentation for the
# deprecated API 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
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 =
QT_QUICK_CONTROLS_STYLE=material ./app
# 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/../build-StickyNotesCore-Desktop_Qt_5_13_0_GCC_64bit-Debug/release/ -lStickyNotesCore
else:win32:CONFIG(debug, debug|release): LIBS += -L$$PWD/../build-StickyNotesCore-Desktop_Qt_5_13_0_GCC_64bit-Debug/debug/ -lStickyNotesCore
else:unix: LIBS += -L$$PWD/../build-StickyNotesCore-Desktop_Qt_5_13_0_GCC_64bit-Debug/ -lStickyNotesCore
INCLUDEPATH += $$PWD/../build-StickyNotesCore-Desktop_Qt_5_13_0_GCC_64bit-Debug
DEPENDPATH += $$PWD/../build-StickyNotesCore-Desktop_Qt_5_13_0_GCC_64bit-Debug
EDIT
Folder tree
For your .pro file replace INCLUDEPATH ad DEPENDEPATH to the path where the .h files for your library is located.
make sure to run qmake after make the changes.
INCLUDEPATH += $$PWD/../build-StickyNotesCore-Desktop_Qt_5_13_0_GCC_64bit-Debug
DEPENDPATH += $$PWD/../build-StickyNotesCore-Desktop_Qt_5_13_0_GCC_64bit-Debug
Here is an example of what i on my .pro file.
win32:CONFIG(release, debug|release): LIBS += -L$$PWD/../../../../../mylibrary/lib/vc140/x64/ -lMYLIBRARY
else:win32:CONFIG(debug, debug|release): LIBS += -L$$PWD/../../../../../mylibrary/lib/vc140/x64/ -lMYLIBRARYd
else:unix: LIBS += -L$$PWD/../../../../../mylibrary/lib/vc140/Win32/ -lMYLIBRARY
INCLUDEPATH += $$PWD/../../../../../mylibrary/include
DEPENDPATH += $$PWD/../../../../../mylibrary/include
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.
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'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!