Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt Extensions
  • Unsolved
Collapse
Brand Logo
  1. Home
  2. Qt Development
  3. General and Desktop
  4. How to include a COM tlb library in my console project
QtWS25 Last Chance

How to include a COM tlb library in my console project

Scheduled Pinned Locked Moved Unsolved General and Desktop
axcontainerconsolekompas-3d
4 Posts 3 Posters 597 Views
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • T Offline
    T Offline
    timob256
    wrote on 18 Jul 2023, 12:56 last edited by
    #1

    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 ;_;

    J 1 Reply Last reply 18 Jul 2023, 13:01
    0
    • T timob256
      18 Jul 2023, 12:56

      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 ;_;

      J Offline
      J Offline
      jsulm
      Lifetime Qt Champion
      wrote on 18 Jul 2023, 13:01 last edited by
      #2

      @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.

      https://forum.qt.io/topic/113070/qt-code-of-conduct

      T 1 Reply Last reply 18 Jul 2023, 22:44
      0
      • J jsulm
        18 Jul 2023, 13:01

        @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.

        T Offline
        T Offline
        timob256
        wrote on 18 Jul 2023, 22:44 last edited by
        #3

        @jsulm i make this for this exampes https://rutube.ru/video/24093081ddda7718e2759138ace15a57/

        but this not work ;_:

        1 Reply Last reply
        0
        • H Offline
          H Offline
          hskoglund
          wrote on 18 Jul 2023, 23:03 last edited by
          #4

          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.

          1 Reply Last reply
          2

          1/4

          18 Jul 2023, 12:56

          • Login

          • Login or register to search.
          1 out of 4
          • First post
            1/4
            Last post
          0
          • Categories
          • Recent
          • Tags
          • Popular
          • Users
          • Groups
          • Search
          • Get Qt Extensions
          • Unsolved