Ulf,

Thanks for your reply. So that you better understand my problem this is what I 
have

shared
        CMakeList.txt

project
        CMakeList.txt
        common
                CMakeList.txt


In order to build project I need shared and common. When in debug I don’t want 
to build shared and common individually for each change so in project 
CMakeList.txt I do this:

if(${CMAKE_BUILD_TYPE} STREQUAL "Debug")
        add_subdirectory(common)
        target_link_libraries(bam PRIVATE shared)
        target_link_libraries(bam PRIVATE common)
endif()

When doing this, all the qml resources are found and the application works as 
expected

In release I just want to link with shared and common so I have something like 
this:

if(${CMAKE_BUILD_TYPE} STREQUAL “Release")
        target_link_libraries(bam PRIVATE libshared.a)
        target_link_libraries(bam PRIVATE libcommon.a)
        target_link_libraries(bam PRIVATE 
-L${CMAKE_CURRENT_SOURCE_DIR}/common/build/lib)
        target_include_directories(bam PRIVATE 
${CMAKE_CURRENT_SOURCE_DIR}/common/build/include)
endif()

The problem is that when linking with libshared.a and libcommon.a the resources 
are not available and when I try to call the function:

Q_INIT_RESOURCE(shared_qml);

It says:

Undefined symbols for architecture arm64:
  "qInitResources_shared_qml()", referenced from:

The function is not available but searching for that function in binaries says:

Binary file shared/libshared.dylib matches

I’m linking (and I want to link) with the static version of this lib and not 
the dynamic one.

I think don’t totally understand your suggestion. My goal is to have a single 
libshared.a that I can link with my project and call the necessary functions to 
register the resources. 

What would be the right solution for this case?

Thanks in advance!

Regards,

Nuno


> On 11 Jan 2023, at 15:43, Ulf Hermann via Interest <interest@qt-project.org> 
> wrote:
> 
> 
>> With the following approach two libs are created:
>> 
>> libshared.a and libsharedplugin.a
>> 
>> I just want to have a single target called libshared.a with all the qml 
>> resources embedded.
> 
> You can add NO_PLUGIN to your qt_add_qml_module, but be warned: The linker 
> will be clever and omit your type registrations. You have to prevent that in 
> some other way then. The usual way to prevent it is Q_IMPORT_PLUGIN on the 
> generated plugin.
> 
> And you should not add your QML files with qt_add_resources. The most 
> important thing qt_add_qml_module does is adding your QML files.
> 
> best regards,
> 
> Ulf
> 
> _______________________________________________
> Interest mailing list
> Interest@qt-project.org
> https://lists.qt-project.org/listinfo/interest

_______________________________________________
Interest mailing list
Interest@qt-project.org
https://lists.qt-project.org/listinfo/interest

Reply via email to