precice / matlab-bindings

MATLAB language bindings for preCICE
https://www.precice.org
GNU Lesser General Public License v3.0
5 stars 3 forks source link

More user-friendly procedure to avoid crash due to wrong `libstdc++.so` #53

Open BenjaminRodenberg opened 4 months ago

BenjaminRodenberg commented 4 months ago

In our README.md we suggest the following procedure to start MATLAB, if version GLIBCXX_#.#.## is not found:

LD_PRELOAD=/usr/lib/x86_64-linux-gnu/libstdc++.so.6 matlab

This follows the suggested approach from here.

I'm a bit unsure whether we should generally follow this procedure (assuming it is always or in most cases required) or rather treat it as pure troubleshooting (exceptional cases). I was a bit surprised that I actually do not need to set LD_PRELOAD on my system. Running the example case from https://github.com/precice/tutorials/pull/480 worked for me without the need to set LD_PRELOAD.

There is also a list of supported gcc versions and this looks like we don't need to worry a lot. I would still suggest to keep the remark in the troubleshooting section, because I'm not a big fan of the fact that MATLAB brings along its own libstdc++.so and I assume this might lead to compatibility problems sooner or later.

I think it would be helpful to collect some data here in the comments and then decide what we should tell our users (and how to design the tutorials).

suggested format

Important: We should also check this for the VM.

BenjaminRodenberg commented 4 months ago
NiklasVin commented 4 months ago
BenjaminRodenberg commented 4 months ago

I also tried it out with an older MATLAB version on my system. This makes things even more confusing...

BenjaminRodenberg commented 4 months ago

Also no problems with MATLAB R2023b on my system. This is confusing for me considering what @NiklasVin reports above. Currently it looks like I cannot reproduce the problem.

BenjaminRodenberg commented 4 months ago

With R2020b I can reproduce the problem and get the following error:

Warning: The following error was caught while executing 'precice.Participant' class destructor:
Invalid MEX-file '/home/benjamin/Programming/matlab-bindings/+precice/@Participant/private/preciceGateway.mexa64': /home/benjamin/Software/MATLAB/R2020b/bin/glnxa64/../../sys/os/glnxa64/libstdc++.so.6: version `GLIBCXX_3.4.26' not found (required by /usr/local/lib/libprecice.so.3)

Error in precice.Participant/delete (line 40)
            preciceGateway(uint8(1));

Error in coil (line 4)
interface = precice.Participant("Coil", "../precice-config.xml", 0, 1); 
> In coil (line 4) 
Invalid MEX-file '/home/benjamin/Programming/matlab-bindings/+precice/@Participant/private/preciceGateway.mexa64': /home/benjamin/Software/MATLAB/R2020b/bin/glnxa64/../../sys/os/glnxa64/libstdc++.so.6: version `GLIBCXX_3.4.26' not found (required by /usr/local/lib/libprecice.so.3)

Error in precice.Participant (line 34)
            preciceGateway(uint8(0),ParticipantName,configFileName,int32(ProcessIndex),int32(ProcessSize));

Error in coil (line 4)
interface = precice.Participant("Coil", "../precice-config.xml", 0, 1);
BenjaminRodenberg commented 4 months ago
Warning: The following error was caught while executing 'precice.Participant' class destructor:
Invalid MEX-file '/home/benjamin/Programming/matlab-bindings/+precice/@Participant/private/preciceGateway.mexa64': /home/benjamin/Software/MATLAB/R2021b/bin/glnxa64/../../sys/os/glnxa64/libstdc++.so.6: version `GLIBCXX_3.4.26' not found (required by /usr/local/lib/libprecice.so.3)

Error in precice.Participant/delete (line 40)
            preciceGateway(uint8(1));

Error in coil (line 4)
interface = precice.Participant("Coil", "../precice-config.xml", 0, 1); 
> In coil (line 4) 
Invalid MEX-file '/home/benjamin/Programming/matlab-bindings/+precice/@Participant/private/preciceGateway.mexa64': /home/benjamin/Software/MATLAB/R2021b/bin/glnxa64/../../sys/os/glnxa64/libstdc++.so.6: version `GLIBCXX_3.4.26' not found (required by /usr/local/lib/libprecice.so.3)

Error in precice.Participant (line 34)
            preciceGateway(uint8(0),ParticipantName,configFileName,int32(ProcessIndex),int32(ProcessSize));

Error in coil (line 4)
interface = precice.Participant("Coil", "../precice-config.xml", 0, 1);
BenjaminRodenberg commented 4 months ago

I tried to find a bugfix or similar hinting in this direction in the changelogs of MATLAB, but could not find anything. Therefore, I asked a question in the MATLAB Community forum: https://de.mathworks.com/matlabcentral/answers/2108031-has-issue-with-libstdc-so-6-been-fixed.

NiklasVin commented 4 months ago
NiklasVin commented 4 weeks ago
  • gcc version (gcc --version): (Ubuntu 10.5.0-1ubuntu1~20.04) 10.5.0

    • MATLAB version (~/Software/MATLAB/R2023b/bin/matlab -nodisplay -r "disp(version);exit;"): 23.2.0.2515942 (R2023b) Update 7

    • tutorials/resonant-circuit works without setting LD_PRELOAD: yes

Also no problems with MATLAB R2023b on my system. This is confusing for me considering what @NiklasVin reports above. Currently it looks like I cannot reproduce the problem.

Were the MATLAB versions for which the resonant circuit example worked for you fresh installations? I checked whether you got an answer to your question in the MATLAB forum. The answer links to another thread explaining two different solutions how to avoid the issues I encountered. The first one is with the LD_PRELOAD and the other ansatz is to rename one problematic library in the MATLAB installation path. Maybe you did the renaming for your working examples in advance? Because I reinstalled the newest MATLAB version and it didn't work without the LD_PRELOAD out of the box, but as soon as I renamed the mentioned file, everything worked fine without the preload.