Menu

#49 Link failure when Qt6 is compiled with visibility protected

v2.x
closed
None
5
2023-07-01
2023-06-17
No

The origin of this breakage can be traced to this work: Remove copy relocation and optimize locally defined symbol access by Thiago, that finally made its way into Qt6. The Arch Linux Qt6 packager used the new build flag FEATURE_no_direct_extern_access=ON when building Qt6 which exposed the build problem on my Drumstick Libraries.

When using FEATURE_no_direct_extern_access=ON, the macro Q_DECL_EXPORT will be defined as __attribute__((visibility("protected"))) in Linux/GCC, potentially breaking existing public shared libraries using this macro.

This ticket comes from GitHub issue #12.

Related

Help Request: #8

Discussion

  • Pedro Lopez-Cabanillas

    CMake has an alternative solution, which has been discarded:

    https://cmake.org/cmake/help/latest/module/GenerateExportHeader.html

    https://cmake.org/cmake/help/latest/prop_tgt/DEFINE_SYMBOL.html

    set(CMAKE_CXX_VISIBILITY_PRESET hidden)
    set(CMAKE_VISIBILITY_INLINES_HIDDEN 1)
    add_library(somelib someclass.cpp)
    generate_export_header(somelib)
    install(TARGETS somelib DESTINATION ${LIBRARY_INSTALL_DIR})
    install(FILES
        someclass.h
        ${PROJECT_BINARY_DIR}/somelib_export.h DESTINATION ${INCLUDE_INSTALL_DIR}
    )
    

    This means that four headers will be generated, and would need to be installed:

    • drumsmtick_alsa_export.h
    • drumsmtick_file_export.h
    • drumsmtick_rt_export.h
    • drumsmtick_widgets_export.h

    This solution will be cross-platform, and contain some other macros as well, but will be disconnected from any future Qt6 advances.

    Using Q_DECL_EXPORT and Q_DECL_IMPORT, whatever new development in Qt6 on this area will be adopted by Drumstick as well when Linux distros migrate.

     
  • Pedro Lopez-Cabanillas

    • status: open --> pending
     
  • Pedro Lopez-Cabanillas

    • Status: pending --> closed
     

Log in to post a comment.