QT+ External Lib Compile in Visual Studio not in QT Creator.
-
Hello All
I am struggling for 3 days now including a library (.lib) file in Qt Creator
The Lib is a Lidar SDK for managing a laser hardware : https://github.com/YDLIDAR/YDLidar-SDKReadme advise visual studio to compile , wich i did sucessfully as a static library.
To use the lib, I create a QT project and link the YLIDAR_SDK
in : visual studio -> fine
in : qt creator -> LNK2019: unresolved externalwith exactly the same source files , lib, headers and links using both msvc2015 or msvc2019
my : .conf
lib : lydlidar_sdk.lib
includesSDK-G2/core
SDK-G2/src
SDK-G2QT += quick CONFIG += c++11 .# 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 += \ lidamemanager.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 win32: LIBS += -L$$PWD/../../VisualStudio/SDK-G2/build/Debug/ -lydlidar_sdk INCLUDEPATH += $$PWD/../../VisualStudio/SDK-G2/core DEPENDPATH += $$PWD/../../VisualStudio/SDK-G2/core INCLUDEPATH += $$PWD/../../VisualStudio/SDK-G2/src DEPENDPATH += $$PWD/../../VisualStudio/SDK-G2/src INCLUDEPATH += $$PWD/../../VisualStudio/SDK-G2 DEPENDPATH += $$PWD/../../VisualStudio/SDK-G2 win32:!win32-g++: PRE_TARGETDEPS += $$PWD/../../VisualStudio/SDK-G2/build/Debug/ydlidar_sdk.lib else:win32-g++: PRE_TARGETDEPS += $$PWD/../../VisualStudio/SDK-G2/build/Debug/libydlidar_sdk.a HEADERS += \ lidamemanager.h
When i compile ( qmake & msvc15 or 19 ) i get and linking issue
ydlidar_sdk.lib(list_ports_win.obj):-1: error: LNK2019: unresolved external symbol __imp_RegQueryValueExA referenced in function "class std::vector<struct ydlidar::core::serial::PortInfo,class std::allocator<struct ydlidar::core::serial::PortInfo> > __cdecl ydlidar::core::serial::list_ports(void)" (?list_ports@serial@core@ydlidar@@YA?AV?$vector@UPortInfo@serial@core@ydlidar@@V?$allocator@UPortInfo@serial@core@ydlidar@@@std@@@std@@XZ)
where
RegQueryValueExA is a function declared in from "winreg.h" and "setupapi.lib" used in a file from the YLIDAR_SDK
i tried quite a lot of stuff unsuccessfuly ....
Compiling the SDK in QT
addind the setupapi.lib in QT
trying MSVC2015 MSVC2019As code compilation works fine in visual studio i am wondering what i am missing in QT
Any suggestions ?
Thanks -
Hi and welcome to devnet,
@Lo-Public-Name said in QT+ External Lib Compile in Visual Studio not in QT Creator.:
RegQueryValueExA
That symbol comes from the Advapi32 library. You need to link to that one.
-
@SGaist said in QT+ External Lib Compile in Visual Studio not in QT Creator.:
Advapi32
THANKS ( in capital letters ) that was it !