title: C# : Referencing or using .so files in .NET Core on Linux
body: <p>We have a project on .NET Framework that references the Fico Xpress solver dll. The dll’s required are –</p>
  
  <ul>
  <li>Xprb.dll</li>
  <li>Xprbdn.dll</li>
  <li>Xprsdn.dll</li>
  </ul>
  
  <p>As no nuget packages are available for using Fico Xpress Solver, we installed the Fico Xpress Solver and copied these dll’s from the installation directory to our local folder named <strong>lib</strong> inside the project folder and added path reference to these dll’s inside the lib folder. So when compiling, the project uses the reference of these dll’s (present in the <strong>lib</strong> folder) to compile. This project successfully builds. When our project calls the Fico Xpress Solver, then the above required dll's are used from the <strong>installation directory</strong> which is probably accessed through the <strong>environment variables</strong> (the dll's in local folder are just for successful compilation of code and we could have pointed it to the actual Fico Xpress Solver installation directory but we put the dll's in <strong>lib</strong> folder so that we can add it to the SVN) and the project runs successfully using the Fico Xpress Solver.</p>
  
  <p>Now, we have ported the project to .NET Core so as to run the same on Linux machines. So we installed Fico Xpress Solver on the Linux machine and tested whether the installation was successful by using the optimizer executable inside the <strong>/opt/xpressmp/bin/</strong> folder (this is the default installation directory for linux machines). Installation is successful and the Fico Xpress Solver runs correctly (checked it using the method given on their website).</p>
  
  <p>When we build the project, it compiles successfully, as it still refers to the required dll’s inside the local <strong>lib</strong> folder. But, when our project calls the Fico Xpress Solver during run time, it fails as it could not load the required dll’s (which it was probably searching in the <strong>LD_LIBRARY_PATH</strong> which is set to <strong>/opt/xpressmp/lib/</strong> as set by the <strong>/opt/xpressmp/bin/xpvars.sh</strong> script which was specified in the installation manual. This folder contains all the <strong>.so</strong> files and no <strong>dll</strong> files.) The error is as below –</p>
  
  <blockquote>
    <p>Unable to load shared library 'xprb.dll' or one of its dependencies.
    In order to help diagnose loading problems, consider setting the
    LD_DEBUG environment variable: libxprb.dll: cannot open shared object
    file: No such file or directory</p>
  </blockquote>
  
  <p>We are not sure whether the approach we are using i.e. using dll's to compile and run is correct or whether we have to some how use the <strong>.so</strong> files to compile and run the project. As the code was building successfully, we expected it to run, but the shared object files are not found.</p>
  
  <p>Can someone please specify a way to use Xpress solver in linux or some general guidelines that need to be followed when using the same 3rd party software on windows and then on linux. Do we need to change the code or add reference to <strong>.so</strong> rather than the <strong>.dll</strong> files</p>
  
  <p>Is <strong>DllImport</strong> the only way to do this (suggested on different blogs)</p>