Skip to content

Could not load dynamic library such as "fieldFunctionObjects" on macOS

Summary

When one application (use dynamic library) execute, it could not load this library on macOS.

Steps to reproduce

In the directory of "tutorials/incompressible/icoFoam/cavityMappingTest", execute the script of "Allrun".

Example case

% ./Allrun Running blockMesh on /opt/OpenFOAM/OpenFOAM-v1912/tutorials/incompressible/icoFoam/cavityMappingTest Running blockMesh on /opt/OpenFOAM/OpenFOAM-v1912/tutorials/incompressible/icoFoam/cavityMappingTest Running icoFoam on /opt/OpenFOAM/OpenFOAM-v1912/tutorials/incompressible/icoFoam/cavityMappingTest

What is the current bug behaviour?

In the file of "log.icoFoam", there is the following message.

--> FOAM Warning : From function void *Foam::dlLibraryTable::openLibrary(const Foam::fileName &, bool) in file db/dynamicLibrary/dlLibraryTable/dlLibraryTable.C at line 65 Could not load "fieldFunctionObjects" dlopen(libfieldFunctionObjects.dylib, 9): image not found

What is the expected correct behavior?

There is no warning.

Relevant logs and/or images

Environment information

  • OpenFOAM version : v1912
  • Operating system : macOS 10.15.4
  • Hardware info : MacBook Pro
  • Compiler : Apple clang version 11.0.3 (clang-1103.0.32.29)

Possible fixes

When SPI(System Integrity Protection) is enabled, we can not use the environment value of DYLD_LIBRARY_PATH. So another environment value is introduced and it used before call dlopen(). it is patch for this.

dl-search-paths.patch