How to include a COM tlb library in my console project
Unsolved
General and Desktop
-
CMakeList.txt
cmake_minimum_required(VERSION 3.14) project(compas_com_example LANGUAGES CXX) set(CMAKE_AUTOUIC ON) set(CMAKE_AUTOMOC ON) set(CMAKE_AUTORCC ON) set(CMAKE_CXX_STANDARD 17) set(CMAKE_CXX_STANDARD_REQUIRED ON) find_package(QT NAMES Qt6 Qt5 REQUIRED COMPONENTS Core) find_package(Qt${QT_VERSION_MAJOR} REQUIRED COMPONENTS Core) find_package(Qt5AxContainer REQUIRED) include_directories( ${Qt5AxContainer_INCLUDE_DIRS} ) add_definitions(${Qt5AxContainer_DEFINITIONS}) add_executable(compas_com_example main.cpp ) include_directories(${Qt5Widgets_INCLUDES} ${Qt5AxContainer_INCLUDE_DIRS}) target_link_libraries(${PROJECT_NAME} ${Qt5AxContainer_LIBRARIES}) target_link_libraries(compas_com_example Qt${QT_VERSION_MAJOR}::Core) install(TARGETS compas_com_example LIBRARY DESTINATION ${CMAKE_INSTALL_LIBDIR} RUNTIME DESTINATION ${CMAKE_INSTALL_BINDIR} )
main.cpp
#include <QCoreApplication> #include "C:\Program Files\ASCON\KOMPAS-3D v20\Bin\kAPI5.tlb" int main(int argc, char *argv[]) { QCoreApplication a(argc, argv); return a.exec(); }
compas_com_example\main.cpp:2: error: In included file: unknown type name 'MSFT'
why error ;_;
-
@timob256 said in How to include a COM tlb library in my console project:
kAPI5.tlb
What is this? Doesn't look like a proper C/C++ header file.
-
Hi, .tlb-files cannot be added to your project via an #include.
One way is to use Qt's dumpcpp utility, for example:
C:\Qt\5.15.2\msvc2019\bin\dumpcpp C:\Program Files\ASCON\KOMPAS-3D v20\Bin\kAPI5.tlb"
then with a bit of luck you'll have 2 new files: kAPI5.h and kAPI5.cpp, Add these files to your project. And then try #include the kAPI5.h file in your main.cpp.