How to call BMDSwitcherAPI in a Qt project?

Ask software engineering and SDK questions for developers working on Mac OS X, Windows or Linux.
  • Author
  • Message
Offline

fmjsky

  • Posts: 3
  • Joined: Fri Mar 19, 2021 2:37 pm
  • Real Name: Mengjun Fang

How to call BMDSwitcherAPI in a Qt project?

PostThu Mar 25, 2021 5:27 am

Dear software engineer
I am not a software developer. I taught myself a little about Qt programming.
I want to use Qt to write an ATEM control program that contains special functions (triggering other hardware device functions).

Platform:Windows 10
Qt Version:Qt5.9.9
However, I don't know how to call API in Qt.
I haved use dumpcpp to create “bmdswitcherapi.h” and “bmdswitchapi.cpp”. but it does't work.

Platform:mac os 10.14.6
Qt Version:Qt5.9.9
Xcode:10.3
error:
symbol(s) not found for architecture x86_64
linker command failed with exit code 1(use -v to see invocation)

best regards
Offline

Cameron Nichols

Blackmagic Design

  • Posts: 442
  • Joined: Mon Sep 04, 2017 4:05 am

Re: How to call BMDSwitcherAPI in a Qt project?

PostFri Mar 26, 2021 2:48 am

Hi,

You need to first invoke midl compiler on BMDSwitcherAPI.idl to generate necessary headers/sources. You should add the following to your .pro file:
Code: Select all
win32 {
        MIDL_FILES = "../../include/BMDSwitcherAPI.idl"

        MIDL.name = Compiling IDL
        MIDL.input = MIDL_FILES
        MIDL.output = ${QMAKE_FILE_BASE}.h
        MIDL.variable_out = HEADERS
        MIDL_CONFIG += no_link
        contains(QMAKE_TARGET.arch, x86_64)   {
                MIDL.commands = midl.exe /env win64 /h ${QMAKE_FILE_BASE}.h /W1 /char signed /D "NDEBUG" /robust /nologo ${QMAKE_FILE_IN}
        } else {
                MIDL.commands = midl.exe /env win32 /h ${QMAKE_FILE_BASE}.h /W1 /char signed /D "NDEBUG" /robust /nologo ${QMAKE_FILE_IN}
        }
        QMAKE_EXTRA_COMPILERS += MIDL
}

Here I am assuming that your .pro is is a folder under Window/Samples path, you should adjust the MIDL_FILES path if required. Please remember to also add this to your include path:
Code: Select all
INCLUDEPATH += ../../include

On the macOS question, ensure that you are adding BMDSwitcherAPIDispatch.cpp to your sources:
Code: Select all
macx:SOURCES += ../../include/BMDSwitcherAPIDispatch.cpp

Regards
Cameron
Offline

fmjsky

  • Posts: 3
  • Joined: Fri Mar 19, 2021 2:37 pm
  • Real Name: Mengjun Fang

Re: How to call BMDSwitcherAPI in a Qt project?

PostFri Mar 26, 2021 1:58 pm

Dear Cameron Nichols

According to the methods that you provided,I had do some test. but it still does't work.

MAC OS:
Image

WIN10:
there is no Headfile be generated.

Image

Image

Image





Cameron Nichols wrote:Hi,

You need to first invoke midl compiler on BMDSwitcherAPI.idl to generate necessary headers/sources. You should add the following to your .pro file:
Code: Select all
win32 {
        MIDL_FILES = "../../include/BMDSwitcherAPI.idl"

        MIDL.name = Compiling IDL
        MIDL.input = MIDL_FILES
        MIDL.output = ${QMAKE_FILE_BASE}.h
        MIDL.variable_out = HEADERS
        MIDL_CONFIG += no_link
        contains(QMAKE_TARGET.arch, x86_64)   {
                MIDL.commands = midl.exe /env win64 /h ${QMAKE_FILE_BASE}.h /W1 /char signed /D "NDEBUG" /robust /nologo ${QMAKE_FILE_IN}
        } else {
                MIDL.commands = midl.exe /env win32 /h ${QMAKE_FILE_BASE}.h /W1 /char signed /D "NDEBUG" /robust /nologo ${QMAKE_FILE_IN}
        }
        QMAKE_EXTRA_COMPILERS += MIDL
}

Here I am assuming that your .pro is is a folder under Window/Samples path, you should adjust the MIDL_FILES path if required. Please remember to also add this to your include path:
Code: Select all
INCLUDEPATH += ../../include

On the macOS question, ensure that you are adding BMDSwitcherAPIDispatch.cpp to your sources:
Code: Select all
macx:SOURCES += ../../include/BMDSwitcherAPIDispatch.cpp

Regards
Cameron
Offline

fmjsky

  • Posts: 3
  • Joined: Fri Mar 19, 2021 2:37 pm
  • Real Name: Mengjun Fang

Re: How to call BMDSwitcherAPI in a Qt project?

PostFri Mar 26, 2021 2:47 pm

MACOS:
MAC1.png
MAC1.png (206.82 KiB) Viewed 3227 times


WIN10:
WIN1.png
WIN1.png (72.83 KiB) Viewed 3227 times

WIN3.png
WIN3.png (6.4 KiB) Viewed 3227 times
Offline

jhankins

  • Posts: 3
  • Joined: Wed Jan 27, 2021 6:39 pm
  • Location: Chesterfield, Michigan
  • Real Name: Jim Hankins

Re: How to call BMDSwitcherAPI in a Qt project?

PostTue Oct 19, 2021 1:46 pm

Did you ever get this working?
Jim Hankins
Founder / CEO
Cloud Bedrock, LLC
https://cloudbedrock.com
Offline

mseifert

  • Posts: 1
  • Joined: Wed Oct 27, 2021 11:23 pm
  • Real Name: Matej Seifert

Re: How to call BMDSwitcherAPI in a Qt project?

PostWed Oct 27, 2021 11:34 pm

Hi,

I am falling in the same problem. For the first time I work with IDL files. I thoug C++ doesn't need IDL file compilation so I learned C++ and Qt framework in last 2 months to work with your API and it doesn't work. I prefer CMake but I tried both variants. Here are my examples of configs.

*.pro for qmake
Code: Select all
QT -= gui

INCLUDEPATH += include


win32 {
        MIDL_FILES = "include/BMDSwitcherAPI.idl"

        MIDL.name = Compiling IDL
        MIDL.input = MIDL_FILES
        MIDL.output = ${QMAKE_FILE_BASE}.h
        MIDL.variable_out = HEADERS
        MIDL_CONFIG += no_link
        contains(QMAKE_TARGET.arch, x86_64)   {
                MIDL.commands = midl.exe /env win64 /h ${QMAKE_FILE_BASE}.h /W1 /char signed /D "NDEBUG" /robust /nologo ${QMAKE_FILE_IN}
        } else {
                MIDL.commands = midl.exe /env win32 /h ${QMAKE_FILE_BASE}.h /W1 /char signed /D "NDEBUG" /robust /nologo ${QMAKE_FILE_IN}
        }
        QMAKE_EXTRA_COMPILERS += MIDL
}

CONFIG += c++11 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

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




CMake:

Code: Select all
cmake_minimum_required(VERSION 3.14)

project(stream-controll-desktop-client LANGUAGES CXX)

set(CMAKE_INCLUDE_CURRENT_DIR ON)


set(CMAKE_AUTOUIC ON)
set(CMAKE_AUTOMOC ON)
set(CMAKE_AUTORCC ON)

set(CMAKE_CXX_STANDARD 11)
set(CMAKE_CXX_STANDARD_REQUIRED ON)



find_package(QT NAMES Qt6 Qt5 COMPONENTS Core REQUIRED)
find_package(Qt${QT_VERSION_MAJOR} COMPONENTS Core REQUIRED)



add_executable(stream-controll-desktop-client
  main.cpp
)

target_link_libraries(stream-controll-desktop-client Qt${QT_VERSION_MAJOR}::Core)


set(MIDL_OUTPUT
    ${CMAKE_CURRENT_BINARY_DIR}/BMDSwitcherAPI.h
    )
set(MIDL_FILE
    ${CMAKE_CURRENT_LIST_DIR}/BMDSwitcherAPI.idl
    )
add_custom_command(
    OUTPUT ${MIDL_OUTPUT}
    COMMAND midl /h BMDSwitcherAPI.h ${MIDL_FILE}
    WORKING_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR}
    DEPENDS ${MIDL_FILE}
    VERBATIM
    )


target_sources(${PROJECT_NAME} PRIVATE ${MIDL_FILE} ${MIDL_OUTPUT})



These two applications are just generated new console apps by Qt Creator. I am not Cmake nor qmake expert. *.pro file is compileable, but nothing is generated. CMake is not compileable.

Any advice, how to setup MIDL correctly? For qmake I followed this topic, for CMake I followed https://stackoverflow.com/questions/468 ... from-cmake

Anyone any ideas? Thank you, Matej S.

Return to Software Developers

Who is online

Users browsing this forum: No registered users and 3 guests