1

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.

inkfil
  • 31
  • 5
  • The error message tells that your application has no entry point. "If my linker command or cmake script helps, please let me know, I'll link them as well." - Yes, we need to see your **code**, and no, a link to that code is no suitable: the code should be **in the question post** itself, as text. Please, (re-)read [ask] and missed parts of your question. – Tsyvarev Jan 24 '23 at 07:57
  • @Tsyvarev, I've updated the question with link to linking command and Cmake script, I couldn't add these directly as text, since these are quite long, Thanks – inkfil Jan 24 '23 at 08:29
  • Your `CMakeLists.txt` is not so long, paste it to the question post (and format as code). Also, what is about **entry point**? Which your source file defines and how? – Tsyvarev Jan 24 '23 at 09:11
  • question updated as suggested, arigato senpai :) – inkfil Jan 24 '23 at 10:36
  • **Which source file** contains definition of the `main` function? How this file is specified in your `CMakeLists.txt`? We don't know content of your `../files.cmake` script, so we don't know exact value of variables like `COMMON_SOURCE`. This is why on Stack Overflow we expect the code in the question to be in form of [mcve]. Without it you will need to answer tens clarifying questions about your code before we could be able to find the problem in it. – Tsyvarev Jan 24 '23 at 11:43

0 Answers0