inkfil
inkfil

Reputation: 21

linking issues in QT. 6.2.4 for missing entrypoint "_main"

I'm trying to build an iOS application using QT6.4.2 and Cmake, I'm getting following linking error

Undefined symbols for architecture arm64:
  "_main", referenced from:
      user_main_trampoline() in libqios_debug.a(qioseventdispatcher.mm.o)
     (maybe you meant: _jinit_d_main_controller, _jinit_c_main_controller , _qt_main_wrapper )
ld: symbol(s) not found for architecture arm64
clang: error: linker command failed with exit code 1 (use -v to see invocation)

this is m list of installed libs list of all libs and modules installed in QT 6.2.4

My main entry point looks like this

int main(int argc, char *argv[]) {
    QApplication app(argc, argv);
    // ...
    return app.exec();
}

following is my cmake script


set(TARGET_NAME Focus)
set(CMAKE_SUPPRESS_REGENERATION true)
include(../cute.cmake)
include(../files.cmake)
 
cute_add_executable(${TARGET_NAME})
target_sources(${TARGET_NAME} 
    PRIVATE
    ${FOCUS_HEADER}
    ${OBJECTIVE_HEADER}
    ${COMMON_HEADER}
    ${FOCUS_SOURCE}
    ${OBJECTIVE_SOURCE}
    ${COMMON_SOURCE}
    ${QUICK_IOS_SOURCE}
    ${FOCUS_QML_SOURCE}
    ${QUICK_IOS_QML_SOURCE}
    ${QRC_FILES}
    ${QT_QML_PLUGIN_CPP}
)
 
find_package(Qt${QT_VERSION_MAJOR} COMPONENTS Core OpenGL Concurrent Widgets Multimedia Network Sql Qml Quick QuickWidgets Svg WebView QuickControls2 Core5Compat REQUIRED)
 
# set(CMAKE_EXE_LINKER_FLAGS ${CMAKE_EXE_LINKER_FLAGS} "-Wl,-e,_qt_main_wrapper")
# set(CMAKE_EXE_LINKER_FLAGS ${CMAKE_EXE_LINKER_FLAGS} "-u _qt_registerPlatformPlugin")
 
target_link_libraries(${TARGET_NAME} 
    PRIVATE
    #MySharedLibrary
    Qt${QT_VERSION_MAJOR}::Core
    Qt${QT_VERSION_MAJOR}::Concurrent
    Qt${QT_VERSION_MAJOR}::Network
    Qt${QT_VERSION_MAJOR}::Qml
    Qt${QT_VERSION_MAJOR}::Quick
    Qt${QT_VERSION_MAJOR}::Core
    Qt${QT_VERSION_MAJOR}::OpenGL
    Qt${QT_VERSION_MAJOR}::Multimedia
    Qt${QT_VERSION_MAJOR}::Network
    Qt${QT_VERSION_MAJOR}::Sql
    Qt${QT_VERSION_MAJOR}::Qml
    Qt${QT_VERSION_MAJOR}::Quick
    Qt${QT_VERSION_MAJOR}::QuickControls2
    Qt${QT_VERSION_MAJOR}::QuickWidgets
    Qt${QT_VERSION_MAJOR}::Svg
    Qt${QT_VERSION_MAJOR}::WebView
    Qt${QT_VERSION_MAJOR}::Core5Compat
)
 
if (${QT_VERSION_MAJOR} EQUAL 6)
    qt6_import_qml_plugins(${TARGET_NAME})
endif ()
 
file(GLOB LOCAL_LIB_FILES "${CMAKE_SOURCE_DIR}/lib/ios/*.a")
message("CMAKE_SOURCE_DIR  : " ${CMAKE_SOURCE_DIR})
 
target_link_libraries(${TARGET_NAME} 
    PRIVATE
    ${LOCAL_LIB_FILES}
)
 

Any guidance/help is appreciated.

I've already gone through following posts from QT community and SO but no luck, https://forum.qt.io/topic/136707/undefined-symbols-_main-when-building-a-shared-lib-on-ios-with-qt-statemachine

https://forum.qt.io/topic/80775/main-function-required-when-compiling-shared-library-for-ios

QT IOS linker error entry point (_main) undefined

LINKER COMMAND: https://pastebin.com/CdARmarQ CMAKE SCRIPT: https://pastebin.com/xXnCUKC6

NOTE: I've used https://github.com/cuteserver/hello-world as my toolchain and qt configuration for iOS.

Upvotes: 1

Views: 358

Answers (0)

Related Questions