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

MEX file error under Ubuntu 20.04 starting from commit 6346ecd #106

Open
andreafarina opened this issue Dec 17, 2024 · 5 comments
Open

MEX file error under Ubuntu 20.04 starting from commit 6346ecd #106

andreafarina opened this issue Dec 17, 2024 · 5 comments

Comments

@andreafarina
Copy link
Contributor

andreafarina commented Dec 17, 2024

Dear @fangq,
I experience the following error under Matlab2024a when I create mex or cudamex binaries starting from commit 6346ecd:

Invalid MEX-file
'/home/andreafarina/Documents/MCXStudio/MATLAB/mmclab/mmc.mexa64':
/usr/local/MATLAB/R2024a/bin/glnxa64/../../sys/os/glnxa64/libstdc++.so.6:
version `GLIBCXX_3.4.29' not found (required by
/home/andreafarina/Documents/MCXStudio/MATLAB/mmclab/mmc.mexa64)

Error in mmclab (line 430)
    [varargout{1:mmcout}] = mmc(cfg);

Error in demo_example_replay (line 44)
[cube, detp, ncfg, seeds] = mmclab(newcfg); % initial simulation

Do you have any hint to solve this?
Thanks a lot
Regards
Andrea

@andreafarina
Copy link
Contributor Author

An update: the problem seems happening only if compiling with make cudamex. If I use cmake ..-DBUILD_CUDA=on the binary works smmohly.
Regards!

@fangq
Copy link
Owner

fangq commented Dec 18, 2024

@andreafarina, can you do a make clean before running make cudamex? if the binary was compiled on your own machine, I don't see why the glibc symbol could not be found.

it is possible that those build on my nightly build server maybe have issues like this, but I don't expect locally build binary to see this error.

@andreafarina
Copy link
Contributor Author

Absolutely, I typically do

make cudamex
make clean
make

to have both the binary and the mexfile. When I run mmclab from matlab with the new binary I get there error...
I've checked if the libstddc++.so.6 that matlab uses is compatible with GLIBCX_3.4.29. Here is the output:
strings /usr/local/MATLAB/R2024a/sys/os/glnxa64/libstdc++.so.6 | grep GLIBCXX
GLIBCXX
GLIBCXX_3.4
GLIBCXX_3.4.1
GLIBCXX_3.4.2
GLIBCXX_3.4.3
GLIBCXX_3.4.4
GLIBCXX_3.4.5
GLIBCXX_3.4.6
GLIBCXX_3.4.7
GLIBCXX_3.4.8
GLIBCXX_3.4.9
GLIBCXX_3.4.10
GLIBCXX_3.4.11
GLIBCXX_3.4.12
GLIBCXX_3.4.13
GLIBCXX_3.4.14
GLIBCXX_3.4.15
GLIBCXX_3.4.16
GLIBCXX_3.4.17
GLIBCXX_3.4.18
GLIBCXX_3.4.19
GLIBCXX_3.4.20
GLIBCXX_3.4.21
GLIBCXX_3.4.22
GLIBCXX_3.4.23
GLIBCXX_3.4.24
GLIBCXX_3.4.25
GLIBCXX_3.4.26
GLIBCXX_3.4.27
GLIBCXX_3.4.28

So I guess that, probably, if I update to MATLAB2024b I can solve the error, or I have to override the use of the matlab library with the one in my linux system. What dou you think?

@fangq
Copy link
Owner

fangq commented Dec 18, 2024

@andreafarina, does this glibc symbol error also happens to make mex output?

if it only happens on cuda output, then it is possible that the cudart library (libcudart_static) was build using a different version of libstdc++ (compared to matlab or system's version).

if you want to see the detailed linking command, you can manually run the mex command, printed by make cudamex and replace mex by mex -v, it should print out the g++ command used to link the .mex file. you can see where the libstdc++ library is used.

@andreafarina
Copy link
Contributor Author

@fangq I've tried also with make mex and the same error happens.
By using your suggestion running mex -v followed by the long line I see that a certain point is used (at least I guess) the options:
MWCPPLIB : "/usr/local/MATLAB/R2024a/sys/os/glnxa64/orig/libstdc++.so.6"
I guess the MATLAB version of libstdc++ is used, and in this case, only up to the 3.4.28 version of GLIBCXX is supported. As a workaround, before running matlab, I run the command:
export LD_PRELOAD=/usr/lib/x86_64-linux-gnu
so to force matlab to use the system libstdc++.so.6 library. In this case mmclab runs smoothly both if compiled under cudamex or mex. On my Ubuntu version I've gcc 11 version installed.
Thanks a lot! Anyway using cmake all goes smoothly! :)

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