Using a dictionary without gSystem->Load, Mac OS version

Hi @Danilo! I thought I was doing all three of those things, but it turns out that I wasn’t on Mac OS X. On Linux, the .pcm file was being created. On Mac OS X, it was not!

Here are the details.

On the Linux side, these are the CMakeLists.txt lines in the dictionary directory:

file(GLOB headerList ${CMAKE_CURRENT_SOURCE_DIR}/include/*.h)
file(GLOB DataObjSrc ${CMAKE_CURRENT_SOURCE_DIR}/src/*.cc )

set(LinkDef ${CMAKE_CURRENT_SOURCE_DIR}/include/LinkDef.hh)
set(Dictionary ${CMAKE_CURRENT_BINARY_DIR}/DataObjDict)
set(LibName ${CMAKE_PROJECT_NAME}DataObj)

ROOT_GENERATE_DICTIONARY ( ${Dictionary} ${headerList} LINKDEF ${LinkDef} )

add_library (${LibName} SHARED ${Dictionary}.cxx ${DataObjSrc})
target_include_directories (${LibName} PUBLIC ${CMAKE_CURRENT_SOURCE_DIR}/include)

This works in Linux (up to the minor build-order issue I reported earlier).

In Mac OS X, the above lines don’t work. When I try to build the project, I got an error:

Undefined symbols for architecture arm64:
  "Fatal(char const*, char const*, ...)", referenced from:
      ROOT::Detail::TCollectionProxyInfo::Iterators<std::__1::vector<int, std::__1::allocator<int>>, false>::next(void*, void const*) in DataObjDict.cxx.o

followed by many more “referenced from” lines.

I did my due diligence to track this down, and finally found this topic in which @pcanal was able to solve a similar problem. Following the recipe in that post, I changed some CMakeLists.txt lines on Mac OS X:

The key lines on Linux:

ROOT_GENERATE_DICTIONARY ( ${Dictionary} ${headerList} LINKDEF ${LinkDef} )
add_library (${LibName} SHARED ${Dictionary}.cxx ${DataObjSrc})

The revised lines on Mac OS X:

ROOT_GENERATE_DICTIONARY ( ${Dictionary} ${headerList}
                         MODULE ${LibName}
                         LINKDEF ${LinkDef} )
add_library (${LibName} SHARED ${DataObjSrc})

In other words, to get the code to compile and link on Mac OS X, I had to add MODULE ${LibName} to ROOT_GENERATE_DICTIONARY; then I had to remove ${Dictionary}.cxx from the shared library dependencies; otherwise I got the error:

make[2]: *** No rule to make target `GramsDataObj/MODULE', needed by `GramsDataObj/DataObjDict.cxx'.  Stop.

But the above lines don’t generate the .pcm file (when I tried, they don’t generate it on Linux either). As a result, I get the same issue I reported before: When the program executes, it can’t find the dictionary.

Can you spot what I’m missing?