Discussion Closed This discussion was created more than 6 months ago and has been closed. To start a new discussion with a link back to this one, click here.

COMSOL cannot load MATLAB (on Ubuntu 12.04 and Debian 7.7)

Please login with a confirmed email address before reporting spam

Dear all,

I recently experienced a serious problem when trying to use MATLAB functions in COMSOL on Linux computers, where COMSOL needs to call a MATLAB command line.

I use COMSOL 4.4 and MATLAB R2013b.

I both tried that on a workstation with Ubuntu 12.04 and a server with Debian 7.7.
Models and MATLAB functions where tested on a PC with Windows 7 before and worked.

When trying to run them (actually when trying to run any function that needs to call MATLAB), I get the following error:
-----------------------------------------------------------------------------
The following feature has encountered a problem:

Failure loading MATLAB libraries. This model requires that MATLAB is available.
- Library: csmatlab.so
- Error: libeng.so: cannot open shared object file: No such file or directory
-----------------------------------------------------------------------------

Both libraries, csmatlab.so and libeng.so, are on the system. libeng.so is also in the directory of the MATLAB installation that is set in COMSOL, namely /usr/local/MATLAB/R2013b (and there within /bin/glnxa64/libeng.so).

Calling COMSOL servers from MATLAB works perfectly fine on this systems (to the best of my knowledge and experience).

So did anyone else get this error and is there a solution for that problem?

Thanks already in advance for your help.

Best,
Hannes

14 Replies Last Post 2017年7月26日 GMT-4 04:47

Please login with a confirmed email address before reporting spam

Posted: 10 years ago 2015年2月24日 GMT-5 13:02
Hi all,

I tried it now also with COMSOL 5.0 on the Ubuntu 12.04 computer and found the same problem.

Additionally, I tested a few variations for the MATLAB path set in COMSOL (namely /usr/local/MATLAB/R2013b, /usr/local/MATLAB/R2013b/bin and /usr/local/MATLAB/R2013b/bin/glnxa64). None of the tried makes it work.

Does anyone have some suggestions to try?

Thank you,
Hannes
Hi all, I tried it now also with COMSOL 5.0 on the Ubuntu 12.04 computer and found the same problem. Additionally, I tested a few variations for the MATLAB path set in COMSOL (namely /usr/local/MATLAB/R2013b, /usr/local/MATLAB/R2013b/bin and /usr/local/MATLAB/R2013b/bin/glnxa64). None of the tried makes it work. Does anyone have some suggestions to try? Thank you, Hannes

Please login with a confirmed email address before reporting spam

Posted: 10 years ago 2015年2月26日 GMT-5 10:20
Hi,

just for everybody struggling with the same questions:

For the call of MATLAB functions xterm and csh (this one was missing in my case) have to be installed on the system.

Best,
Hannes
Hi, just for everybody struggling with the same questions: For the call of MATLAB functions xterm and csh (this one was missing in my case) have to be installed on the system. Best, Hannes

Please login with a confirmed email address before reporting spam

Posted: 10 years ago 2015年2月26日 GMT-5 11:50
Hi,
I'm having the same problem with Comsol5 and MATLAB_R2014a. I have tried your suggestion of installing csh, and still not working. Where did you install csh (in which directory)?

Thank's a lot,

Savitri
Hi, I'm having the same problem with Comsol5 and MATLAB_R2014a. I have tried your suggestion of installing csh, and still not working. Where did you install csh (in which directory)? Thank's a lot, Savitri

Please login with a confirmed email address before reporting spam

Posted: 10 years ago 2015年2月26日 GMT-5 13:59
Hi Savitri,

I just used aptitude to install it, so I actually didn't worry about the path.
But locating the package gives /bin as the directory of the program and some other dependencies in /usr and /usr/share.
I guess as long as it is on the system path csh is not the problem.

Best,
Hannes
Hi Savitri, I just used aptitude to install it, so I actually didn't worry about the path. But locating the package gives /bin as the directory of the program and some other dependencies in /usr and /usr/share. I guess as long as it is on the system path csh is not the problem. Best, Hannes

Please login with a confirmed email address before reporting spam

Posted: 10 years ago 2015年2月27日 GMT-5 05:10
Hi Hannes,
Thank you for your answer. I have it also in the bin, but for me is still not working; still the same message. So for which versions it worked for you at the end? I have Ubuntu 12.04, Comsol 5 and Matlab 2014a.

Thank's again,

Savitri
Hi Hannes, Thank you for your answer. I have it also in the bin, but for me is still not working; still the same message. So for which versions it worked for you at the end? I have Ubuntu 12.04, Comsol 5 and Matlab 2014a. Thank's again, Savitri

Please login with a confirmed email address before reporting spam

Posted: 10 years ago 2015年2月27日 GMT-5 05:38
Hi Savitri,

I got it running on both the Debian and the Ubuntu system with Comsol4.4 as well as Comsol5.0 and Matlab2013b. So actually just the Matlab version is different.

I guess you also checked xterm (should actually be there by default) and the error message is the same as mine (so this csmatlab.so stuff)?

You could also try (at least the support told me so), if just installing csh does not work, to set one of the following additional flags when starting Comsol:

-mlroot /usr/local/MATLAB/R2013b
(change Matlab directory to yours)
-mlroot /usr/local/MATLAB/R2013b -forcegcc
or
-mlroot /usr/local/MATLAB/R2013b -forcecomsolgcc

If this does not help, I am sorry to tell you that I don't have a clue what else you could try. Maybe it would in this case be best to contact the support and send them your Comsol log files and an error description.

Best,
Hannes
Hi Savitri, I got it running on both the Debian and the Ubuntu system with Comsol4.4 as well as Comsol5.0 and Matlab2013b. So actually just the Matlab version is different. I guess you also checked xterm (should actually be there by default) and the error message is the same as mine (so this csmatlab.so stuff)? You could also try (at least the support told me so), if just installing csh does not work, to set one of the following additional flags when starting Comsol: -mlroot /usr/local/MATLAB/R2013b (change Matlab directory to yours) -mlroot /usr/local/MATLAB/R2013b -forcegcc or -mlroot /usr/local/MATLAB/R2013b -forcecomsolgcc If this does not help, I am sorry to tell you that I don't have a clue what else you could try. Maybe it would in this case be best to contact the support and send them your Comsol log files and an error description. Best, Hannes

Please login with a confirmed email address before reporting spam

Posted: 10 years ago 2015年2月27日 GMT-5 06:05
Hi Hannes,

Yes I have xterm and csh installed. The error message is the same as yours:

Messages:
The following feature has encountered a problem:

Failure loading MATLAB libraries. This model requires that MATLAB is available.
- Library: csmatlab.so
- Error: libeng.so: cannot open shared object file: No such file or directory

But for me it's appearing when I'm using Livelink for matlab (Matlab and Comsol), so I see it in the matlab gui. When I use the same model in Comsol it works fine. I'm quite sure that the model is correct because is one of the tutorial models that Comsol offers, that calls Matlab external functions.

So what I'm finding is that there's a trouble with Livelink for matlab when trying to call matlab external functions and I have the feeling this is related with Matlab 2014a.

Thank's a lot for your help and I'm going to contact Comsol support, and also try if with another version of Matlab it works good.

Cheers,

Savitri

Hi Hannes, Yes I have xterm and csh installed. The error message is the same as yours: Messages: The following feature has encountered a problem: Failure loading MATLAB libraries. This model requires that MATLAB is available. - Library: csmatlab.so - Error: libeng.so: cannot open shared object file: No such file or directory But for me it's appearing when I'm using Livelink for matlab (Matlab and Comsol), so I see it in the matlab gui. When I use the same model in Comsol it works fine. I'm quite sure that the model is correct because is one of the tutorial models that Comsol offers, that calls Matlab external functions. So what I'm finding is that there's a trouble with Livelink for matlab when trying to call matlab external functions and I have the feeling this is related with Matlab 2014a. Thank's a lot for your help and I'm going to contact Comsol support, and also try if with another version of Matlab it works good. Cheers, Savitri

Please login with a confirmed email address before reporting spam

Posted: 10 years ago 2015年2月27日 GMT-5 06:20
Hi Savitri,

I tried it now through the MATLAB Livelink and you are right the problem remained. So apparently it does also not work with this MATLAB version.
The actual real annoying thing is that it works fine in Windows :(
I'll post here if I have some news.

Best,
Hannes
Hi Savitri, I tried it now through the MATLAB Livelink and you are right the problem remained. So apparently it does also not work with this MATLAB version. The actual real annoying thing is that it works fine in Windows :( I'll post here if I have some news. Best, Hannes

Please login with a confirmed email address before reporting spam

Posted: 10 years ago 2015年2月27日 GMT-5 06:31
Hi,

Ok, I just wrote them; I'll keep you updated.

Thank you,

Savitri
Hi, Ok, I just wrote them; I'll keep you updated. Thank you, Savitri

Please login with a confirmed email address before reporting spam

Posted: 10 years ago 2015年3月3日 GMT-5 08:46
Hi Savitri,

can you try typing (adjusted to your Matlab directory):
export LD_LIBRARY_PATH=/usr/local/MATLAB/R2013b/bin/glnxa64/:$LD_LIBRARY_PATH
in the shell in which you afterwards start Comsol/Matlab?

It may help. I got it from the support and up to now it seems to work, but I did not run all tests yet.

Best,
Hannes
Hi Savitri, can you try typing (adjusted to your Matlab directory): export LD_LIBRARY_PATH=/usr/local/MATLAB/R2013b/bin/glnxa64/:$LD_LIBRARY_PATH in the shell in which you afterwards start Comsol/Matlab? It may help. I got it from the support and up to now it seems to work, but I did not run all tests yet. Best, Hannes

Please login with a confirmed email address before reporting spam

Posted: 10 years ago 2015年3月4日 GMT-5 05:41
Hi Hannes,

I have tried what you proposed and it works also for me, the problem is that I need to type this every time I start a new terminal. From Comsol support they answered me the following:

There is a bug in Matlab 2014a that prevents the Matlab Engine form working. You can either

1) Upgrade to Matlab 2014b

or

2) Upgrade Comsol with an update that circumvents the problem:

www.comsol.com/product-update/5.0

For now, I have tried option 2 and it works; maybe you could also try otion 2 if you are using Comsol5, but I don't know if it's the same since you were using another Matlab version.

Cheers,

Savitri
Hi Hannes, I have tried what you proposed and it works also for me, the problem is that I need to type this every time I start a new terminal. From Comsol support they answered me the following: There is a bug in Matlab 2014a that prevents the Matlab Engine form working. You can either 1) Upgrade to Matlab 2014b or 2) Upgrade Comsol with an update that circumvents the problem: www.comsol.com/product-update/5.0 For now, I have tried option 2 and it works; maybe you could also try otion 2 if you are using Comsol5, but I don't know if it's the same since you were using another Matlab version. Cheers, Savitri

Please login with a confirmed email address before reporting spam

Posted: 10 years ago 2015年3月4日 GMT-5 06:48
Hi Savitri,

Thank you for also testing it.

I already tried it with my MATLAB version and COMSOL5.0, but it had the same problem. For now I just added this line to the script that I use to call COMSOL.

As far as I know one could also permanently add the directory to PD_LIBRARY_PATH for all users within /etc/ and there the .conf file (but look up the correct way to do that in some Linux forums) or one uses bashrc, if it has to be set just for a single user.
Probably even adding the line directly in comsols shell script (so comsol within your comsol44/bin directory) would do the job.

Anyway, it works now.

Cheers,
Hannes

Hi Savitri, Thank you for also testing it. I already tried it with my MATLAB version and COMSOL5.0, but it had the same problem. For now I just added this line to the script that I use to call COMSOL. As far as I know one could also permanently add the directory to PD_LIBRARY_PATH for all users within /etc/ and there the .conf file (but look up the correct way to do that in some Linux forums) or one uses bashrc, if it has to be set just for a single user. Probably even adding the line directly in comsols shell script (so comsol within your comsol44/bin directory) would do the job. Anyway, it works now. Cheers, Hannes

Walter Frei COMSOL Employee

Please login with a confirmed email address before reporting spam

Posted: 10 years ago 2015年3月4日 GMT-5 09:22
Hello All,

Installation questions such as this can also be addressed to support@comsol.com.

For academic users, you can ask your local COMSOL Software Administrator to contact our Technical Support Team on your behalf, and they can also assist you with networking and other system administration issues unrelated to COMSOL, as seems to be part of the issue here.

Please also always check the list of supported platforms before attempting to install:
www.comsol.com/system-requirements

Best Regards
Hello All, Installation questions such as this can also be addressed to support@comsol.com. For academic users, you can ask your local COMSOL Software Administrator to contact our Technical Support Team on your behalf, and they can also assist you with networking and other system administration issues unrelated to COMSOL, as seems to be part of the issue here. Please also always check the list of supported platforms before attempting to install: http://www.comsol.com/system-requirements Best Regards

Please login with a confirmed email address before reporting spam

Posted: 7 years ago 2017年7月26日 GMT-4 04:47
I want to use your method,but my computer's system is Windows7. What should I do for this situation?
I want to use your method,but my computer's system is Windows7. What should I do for this situation?

Note that while COMSOL employees may participate in the discussion forum, COMSOL® software users who are on-subscription should submit their questions via the Support Center for a more comprehensive response from the Technical Support team.