Exporting functions in Dynamic library

Exporting functions in Dynamic library


I have currently a dll (compiled from Fortran Source code with Visual Studio in Windows), which I call from Matlab. Now I want to run the same analysis on a linux machine. I managed so far compiling the code using the command (using intel 11.1 compiler)

ifort -shared -fpic -o ST2CR.so -O3 SourceCodeDll/*.f90

However when I load the ST2CR.so library in matlab, it can't upload the functions which I need (although it loads the library in matlab without error, it complains that it was not able to find the functions which are speficied in header file). Normally in windows, I export these functions as follows:


My question is: what is the equivalent of the command above for linux ? I have looked for this in the web, which led me to things like visibility setting, etc. I tried various things, however couldn't understand properly how things work. Am I supposed to export the selected functions as I do in windows or are things handled differently in linux ? or do I need a different header file ? (just as a side note: I have a big code consisting many routines. However within Matlab, I only need to call four of these functions. Therefore I have these DLLEXPORT commands only in four routines). 

Thank you for your replies in advance,

Best regards,


5 posts / 0 new
Last post
For more complete information about compiler optimizations, see our Optimization Notice.

Linux doesn't require a DLLEXPORT directive - all entry points are automatically exported into a .so. Note that on Linux you link to the .so directly - there is no concept of the import library as on Windows.

I suggest that you check that Matlab is looking for the exact name you have specified in your code. You may need the ALIAS, but I don't know what Matlab is looking for.

Retired 12/31/2016


thank you very much for your prompt reply.

I am sure that Matlab is looking for the exact function names I specified (after all I haven't changed anything from windows to linux, and it can find the functions in windows).

Regarding your comment that I may need ALIAS: could you explain what you mean exactly? is it something to be done on Fortran side or on Matlab side?

Actually at this point my biggest confusion is: is the problem arising from Matlab or from the compiled dynamic library ? From your reply I get that I don't need to specify the names of those four functions which I call in Matlab, i.e. every function compiled in the fortran code is available once the ST2CR.so is loaded, right ? Then, would you agree that as long as I don't get any warning/error from the ifort command (which is the case currently), I can assume that the ST2CR.so is created successfully with all the functions available ?

One final question is: I presume that I can't use Visual Studio to create the ST2CR.so, right ?

Thank you,


What I meant about ALIAS is that external names are case-sensitive. The default for Fortran is different on Windows and Linux, so if you don't use ALIAS the Fortran routine will have a lowercase name (and a trailing underscore) on Linux.

You can use "nm -D" on the .so to dump the visible names.

I can't help with the Matlab side of things. No, you can't use Visual Studio (or Windows at all) to build something for Linux.

Retired 12/31/2016


that was it ! the names were with lower case. using nm -D command revealed the names, and when I changed the names in header file, it worked.

Thank you so much for your help !

best regards,


Leave a Comment

Please sign in to add a comment. Not a member? Join today