Skip to content

Issue with ctLoad on MacOS #2030

@santoshshanbhogue

Description

@santoshshanbhogue

Problem description
The experimental MATLAB toolbox has a few fixable bugs, that as of now lead to Cantera being installed incorrectly. The fix on my machine is to run the following commands before ctLoad

clibConfiguration('ctMatlab','ExecutionMode','inprocess')

(ctBuildInterface claims to do this, but it ends up not being the case)

Steps to reproduce

Run the following commands in the MATLAB editor:

ctSourceRoot = '/Users/santosh1/packages/canteraSource';
ctInstalledDir = '/Users/santosh1/packages/ct_dev_version/';

ctToolboxDir = fullfile(ctSourceRoot, "interfaces/matlab_experimental");

ctCLibIncludeDir = fullfile(ctInstalledDir,"include");
ctLibDir = fullfile(ctInstalledDir, "lib");

clc;
ctBuildInterface(ctToolboxDir, ctCLibIncludeDir, ctLibDir);

Paths used in the build process:
Cantera Toolbox Root: /Users/santosh1/packages/canteraSource/interfaces/matlab_experimental
Include Directory: /Users/santosh1/packages/ct_dev_version/include
Cantera Library: /Users/santosh1/packages/ct_dev_version/lib
Output Folder: /Users/santosh1/packages/canteraSource/interfaces/matlab_experimental/cantera
MEX configured to use 'Xcode Clang++' for C++ language compilation.
C++ compiler set to 'Xcode Clang++'.
Definition file definectMatlab.m contains definitions for 428 constructs supported by MATLAB.

  • 324 constructs are fully defined.
  • 104 constructs partially defined and commented out.

To include the 104 undefined constructs in the interface, uncomment and complete the definitions in definectMatlab.m.
To build the interface, call build(definectMatlab).
Building interface file 'ctMatlabInterface.dylib' for clib interface 'ctMatlab'.
Build Log:
/usr/bin/xcrun -sdk macosx26.0 clang++ -c -fno-common -arch arm64 -mmacosx-version-min=12.0 -fexceptions -isysroot /Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX26.0.sdk -fwrapv -ffp-contract=off -fobjc-arc -std=c++14 -stdlib=libc++ -O2 -DNDEBUG -I"/Users/santosh1/packages/ct_dev_version/include" -I"/Applications/MATLAB_R2024b.app/extern/include" "/Users/santosh1/packages/canteraSource/interfaces/matlab_experimental/cantera/ctMatlab/ctMatlabInterface.cpp" -o "/Users/santosh1/packages/canteraSource/interfaces/matlab_experimental/cantera/ctMatlab/ctMatlabInterface.o"

/usr/bin/xcrun -sdk macosx26.0 clang++ -Wl,-twolevel_namespace -arch arm64 -mmacosx-version-min=12.0 -Wl,-syslibroot,/Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX26.0.sdk -framework Cocoa -bundle -stdlib=libc++ "/Users/santosh1/packages/canteraSource/interfaces/matlab_experimental/cantera/ctMatlab/ctMatlabInterface.o" "/Users/santosh1/packages/ct_dev_version/lib/libcantera_shared.3.2.0.dylib" "/Applications/MATLAB_R2024b.app/extern/bin/maca64/libMatlabDataArray.dylib" -Wl,-rpath,@loader_path/ -O -o "/Users/santosh1/packages/canteraSource/interfaces/matlab_experimental/cantera/ctMatlab/ctMatlabInterface.dylib" -sectcreate __TEXT us_resources "/Users/santosh1/packages/canteraSource/interfaces/matlab_experimental/cantera/ctMatlab/ctMatlab.zip"


Interface file 'ctMatlabInterface.dylib' built in folder '/Users/santosh1/packages/canteraSource/interfaces/matlab_experimental/cantera/ctMatlab'.

To use the library, add the interface file folder to the MATLAB path.
addpath('/Users/santosh1/packages/canteraSource/interfaces/matlab_experimental/cantera/ctMatlab')
Execution mode 'ctMatlab' set to 'inprocess'. To modify, call clibConfiguration('ctMatlab','ExecutionMode','outofprocess').
 Copied 1 run-time library files to '/Users/santosh1/packages/canteraSource/interfaces/matlab_experimental/cantera/ctMatlab'
/Users/santosh1/packages/ct_dev_version/lib/libcantera_shared.3.2.0.dylib

 Run-time dependencies copied to interface library folder.

clibConfiguration("ctmatlab")

ans =

  CLibraryConfiguration for ctmatlab with properties:

InterfaceLibraryPath: "/Users/santosh1/packages/canteraSource/interfaces/matlab_experimental/cantera/ctMatlab/ctMatlabInterface.dylib"
           Libraries: "libcantera_shared.3.2.0.dylib"
              Loaded: 0
       ExecutionMode: inprocess

ctLoad
Unable to load interface library:
'/Users/santosh1/packages/canteraSource/interfaces/matlab_experimental/cantera/ctMatlab/ctMatlabInterface.dylib'.
Reason: The specified module could not be found.
Ensure the C++ dependent libraries for the interface library are added to run-time path.

Error in ctString

Error in ctVersion (line 9)
v = ctString('ct_version');
^^^^^^^^^^^^^^^^^^^^^^
Error in ctLoad (line 32)
fprintf('Cantera %s is ready for use (%s mode).\n', ctVersion, mode);
^^^^^^^^^
Related documentation

ctLoad('inprocess')
Unable to load interface library:
'/Users/santosh1/packages/canteraSource/interfaces/matlab_experimental/cantera/ctMatlab/ctMatlabInterface.dylib'.
Reason: The specified module could not be found.
Ensure the C++ dependent libraries for the interface library are added to run-time path.

Error in ctString

Error in ctVersion (line 9)
v = ctString('ct_version');
^^^^^^^^^^^^^^^^^^^^^^
Error in ctLoad (line 32)
fprintf('Cantera %s is ready for use (%s mode).\n', ctVersion, mode);
^^^^^^^^^
Related documentation

clibConfiguration('ctMatlab','ExecutionMode','inprocess')

ans =

  CLibraryConfiguration for ctMatlab with properties:

InterfaceLibraryPath: "/Users/santosh1/packages/canteraSource/interfaces/matlab_experimental/cantera/ctMatlab/ctMatlabInterface.dylib"
           Libraries: "libcantera_shared.3.2.0.dylib"
              Loaded: 0
       ExecutionMode: inprocess

ctLoad
Cantera 3.2.0a5 is ready for use (outofprocess mode).
gas = Solution('gri30.yaml')

gri30:

   temperature   300 K
      pressure   1.0133e+05 Pa
       density   0.081894 kg/m^3

mean mol. weight 2.016 kg/kmol
phase of matter gas

                      1 kg             1 kmol     
                 ---------------   ---------------
      enthalpy             26469             53361  J

internal energy -1.2108e+06 -2.441e+06 J
entropy 64910 1.3086e+05 J/K
Gibbs function -1.9447e+07 -3.9204e+07 J
heat capacity c_p 14311 28851 J/K
heat capacity c_v 10187 20536 J/K

                  mass frac. Y      mole frac. X     chem. pot. / RT
                 ---------------   ---------------   ---------------
            H2                 1                 1           -15.717
 [  +52 minor]                 0                 0  

Behavior

System information

  • Cantera version: 2054d5e
  • OS: Mac OS 15.6.1
  • Python/MATLAB/other software versions: Python 3.10.19
  • MATLAB 2024b

Attachments

Additional context

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions