Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

MATLAB Bindings Don't Compile on Sonoma - A few issues #3947

Closed
tomgade09 opened this issue Nov 28, 2023 · 3 comments
Closed

MATLAB Bindings Don't Compile on Sonoma - A few issues #3947

tomgade09 opened this issue Nov 28, 2023 · 3 comments

Comments

@tomgade09
Copy link
Contributor

tomgade09 commented Nov 28, 2023

Describe the bugs (x2)

  1. Attempting to compile MATLAB bindings on MacOS 14.1.1 (Sonoma), aarch64 (M1 Max) fails with the following error:
mex adiosopenc.c  -largeArrayDims -DDEBUG CFLAGS="-g -std=c99 -fPIC -O0" -I. -I/opt/homebrew/opt/adios2/include "LDFLAGS=-Wl,-rpath,/opt/homebrew/opt/adios2/lib -L/opt/homebrew/opt/adios2/lib -ladios2_c -ladios2_core"
Building with 'Xcode with Clang'.
/Users/tomgade/src/ADIOS2/bindings/Matlab/adiosopenc.c:143:28: error: too many arguments provided to function-like macro invocation
    adiosobj = adios2_init(false);
                           ^
/opt/homebrew/opt/adios2/include/adios2/c/adios2_c_adios.h:49:9: note: macro 'adios2_init' defined here
#define adios2_init() adios2_init_serial()
        ^
/Users/tomgade/src/ADIOS2/bindings/Matlab/adiosopenc.c:143:16: error: use of undeclared identifier 'adios2_init'
    adiosobj = adios2_init(false);
               ^
2 errors generated.

The issue stems from this code block in <root>/bindings/C/adios2/c/adios2_c_adios.h : 47-50 (below)

#else
#define adios2_init() adios2_init_serial()   // issue #1 (above) - adios2_init is called with an argument in line 143 of <root>/bindings/Matlab/adiosopenc.c
#define adios2_init_config(config_file) adios2_init_config_seria(config_file)  // issue #2 (below) - note "adios2_init_config_**seria**(config_file)"
#endif
  1. There appears to be a typo in the same location <root>/bindings/C/adios2/c/adios2_c_adios.h :: 49. It will likely lead to a link error later, once issue 1 is fixed.

To Reproduce
Steps to reproduce the behavior:

  1. Install ADIOS2 via homebrew and clone the git repository
    OR
  2. Alternatively clone the git repository and compile using the "minimal" instructions in <root>/bindings/Matlab/README.txt :
    cmake -DCMAKE_INSTALL_PREFIX=/opt/adios/lean -DADIOS2_USE_MPI=OFF -DADIOS2_USE_Fortran=OFF -DADIOS2_USE_Python=OFF -DCMAKE_BUILD_TYPE=RelWithDebInfo -DADIOS2_ENABLE_PIC=ON -DCMAKE_POSITION_INDEPENDENT_CODE=ON -DADIOS2_USE_SST=OFF -DADIOS2_USE_BZip2=OFF -DADIOS2_USE_DataMan=OFF ..
  3. cd bindings/Matlab
  4. Modify Makefile to use correct install directories (comment out all other invalid definitions in the above sections)
### General - this should work everywhere
ADIOS_DIR=/opt/homebrew/opt/adios2
ADIOS_INC=-I${ADIOS_DIR}/include
ADIOS_LIBS=-Wl,-rpath,${ADIOS_DIR}/lib -L${ADIOS_DIR}/lib -ladios2_c -ladios2_core
MEXLIBS="LDFLAGS=${ADIOS_LIBS}"

Note: the examples stating ADIOS_LIBS=-Wl,-rpath=<path>.... are invalid (on Mac, maybe others) and should read ...-rpath,<path>... (using a comma, not an equals sign)
5. PATH=$PATH:/Applications/MATLAB_R2023b.app/bin make matlab
6. See error

Expected behavior
MATLAB bindings compile - mex and .dylib files are generated for adiosopen, adiosclose, adiosread, adioswrite.

Desktop (please complete the following information):

  • Macbook Pro M1 Max, MacOS 14.1.1 Sonoma, aarch64
  • Xcode 15.0.1 (which seems to use clang/llvm)
  • ADIOS 2.9.2 (homebrew version), or alternatively same version from source / github repo

Additional context
I installed adios2 through homebrew, leading to this issue; however, it is also worth noting that doing compiling a "minimal" build, as contained in the readme file in /bindings/Matlab also yields this issue. The issue is a mismatch between function signatures

Follow-up
TBD

@tomgade09
Copy link
Contributor Author

I should also add:
Modifying line 143 of adiosopenc.c from:
adiosobj = adios2_init(false);
to
adiosobj = adios2_init(); (not sure if this is valid or not)
yields an undefined external symbol error _main.

mex adiosopenc.c  -largeArrayDims -DDEBUG CFLAGS="-g -std=c99 -fPIC -O0" -I. -I/opt/homebrew/opt/adios2/include "LDFLAGS=-Wl,-rpath,/opt/homebrew/opt/adios2/lib -L/opt/homebrew/opt/adios2/lib -ladios2_c -ladios2_core"
Building with 'Xcode with Clang'.
ld: Undefined symbols:
  _main, referenced from:
      <initial-undefines>
clang: error: linker command failed with exit code 1 (use -v to see invocation)

I've attempted to pass the -v flag in the appropriate spot to show the ld call, but I haven't been able to figure out where to work it in to get it to ld.

@tomgade09
Copy link
Contributor Author

I looked into this more. I've got the solve on this. PR coming shortly.

@anagainaru
Copy link
Contributor

This issue can be closed since it's fixed in #3950

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants