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

Link custom plugin to NCrystal in Mac (OSX-arm64) #211

Closed
XuShuqi7 opened this issue Dec 5, 2024 · 11 comments
Closed

Link custom plugin to NCrystal in Mac (OSX-arm64) #211

XuShuqi7 opened this issue Dec 5, 2024 · 11 comments

Comments

@XuShuqi7
Copy link

XuShuqi7 commented Dec 5, 2024

I tried to attach a custom plugin "https://github.com/XuShuqi7/ncplugin-CrysExtn" to NCrystal in my Mac (OSX-arm64), while I find some issues. After installing NCrystal, the commands I used are:

git clone https://github.com/XuShuqi7/ncplugin-CrysExtn.git
cmake -S ./ncplugin-CrysExtn -B ./tmpbld -DNCPLUGIN_DEVMODE=OFF -DCMAKE_INSTALL_PREFIX=./CrysExtn_inst/
cmake --build tmpbld
cmake --install tmpbld
export NCRYSTAL_PLUGIN_LIST="$PWD/CrysExtn_inst/lib/libNCPlugin_CrysExtn.dylib"

When I typed nctool --plugin, I got

Traceback (most recent call last):
  File "/Users/shuqixu/opt/miniconda3/envs/ncrystal-extinction/bin/nctool", line 1037, in <module>
    main()
    ~~~~^^
  File "/Users/shuqixu/opt/miniconda3/envs/ncrystal-extinction/bin/nctool", line 913, in main
    NC.browsePlugins(dump=True)
    ~~~~~~~~~~~~~~~~^^^^^^^^^^^
  File "/Users/shuqixu/opt/miniconda3/envs/ncrystal-extinction/share/NCrystal/python/NCrystal/plugins.py", line 41, in browsePlugins
    l=_get_raw_cfcts()['ncrystal_get_pluginlist']()
  File "/Users/shuqixu/opt/miniconda3/envs/ncrystal-extinction/share/NCrystal/python/NCrystal/_chooks.py", line 789, in ncrystal_get_pluginlist
    _raw_getpluginlist(n,ctypes.byref(l))
    ~~~~~~~~~~~~~~~~~~^^^^^^^^^^^^^^^^^^^
  File "/Users/shuqixu/opt/miniconda3/envs/ncrystal-extinction/share/NCrystal/python/NCrystal/_chooks.py", line 203, in fcte
    _raise_err()
    ~~~~~~~~~~^^
  File "/Users/shuqixu/opt/miniconda3/envs/ncrystal-extinction/share/NCrystal/python/NCrystal/_chooks.py", line 175, in _raise_err
    raise e
NCrystal.exceptions.NCDataLoadError: Could not load shared library: /Users/shuqixu/Downloads/My_C++/ncrystal_test_plugin/CrysExtn_inst/lib/libNCPlugin_CrysExtn.dylib (error was: dlopen(/Users/shuqixu/Downloads/My_C++/ncrystal_test_plugin/CrysExtn_inst/lib/libNCPlugin_CrysExtn.dylib, 0x0006): weak-def symbol not found '__ZNK8NCrystal8FactImpl18ProcessRequestBaseINS0_14ScatterRequestEE8modifiedEPKc')

Please help me to check if I didn't use the commands correctly or should I need to modify some of them? Thx!

@tkittel
Copy link
Member

tkittel commented Dec 5, 2024

Hi @XuShuqi7 ,

After asking you to open this I realised that we already have #193 for this. Can you go there and try the solution I just suggested?

Cheers,
Thomas

@XuShuqi7
Copy link
Author

XuShuqi7 commented Dec 5, 2024

Hi @tkittel,

I replaced SHARED by MODULE in the CMakeLists.txt file, deleted the previous folders, and reran all the commands, but I still got exactly the same error:

Traceback (most recent call last):
  File "/Users/shuqixu/opt/miniconda3/envs/ncrystal-extinction/bin/nctool", line 1037, in <module>
    main()
    ~~~~^^
  File "/Users/shuqixu/opt/miniconda3/envs/ncrystal-extinction/bin/nctool", line 913, in main
    NC.browsePlugins(dump=True)
    ~~~~~~~~~~~~~~~~^^^^^^^^^^^
  File "/Users/shuqixu/opt/miniconda3/envs/ncrystal-extinction/share/NCrystal/python/NCrystal/plugins.py", line 41, in browsePlugins
    l=_get_raw_cfcts()['ncrystal_get_pluginlist']()
  File "/Users/shuqixu/opt/miniconda3/envs/ncrystal-extinction/share/NCrystal/python/NCrystal/_chooks.py", line 789, in ncrystal_get_pluginlist
    _raw_getpluginlist(n,ctypes.byref(l))
    ~~~~~~~~~~~~~~~~~~^^^^^^^^^^^^^^^^^^^
  File "/Users/shuqixu/opt/miniconda3/envs/ncrystal-extinction/share/NCrystal/python/NCrystal/_chooks.py", line 203, in fcte
    _raise_err()
    ~~~~~~~~~~^^
  File "/Users/shuqixu/opt/miniconda3/envs/ncrystal-extinction/share/NCrystal/python/NCrystal/_chooks.py", line 175, in _raise_err
    raise e
NCrystal.exceptions.NCDataLoadError: Could not load shared library: /Users/shuqixu/Downloads/My_C++/ncrystal_test_plugin/CrysExtn_inst/lib/libNCPlugin_CrysExtn.so (error was: dlopen(/Users/shuqixu/Downloads/My_C++/ncrystal_test_plugin/CrysExtn_inst/lib/libNCPlugin_CrysExtn.so, 0x0006): weak-def symbol not found '__ZNK8NCrystal8FactImpl18ProcessRequestBaseINS0_14ScatterRequestEE8modifiedEPKc')

@tkittel
Copy link
Member

tkittel commented Dec 5, 2024

And you are in conda with a conda-installed NCrystal?

@XuShuqi7
Copy link
Author

XuShuqi7 commented Dec 5, 2024

Yes, I used the following commands for installing NCrystal:

conda create -n ncrystal-extinction -y -c conda-forge jupyter numpy scipy matplotlib pip h5py
conda activate ncrystal-extinction
conda install conda-forge::ncrystal

Then followed by the previously listed commands.

@tkittel
Copy link
Member

tkittel commented Dec 5, 2024

Could you try to also install the conda-forge compilers and cmake packages, and then deactivate + activate your environment? And then try again of course.

@XuShuqi7
Copy link
Author

XuShuqi7 commented Dec 5, 2024

Yes, I ran

conda install -c conda-forge compilers
conda install -c conda-forge cmake 

and deactivate and activate the env, and reran all the process including reinstalling NCrystal, but I still got exactly the same error message.

@tkittel
Copy link
Member

tkittel commented Dec 5, 2024

Ok, it was worth a try. If you can debug it further with tools like otool, feel free to do so. Otherwise I will have a look eventually.

@XuShuqi7
Copy link
Author

XuShuqi7 commented Dec 5, 2024

I used otool to look at the shared libraries used, and I got

/Users/shuqixu/Downloads/My_C++/ncrystal_test_plugin/CrysExtn_inst/lib/libNCPlugin_CrysExtn.so:
	@rpath/libNCrystal.3.dylib (compatibility version 3.0.0, current version 3.9.7)
	@rpath/libc++.1.dylib (compatibility version 1.0.0, current version 1.0.0)
	/usr/lib/libSystem.B.dylib (compatibility version 1.0.0, current version 1351.0.0)

@tkittel
Copy link
Member

tkittel commented Dec 5, 2024

Sure, but I meant that you either have to investigate and find the solution, or wait.

@tkittel
Copy link
Member

tkittel commented Dec 5, 2024

Also, please do not comment more on this closed issue. Put comments on #193.

@XuShuqi7
Copy link
Author

XuShuqi7 commented Dec 5, 2024

OK. Since we always has a backup solution for including the plugin, we can address this issue later. Thanks a lot for the discussion :-)

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

No branches or pull requests

2 participants