Author Topic: Calling Matlab from FEAP  (Read 4697 times)

harit

  • Jr. Member
  • **
  • Posts: 11
Calling Matlab from FEAP
« on: July 03, 2023, 08:58:51 AM »
Hi everyone,

I am trying out the example shown in the Feap wiki (http://feap.berkeley.edu/wiki/index.php?title=MATLAB) regarding calling the Matlab functions from FEAP.

I have copied out the content given there to individual files and also modified the umarc6.F to give the paths of Matlab installation files and the FEAP files in the Ubuntu system. I have also made the corresponding changes in the make file. But when I tried to compile them, I am getting an error '/usr/bin/ld: cannot find -leng
/usr/bin/ld: cannot find -lmx'  (see the attached picture of the terminal window).

To be honest, I am not sure what role these leng, lmx play here. I even tried to compile the make file after deleting them. But then I was getting some other error.

Could you please help me out here? I have also attached my make file below.

Two other small questions:
. Is the command 'dsymutil' needed in my makefile for Ubuntu. 
. In the make file given in the wiki link above (made for mac), there a line '-L/$(MLROOT)/bin/maci64'. What does the program look for in the maci64 folder?
  I have a Ubuntu system. So I have changed it to '-L/$(MLROOT)/bin/glnxa64'. Does this make sense?

Thank you very much!




 

Prof. S. Govindjee

  • Administrator
  • FEAP Guru
  • *****
  • Posts: 1160
Re: Calling Matlab from FEAP
« Reply #1 on: July 03, 2023, 02:23:42 PM »
The problem you are seeing is that $(MLROOT)/bin/glnxa64 apparently does not contain the libraries libeng and libmx.  You will have to locate them in your Matlab installation.  If you do not find them, then you will need to load the Matlab Engine (toolbox).

Regarding dsymutil, you do not need that with Ubuntu.

harit

  • Jr. Member
  • **
  • Posts: 11
Re: Calling Matlab from FEAP
« Reply #2 on: July 04, 2023, 07:05:44 AM »
Thank you for the reply.

I do have the files libeng.so and libmx.so in the path /usr/local/MATLAB/R2021a/bin/glnxa64. But the issue is still there. Moreover, this issue occurred during the execution of the command $(LDOPTIONS) -leng -lmx. (See picture).

Where, LDOPTIONS = -L/usr/include -lX11 -lm.




Prof. S. Govindjee

  • Administrator
  • FEAP Guru
  • *****
  • Posts: 1160
Re: Calling Matlab from FEAP
« Reply #3 on: July 05, 2023, 01:43:37 PM »
You -L line seems to have an 'extra'  /.  It should not make a difference but please try removing it to see if that fixes the problem.  You can do so by removing the / before $(MLROOT).

Also please post the out put of
Code: [Select]
ls /usr/local/MATLAB/R2021a/bin/glnxa64/lib*

Prof. S. Govindjee

  • Administrator
  • FEAP Guru
  • *****
  • Posts: 1160
Re: Calling Matlab from FEAP
« Reply #4 on: July 05, 2023, 01:45:56 PM »
I also wonder about your compiler setup.  In your first message I see an error in finding -lgcc_s.

Are you able to build a FEAP executable without the matlab stuff?  Have you tested your compiler on a simple standalone program?

harit

  • Jr. Member
  • **
  • Posts: 11
Re: Calling Matlab from FEAP
« Reply #5 on: July 05, 2023, 04:14:15 PM »
Removing / before $(MLROOT) didn't have any influence, as you have already mentioned.

The code did compile well if I keep only feap84.0 as objects and change $(FF) -Wl,-no_pie -o  to just $(FF) -o. In this case, there was no error in finding -lgcc_s. (But it did reoccur when I replaced -Wl,-no_pie in that command.)

So then I tried adding all the user macro, and user material files in objects and also by removing this  -Wl,-no_pie in $(FF). This time my error was different ('invalid needed version 48', see picture).

You can also find an attached txt file of lib* in glnxa64 and my current make file below.

Thank you :)

Prof. S. Govindjee

  • Administrator
  • FEAP Guru
  • *****
  • Posts: 1160
Re: Calling Matlab from FEAP
« Reply #6 on: July 05, 2023, 11:47:55 PM »
Go ahead and leave off the -Wl,-no_pie that is not needed in general.

Your remaining error is, I think, related to the MATLAB libraries and their
compatibility with your operating system.  MATLAB seems to have its own version of
libstdc++ that is being found and this is interfering with our build; i.e. the way the loader /usr/bin/lb is searching your library paths is not correct.

One random thought is to place the -L$(MLROOT)/bin/glnxa64 after the -lm and before -leng and or other re-arrangements.  Also I am guessing that -L/usr/include is not needed and/or should be -I/usr/include.

I am not an expert on the Ubuntu OS and won't have access to my Ubunutu computer
for another month.  You may be able to get some help on the MATLAB help forums.