Set LD_LIBRARY_PATH correctly











up vote
4
down vote

favorite












I am using Docker with image of Ubuntu 16.04. I am using this docker to run:




  • Import C++ classes in python with the help of boost.python

  • Import matlab's python package in python with the help Matlab Runtime (MCR).


Before I have installed MCR in the docker, I have installed boost using:



$ sudo apt-get install -y libboost-all-dev


and I was able to wrap C++ classes and call them in python. Then I have installed MCR and one of the requirement is to set LD_LIBRARY_PATH to Matlab's library.



export LD_LIBRARY_PATH=$LD_LIBRARY_PATH:/usr/local/MATLAB/MATLAB_Runtime/v94/runtime/glnxa64:/usr/local/MATLAB/MATLAB_Runtime/v94/bin/glnxa64:/usr/local/MATLAB/MATLAB_Runtime/v94/sys/os/glnxa64:/usr/local/MATLAB/MATLAB_Runtime/v94/extern/bin/glnxa64


It worked, I was able to run matlab's python package in python but testing the C++ classes wrappers failed due to change of LD_LIBRARY_PATH. For example, I get the following error when I try to import C++ class in python:



 /usr/lib/x86_64-linux-gnu/libpython3.4m.so.1.0: undefined symbol: XML_SetHashSalt


If I unset LD_LIBRARY_PATH C++ import works but MCR fails. So the question what LD_LIBRARY_PATH should be in order to run both C++ classes and Matlab's python package successfully?



I have tried to add path to boost libraries to LD_LIBRARY_PATH but didn't work, so the env value would be:



/usr/lib/x86_64-linux-gnu:/usr/local/MATLAB/MATLAB_Runtime/v94/runtime/glnxa64:/usr/local/MATLAB/MATLAB_Runtime/v94/bin/glnxa64:/usr/local/MATLAB/MATLAB_Runtime/v94/sys/os/glnxa64:/usr/local/MATLAB/MATLAB_Runtime/v94/extern/bin/glnxa64


EDIT



the dependencies of C++ library file before setting the LD_LIBRARY_PATH:



linux-vdso.so.1 (0x00007ffcee0dc000)
libpython3.4m.so.1.0 => /usr/lib/x86_64-linux-gnu/libpython3.4m.so.1.0 (0x00007f9d69e59000)
libboost_python-py34.so.1.55.0 => /usr/lib/x86_64-linux-gnu/libboost_python-py34.so.1.55.0 (0x00007f9d69c09000)
libstdc++.so.6 => /usr/lib/x86_64-linux-gnu/libstdc++.so.6 (0x00007f9d698fe000)
libm.so.6 => /lib/x86_64-linux-gnu/libm.so.6 (0x00007f9d695fd000)
libgcc_s.so.1 => /lib/x86_64-linux-gnu/libgcc_s.so.1 (0x00007f9d693e7000)
libc.so.6 => /lib/x86_64-linux-gnu/libc.so.6 (0x00007f9d6903c000)
librt.so.1 => /lib/x86_64-linux-gnu/librt.so.1 (0x00007f9d68e34000)
libexpat.so.1 => /lib/x86_64-linux-gnu/libexpat.so.1 (0x00007f9d68c0b000)
libz.so.1 => /lib/x86_64-linux-gnu/libz.so.1 (0x00007f9d689f0000)
libpthread.so.0 => /lib/x86_64-linux-gnu/libpthread.so.0 (0x00007f9d687d3000)
libdl.so.2 => /lib/x86_64-linux-gnu/libdl.so.2 (0x00007f9d685cf000)
libutil.so.1 => /lib/x86_64-linux-gnu/libutil.so.1 (0x00007f9d683cc000)
/lib64/ld-linux-x86-64.so.2 (0x00007f9d6a6c3000)


After setting the LD_LIBRARY_PATH:



linux-vdso.so.1 (0x00007ffc42e9b000)
libpython3.4m.so.1.0 => /usr/lib/x86_64-linux-gnu/libpython3.4m.so.1.0 (0x00007fad9635b000)
libboost_python-py34.so.1.55.0 => /usr/lib/x86_64-linux-gnu/libboost_python-py34.so.1.55.0 (0x00007fad9610b000)
libstdc++.so.6 => /usr/local/MATLAB/MATLAB_Runtime/v94/sys/os/glnxa64/libstdc++.so.6 (0x00007fad95d8a000)
libm.so.6 => /lib/x86_64-linux-gnu/libm.so.6 (0x00007fad95a89000)
libgcc_s.so.1 => /usr/local/MATLAB/MATLAB_Runtime/v94/sys/os/glnxa64/libgcc_s.so.1 (0x00007fad95873000)
libc.so.6 => /lib/x86_64-linux-gnu/libc.so.6 (0x00007fad954c8000)
librt.so.1 => /lib/x86_64-linux-gnu/librt.so.1 (0x00007fad952c0000)
libexpat.so.1 => /usr/local/MATLAB/MATLAB_Runtime/v94/bin/glnxa64/libexpat.so.1 (0x00007fad95095000)
libz.so.1 => /lib/x86_64-linux-gnu/libz.so.1 (0x00007fad94e7a000)
libpthread.so.0 => /lib/x86_64-linux-gnu/libpthread.so.0 (0x00007fad94c5d000)
libdl.so.2 => /lib/x86_64-linux-gnu/libdl.so.2 (0x00007fad94a59000)
libutil.so.1 => /lib/x86_64-linux-gnu/libutil.so.1 (0x00007fad94856000)
/lib64/ld-linux-x86-64.so.2 (0x00007fad96bc5000)









share|improve this question




























    up vote
    4
    down vote

    favorite












    I am using Docker with image of Ubuntu 16.04. I am using this docker to run:




    • Import C++ classes in python with the help of boost.python

    • Import matlab's python package in python with the help Matlab Runtime (MCR).


    Before I have installed MCR in the docker, I have installed boost using:



    $ sudo apt-get install -y libboost-all-dev


    and I was able to wrap C++ classes and call them in python. Then I have installed MCR and one of the requirement is to set LD_LIBRARY_PATH to Matlab's library.



    export LD_LIBRARY_PATH=$LD_LIBRARY_PATH:/usr/local/MATLAB/MATLAB_Runtime/v94/runtime/glnxa64:/usr/local/MATLAB/MATLAB_Runtime/v94/bin/glnxa64:/usr/local/MATLAB/MATLAB_Runtime/v94/sys/os/glnxa64:/usr/local/MATLAB/MATLAB_Runtime/v94/extern/bin/glnxa64


    It worked, I was able to run matlab's python package in python but testing the C++ classes wrappers failed due to change of LD_LIBRARY_PATH. For example, I get the following error when I try to import C++ class in python:



     /usr/lib/x86_64-linux-gnu/libpython3.4m.so.1.0: undefined symbol: XML_SetHashSalt


    If I unset LD_LIBRARY_PATH C++ import works but MCR fails. So the question what LD_LIBRARY_PATH should be in order to run both C++ classes and Matlab's python package successfully?



    I have tried to add path to boost libraries to LD_LIBRARY_PATH but didn't work, so the env value would be:



    /usr/lib/x86_64-linux-gnu:/usr/local/MATLAB/MATLAB_Runtime/v94/runtime/glnxa64:/usr/local/MATLAB/MATLAB_Runtime/v94/bin/glnxa64:/usr/local/MATLAB/MATLAB_Runtime/v94/sys/os/glnxa64:/usr/local/MATLAB/MATLAB_Runtime/v94/extern/bin/glnxa64


    EDIT



    the dependencies of C++ library file before setting the LD_LIBRARY_PATH:



    linux-vdso.so.1 (0x00007ffcee0dc000)
    libpython3.4m.so.1.0 => /usr/lib/x86_64-linux-gnu/libpython3.4m.so.1.0 (0x00007f9d69e59000)
    libboost_python-py34.so.1.55.0 => /usr/lib/x86_64-linux-gnu/libboost_python-py34.so.1.55.0 (0x00007f9d69c09000)
    libstdc++.so.6 => /usr/lib/x86_64-linux-gnu/libstdc++.so.6 (0x00007f9d698fe000)
    libm.so.6 => /lib/x86_64-linux-gnu/libm.so.6 (0x00007f9d695fd000)
    libgcc_s.so.1 => /lib/x86_64-linux-gnu/libgcc_s.so.1 (0x00007f9d693e7000)
    libc.so.6 => /lib/x86_64-linux-gnu/libc.so.6 (0x00007f9d6903c000)
    librt.so.1 => /lib/x86_64-linux-gnu/librt.so.1 (0x00007f9d68e34000)
    libexpat.so.1 => /lib/x86_64-linux-gnu/libexpat.so.1 (0x00007f9d68c0b000)
    libz.so.1 => /lib/x86_64-linux-gnu/libz.so.1 (0x00007f9d689f0000)
    libpthread.so.0 => /lib/x86_64-linux-gnu/libpthread.so.0 (0x00007f9d687d3000)
    libdl.so.2 => /lib/x86_64-linux-gnu/libdl.so.2 (0x00007f9d685cf000)
    libutil.so.1 => /lib/x86_64-linux-gnu/libutil.so.1 (0x00007f9d683cc000)
    /lib64/ld-linux-x86-64.so.2 (0x00007f9d6a6c3000)


    After setting the LD_LIBRARY_PATH:



    linux-vdso.so.1 (0x00007ffc42e9b000)
    libpython3.4m.so.1.0 => /usr/lib/x86_64-linux-gnu/libpython3.4m.so.1.0 (0x00007fad9635b000)
    libboost_python-py34.so.1.55.0 => /usr/lib/x86_64-linux-gnu/libboost_python-py34.so.1.55.0 (0x00007fad9610b000)
    libstdc++.so.6 => /usr/local/MATLAB/MATLAB_Runtime/v94/sys/os/glnxa64/libstdc++.so.6 (0x00007fad95d8a000)
    libm.so.6 => /lib/x86_64-linux-gnu/libm.so.6 (0x00007fad95a89000)
    libgcc_s.so.1 => /usr/local/MATLAB/MATLAB_Runtime/v94/sys/os/glnxa64/libgcc_s.so.1 (0x00007fad95873000)
    libc.so.6 => /lib/x86_64-linux-gnu/libc.so.6 (0x00007fad954c8000)
    librt.so.1 => /lib/x86_64-linux-gnu/librt.so.1 (0x00007fad952c0000)
    libexpat.so.1 => /usr/local/MATLAB/MATLAB_Runtime/v94/bin/glnxa64/libexpat.so.1 (0x00007fad95095000)
    libz.so.1 => /lib/x86_64-linux-gnu/libz.so.1 (0x00007fad94e7a000)
    libpthread.so.0 => /lib/x86_64-linux-gnu/libpthread.so.0 (0x00007fad94c5d000)
    libdl.so.2 => /lib/x86_64-linux-gnu/libdl.so.2 (0x00007fad94a59000)
    libutil.so.1 => /lib/x86_64-linux-gnu/libutil.so.1 (0x00007fad94856000)
    /lib64/ld-linux-x86-64.so.2 (0x00007fad96bc5000)









    share|improve this question


























      up vote
      4
      down vote

      favorite









      up vote
      4
      down vote

      favorite











      I am using Docker with image of Ubuntu 16.04. I am using this docker to run:




      • Import C++ classes in python with the help of boost.python

      • Import matlab's python package in python with the help Matlab Runtime (MCR).


      Before I have installed MCR in the docker, I have installed boost using:



      $ sudo apt-get install -y libboost-all-dev


      and I was able to wrap C++ classes and call them in python. Then I have installed MCR and one of the requirement is to set LD_LIBRARY_PATH to Matlab's library.



      export LD_LIBRARY_PATH=$LD_LIBRARY_PATH:/usr/local/MATLAB/MATLAB_Runtime/v94/runtime/glnxa64:/usr/local/MATLAB/MATLAB_Runtime/v94/bin/glnxa64:/usr/local/MATLAB/MATLAB_Runtime/v94/sys/os/glnxa64:/usr/local/MATLAB/MATLAB_Runtime/v94/extern/bin/glnxa64


      It worked, I was able to run matlab's python package in python but testing the C++ classes wrappers failed due to change of LD_LIBRARY_PATH. For example, I get the following error when I try to import C++ class in python:



       /usr/lib/x86_64-linux-gnu/libpython3.4m.so.1.0: undefined symbol: XML_SetHashSalt


      If I unset LD_LIBRARY_PATH C++ import works but MCR fails. So the question what LD_LIBRARY_PATH should be in order to run both C++ classes and Matlab's python package successfully?



      I have tried to add path to boost libraries to LD_LIBRARY_PATH but didn't work, so the env value would be:



      /usr/lib/x86_64-linux-gnu:/usr/local/MATLAB/MATLAB_Runtime/v94/runtime/glnxa64:/usr/local/MATLAB/MATLAB_Runtime/v94/bin/glnxa64:/usr/local/MATLAB/MATLAB_Runtime/v94/sys/os/glnxa64:/usr/local/MATLAB/MATLAB_Runtime/v94/extern/bin/glnxa64


      EDIT



      the dependencies of C++ library file before setting the LD_LIBRARY_PATH:



      linux-vdso.so.1 (0x00007ffcee0dc000)
      libpython3.4m.so.1.0 => /usr/lib/x86_64-linux-gnu/libpython3.4m.so.1.0 (0x00007f9d69e59000)
      libboost_python-py34.so.1.55.0 => /usr/lib/x86_64-linux-gnu/libboost_python-py34.so.1.55.0 (0x00007f9d69c09000)
      libstdc++.so.6 => /usr/lib/x86_64-linux-gnu/libstdc++.so.6 (0x00007f9d698fe000)
      libm.so.6 => /lib/x86_64-linux-gnu/libm.so.6 (0x00007f9d695fd000)
      libgcc_s.so.1 => /lib/x86_64-linux-gnu/libgcc_s.so.1 (0x00007f9d693e7000)
      libc.so.6 => /lib/x86_64-linux-gnu/libc.so.6 (0x00007f9d6903c000)
      librt.so.1 => /lib/x86_64-linux-gnu/librt.so.1 (0x00007f9d68e34000)
      libexpat.so.1 => /lib/x86_64-linux-gnu/libexpat.so.1 (0x00007f9d68c0b000)
      libz.so.1 => /lib/x86_64-linux-gnu/libz.so.1 (0x00007f9d689f0000)
      libpthread.so.0 => /lib/x86_64-linux-gnu/libpthread.so.0 (0x00007f9d687d3000)
      libdl.so.2 => /lib/x86_64-linux-gnu/libdl.so.2 (0x00007f9d685cf000)
      libutil.so.1 => /lib/x86_64-linux-gnu/libutil.so.1 (0x00007f9d683cc000)
      /lib64/ld-linux-x86-64.so.2 (0x00007f9d6a6c3000)


      After setting the LD_LIBRARY_PATH:



      linux-vdso.so.1 (0x00007ffc42e9b000)
      libpython3.4m.so.1.0 => /usr/lib/x86_64-linux-gnu/libpython3.4m.so.1.0 (0x00007fad9635b000)
      libboost_python-py34.so.1.55.0 => /usr/lib/x86_64-linux-gnu/libboost_python-py34.so.1.55.0 (0x00007fad9610b000)
      libstdc++.so.6 => /usr/local/MATLAB/MATLAB_Runtime/v94/sys/os/glnxa64/libstdc++.so.6 (0x00007fad95d8a000)
      libm.so.6 => /lib/x86_64-linux-gnu/libm.so.6 (0x00007fad95a89000)
      libgcc_s.so.1 => /usr/local/MATLAB/MATLAB_Runtime/v94/sys/os/glnxa64/libgcc_s.so.1 (0x00007fad95873000)
      libc.so.6 => /lib/x86_64-linux-gnu/libc.so.6 (0x00007fad954c8000)
      librt.so.1 => /lib/x86_64-linux-gnu/librt.so.1 (0x00007fad952c0000)
      libexpat.so.1 => /usr/local/MATLAB/MATLAB_Runtime/v94/bin/glnxa64/libexpat.so.1 (0x00007fad95095000)
      libz.so.1 => /lib/x86_64-linux-gnu/libz.so.1 (0x00007fad94e7a000)
      libpthread.so.0 => /lib/x86_64-linux-gnu/libpthread.so.0 (0x00007fad94c5d000)
      libdl.so.2 => /lib/x86_64-linux-gnu/libdl.so.2 (0x00007fad94a59000)
      libutil.so.1 => /lib/x86_64-linux-gnu/libutil.so.1 (0x00007fad94856000)
      /lib64/ld-linux-x86-64.so.2 (0x00007fad96bc5000)









      share|improve this question















      I am using Docker with image of Ubuntu 16.04. I am using this docker to run:




      • Import C++ classes in python with the help of boost.python

      • Import matlab's python package in python with the help Matlab Runtime (MCR).


      Before I have installed MCR in the docker, I have installed boost using:



      $ sudo apt-get install -y libboost-all-dev


      and I was able to wrap C++ classes and call them in python. Then I have installed MCR and one of the requirement is to set LD_LIBRARY_PATH to Matlab's library.



      export LD_LIBRARY_PATH=$LD_LIBRARY_PATH:/usr/local/MATLAB/MATLAB_Runtime/v94/runtime/glnxa64:/usr/local/MATLAB/MATLAB_Runtime/v94/bin/glnxa64:/usr/local/MATLAB/MATLAB_Runtime/v94/sys/os/glnxa64:/usr/local/MATLAB/MATLAB_Runtime/v94/extern/bin/glnxa64


      It worked, I was able to run matlab's python package in python but testing the C++ classes wrappers failed due to change of LD_LIBRARY_PATH. For example, I get the following error when I try to import C++ class in python:



       /usr/lib/x86_64-linux-gnu/libpython3.4m.so.1.0: undefined symbol: XML_SetHashSalt


      If I unset LD_LIBRARY_PATH C++ import works but MCR fails. So the question what LD_LIBRARY_PATH should be in order to run both C++ classes and Matlab's python package successfully?



      I have tried to add path to boost libraries to LD_LIBRARY_PATH but didn't work, so the env value would be:



      /usr/lib/x86_64-linux-gnu:/usr/local/MATLAB/MATLAB_Runtime/v94/runtime/glnxa64:/usr/local/MATLAB/MATLAB_Runtime/v94/bin/glnxa64:/usr/local/MATLAB/MATLAB_Runtime/v94/sys/os/glnxa64:/usr/local/MATLAB/MATLAB_Runtime/v94/extern/bin/glnxa64


      EDIT



      the dependencies of C++ library file before setting the LD_LIBRARY_PATH:



      linux-vdso.so.1 (0x00007ffcee0dc000)
      libpython3.4m.so.1.0 => /usr/lib/x86_64-linux-gnu/libpython3.4m.so.1.0 (0x00007f9d69e59000)
      libboost_python-py34.so.1.55.0 => /usr/lib/x86_64-linux-gnu/libboost_python-py34.so.1.55.0 (0x00007f9d69c09000)
      libstdc++.so.6 => /usr/lib/x86_64-linux-gnu/libstdc++.so.6 (0x00007f9d698fe000)
      libm.so.6 => /lib/x86_64-linux-gnu/libm.so.6 (0x00007f9d695fd000)
      libgcc_s.so.1 => /lib/x86_64-linux-gnu/libgcc_s.so.1 (0x00007f9d693e7000)
      libc.so.6 => /lib/x86_64-linux-gnu/libc.so.6 (0x00007f9d6903c000)
      librt.so.1 => /lib/x86_64-linux-gnu/librt.so.1 (0x00007f9d68e34000)
      libexpat.so.1 => /lib/x86_64-linux-gnu/libexpat.so.1 (0x00007f9d68c0b000)
      libz.so.1 => /lib/x86_64-linux-gnu/libz.so.1 (0x00007f9d689f0000)
      libpthread.so.0 => /lib/x86_64-linux-gnu/libpthread.so.0 (0x00007f9d687d3000)
      libdl.so.2 => /lib/x86_64-linux-gnu/libdl.so.2 (0x00007f9d685cf000)
      libutil.so.1 => /lib/x86_64-linux-gnu/libutil.so.1 (0x00007f9d683cc000)
      /lib64/ld-linux-x86-64.so.2 (0x00007f9d6a6c3000)


      After setting the LD_LIBRARY_PATH:



      linux-vdso.so.1 (0x00007ffc42e9b000)
      libpython3.4m.so.1.0 => /usr/lib/x86_64-linux-gnu/libpython3.4m.so.1.0 (0x00007fad9635b000)
      libboost_python-py34.so.1.55.0 => /usr/lib/x86_64-linux-gnu/libboost_python-py34.so.1.55.0 (0x00007fad9610b000)
      libstdc++.so.6 => /usr/local/MATLAB/MATLAB_Runtime/v94/sys/os/glnxa64/libstdc++.so.6 (0x00007fad95d8a000)
      libm.so.6 => /lib/x86_64-linux-gnu/libm.so.6 (0x00007fad95a89000)
      libgcc_s.so.1 => /usr/local/MATLAB/MATLAB_Runtime/v94/sys/os/glnxa64/libgcc_s.so.1 (0x00007fad95873000)
      libc.so.6 => /lib/x86_64-linux-gnu/libc.so.6 (0x00007fad954c8000)
      librt.so.1 => /lib/x86_64-linux-gnu/librt.so.1 (0x00007fad952c0000)
      libexpat.so.1 => /usr/local/MATLAB/MATLAB_Runtime/v94/bin/glnxa64/libexpat.so.1 (0x00007fad95095000)
      libz.so.1 => /lib/x86_64-linux-gnu/libz.so.1 (0x00007fad94e7a000)
      libpthread.so.0 => /lib/x86_64-linux-gnu/libpthread.so.0 (0x00007fad94c5d000)
      libdl.so.2 => /lib/x86_64-linux-gnu/libdl.so.2 (0x00007fad94a59000)
      libutil.so.1 => /lib/x86_64-linux-gnu/libutil.so.1 (0x00007fad94856000)
      /lib64/ld-linux-x86-64.so.2 (0x00007fad96bc5000)






      environment-variables matlab paths boost






      share|improve this question















      share|improve this question













      share|improve this question




      share|improve this question








      edited Aug 17 at 13:02

























      asked Aug 15 at 11:57









      Coderji

      266




      266






















          3 Answers
          3






          active

          oldest

          votes

















          up vote
          2
          down vote



          +50










          This Stack Exchange Q&A has various ways of setting LD_LIBRARY_PATH the top voted answer suggests this is the best way:



          sudo -H gedit /etc/ld.so.conf.d/randomLibs.conf


          inside the file you are supposed to write the complete path to the directory that contains all the libraries that you wish to add to the system, for example



          /home/linux/myLocalLibs


          remember to add only the path to the dir, not the full path for the file, all the libs inside that path will be automatically indexed.



          Save and run sudo ldconfig to update the system with this libs.






          share|improve this answer




























            up vote
            1
            down vote













            Do you have to export the LD_LIBRARY_PATH? can't you just preface the matlab call with it, e.g.



            LD_LIBRARY_PATH=$LD_LIBRARY_PATH:/usr/local/MATLAB/MATLAB_Runtime/v94/runtime/glnxa64:/usr/local/MATLAB/MATLAB_Runtime/v94/bin/glnxa64:/usr/local/MATLAB/MATLAB_Runtime/v94/sys/os/glnxa64:/usr/local/MATLAB/MATLAB_Runtime/v94/extern/bin/glnxa64 /usr/local/MATLAB/MATLAB_Runtime/...


            (I do not exactly know what the executable is called like)



            You could put that in a little skript



            Secondly, it could be possible to change the rpath of the executable or some library, so it looks at the correct place directly. I use patchelf for this



            patchelf --set-rpath 


            Since there are multiple paths involved it could get a bit tricky, though






            share|improve this answer





















            • Thanks for your answer, the preface didn't work with me.. I am trying to do the patchelf but it seems complicated. And in the future I might have many C++ classes.. wouldn't this mean that I will need to do it for all of them?
              – Coderji
              Aug 17 at 13:53










            • you would have to do this for every executable / shared library. But If you compile them yourself you must be able to set this at compile time ( or link time to be precise)
              – mbeyss
              Aug 17 at 14:03


















            up vote
            0
            down vote



            accepted










            The only way it worked for me is by defining LD_PRELOAD and point it to system library. So my current environment would be:



            LD_LIBRARY_PATH=/usr/local/MATLAB/MATLAB_Runtime/v94/runtime/glnxa64:/usr/local/MATLAB/MATLAB_Runtime/v94/bin/glnxa64:/usr/local/MATLAB/MATLAB_Runtime/v94/sys/os/glnxa64:/usr/local/MATLAB/MATLAB_Runtime/v94/extern/bin/glnxa64:/usr/local/MATLAB/MATLAB_Runtime/v94/sys/opengl/lib/glnxa64
            LD_PRELOAD=/usr/lib/x86_64-linux-gnu/libexpat.so


            So in docker, I have created a .matlab file that contains the mentioned env variables. Then, in dockerfile I added the following:



            services:
            django: &django
            build:
            context: .
            dockerfile: ./compose/local/django/Dockerfile
            depends_on:
            - postgres
            volumes:
            - .:/app
            - shared_upload_tmp:/app_temp
            - media:/app/computation_server/media
            env_file:
            - ./.envs/.local/.django
            - ./.envs/.local/.postgres
            - ./.envs/.production/.matlab
            ports:
            - "8800:8000"
            command: /start





            share|improve this answer





















              Your Answer








              StackExchange.ready(function() {
              var channelOptions = {
              tags: "".split(" "),
              id: "89"
              };
              initTagRenderer("".split(" "), "".split(" "), channelOptions);

              StackExchange.using("externalEditor", function() {
              // Have to fire editor after snippets, if snippets enabled
              if (StackExchange.settings.snippets.snippetsEnabled) {
              StackExchange.using("snippets", function() {
              createEditor();
              });
              }
              else {
              createEditor();
              }
              });

              function createEditor() {
              StackExchange.prepareEditor({
              heartbeatType: 'answer',
              convertImagesToLinks: true,
              noModals: true,
              showLowRepImageUploadWarning: true,
              reputationToPostImages: 10,
              bindNavPrevention: true,
              postfix: "",
              imageUploader: {
              brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
              contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
              allowUrls: true
              },
              onDemand: true,
              discardSelector: ".discard-answer"
              ,immediatelyShowMarkdownHelp:true
              });


              }
              });














               

              draft saved


              draft discarded


















              StackExchange.ready(
              function () {
              StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2faskubuntu.com%2fquestions%2f1065557%2fset-ld-library-path-correctly%23new-answer', 'question_page');
              }
              );

              Post as a guest















              Required, but never shown

























              3 Answers
              3






              active

              oldest

              votes








              3 Answers
              3






              active

              oldest

              votes









              active

              oldest

              votes






              active

              oldest

              votes








              up vote
              2
              down vote



              +50










              This Stack Exchange Q&A has various ways of setting LD_LIBRARY_PATH the top voted answer suggests this is the best way:



              sudo -H gedit /etc/ld.so.conf.d/randomLibs.conf


              inside the file you are supposed to write the complete path to the directory that contains all the libraries that you wish to add to the system, for example



              /home/linux/myLocalLibs


              remember to add only the path to the dir, not the full path for the file, all the libs inside that path will be automatically indexed.



              Save and run sudo ldconfig to update the system with this libs.






              share|improve this answer

























                up vote
                2
                down vote



                +50










                This Stack Exchange Q&A has various ways of setting LD_LIBRARY_PATH the top voted answer suggests this is the best way:



                sudo -H gedit /etc/ld.so.conf.d/randomLibs.conf


                inside the file you are supposed to write the complete path to the directory that contains all the libraries that you wish to add to the system, for example



                /home/linux/myLocalLibs


                remember to add only the path to the dir, not the full path for the file, all the libs inside that path will be automatically indexed.



                Save and run sudo ldconfig to update the system with this libs.






                share|improve this answer























                  up vote
                  2
                  down vote



                  +50







                  up vote
                  2
                  down vote



                  +50




                  +50




                  This Stack Exchange Q&A has various ways of setting LD_LIBRARY_PATH the top voted answer suggests this is the best way:



                  sudo -H gedit /etc/ld.so.conf.d/randomLibs.conf


                  inside the file you are supposed to write the complete path to the directory that contains all the libraries that you wish to add to the system, for example



                  /home/linux/myLocalLibs


                  remember to add only the path to the dir, not the full path for the file, all the libs inside that path will be automatically indexed.



                  Save and run sudo ldconfig to update the system with this libs.






                  share|improve this answer












                  This Stack Exchange Q&A has various ways of setting LD_LIBRARY_PATH the top voted answer suggests this is the best way:



                  sudo -H gedit /etc/ld.so.conf.d/randomLibs.conf


                  inside the file you are supposed to write the complete path to the directory that contains all the libraries that you wish to add to the system, for example



                  /home/linux/myLocalLibs


                  remember to add only the path to the dir, not the full path for the file, all the libs inside that path will be automatically indexed.



                  Save and run sudo ldconfig to update the system with this libs.







                  share|improve this answer












                  share|improve this answer



                  share|improve this answer










                  answered Aug 19 at 14:30









                  WinEunuuchs2Unix

                  39.2k1063145




                  39.2k1063145
























                      up vote
                      1
                      down vote













                      Do you have to export the LD_LIBRARY_PATH? can't you just preface the matlab call with it, e.g.



                      LD_LIBRARY_PATH=$LD_LIBRARY_PATH:/usr/local/MATLAB/MATLAB_Runtime/v94/runtime/glnxa64:/usr/local/MATLAB/MATLAB_Runtime/v94/bin/glnxa64:/usr/local/MATLAB/MATLAB_Runtime/v94/sys/os/glnxa64:/usr/local/MATLAB/MATLAB_Runtime/v94/extern/bin/glnxa64 /usr/local/MATLAB/MATLAB_Runtime/...


                      (I do not exactly know what the executable is called like)



                      You could put that in a little skript



                      Secondly, it could be possible to change the rpath of the executable or some library, so it looks at the correct place directly. I use patchelf for this



                      patchelf --set-rpath 


                      Since there are multiple paths involved it could get a bit tricky, though






                      share|improve this answer





















                      • Thanks for your answer, the preface didn't work with me.. I am trying to do the patchelf but it seems complicated. And in the future I might have many C++ classes.. wouldn't this mean that I will need to do it for all of them?
                        – Coderji
                        Aug 17 at 13:53










                      • you would have to do this for every executable / shared library. But If you compile them yourself you must be able to set this at compile time ( or link time to be precise)
                        – mbeyss
                        Aug 17 at 14:03















                      up vote
                      1
                      down vote













                      Do you have to export the LD_LIBRARY_PATH? can't you just preface the matlab call with it, e.g.



                      LD_LIBRARY_PATH=$LD_LIBRARY_PATH:/usr/local/MATLAB/MATLAB_Runtime/v94/runtime/glnxa64:/usr/local/MATLAB/MATLAB_Runtime/v94/bin/glnxa64:/usr/local/MATLAB/MATLAB_Runtime/v94/sys/os/glnxa64:/usr/local/MATLAB/MATLAB_Runtime/v94/extern/bin/glnxa64 /usr/local/MATLAB/MATLAB_Runtime/...


                      (I do not exactly know what the executable is called like)



                      You could put that in a little skript



                      Secondly, it could be possible to change the rpath of the executable or some library, so it looks at the correct place directly. I use patchelf for this



                      patchelf --set-rpath 


                      Since there are multiple paths involved it could get a bit tricky, though






                      share|improve this answer





















                      • Thanks for your answer, the preface didn't work with me.. I am trying to do the patchelf but it seems complicated. And in the future I might have many C++ classes.. wouldn't this mean that I will need to do it for all of them?
                        – Coderji
                        Aug 17 at 13:53










                      • you would have to do this for every executable / shared library. But If you compile them yourself you must be able to set this at compile time ( or link time to be precise)
                        – mbeyss
                        Aug 17 at 14:03













                      up vote
                      1
                      down vote










                      up vote
                      1
                      down vote









                      Do you have to export the LD_LIBRARY_PATH? can't you just preface the matlab call with it, e.g.



                      LD_LIBRARY_PATH=$LD_LIBRARY_PATH:/usr/local/MATLAB/MATLAB_Runtime/v94/runtime/glnxa64:/usr/local/MATLAB/MATLAB_Runtime/v94/bin/glnxa64:/usr/local/MATLAB/MATLAB_Runtime/v94/sys/os/glnxa64:/usr/local/MATLAB/MATLAB_Runtime/v94/extern/bin/glnxa64 /usr/local/MATLAB/MATLAB_Runtime/...


                      (I do not exactly know what the executable is called like)



                      You could put that in a little skript



                      Secondly, it could be possible to change the rpath of the executable or some library, so it looks at the correct place directly. I use patchelf for this



                      patchelf --set-rpath 


                      Since there are multiple paths involved it could get a bit tricky, though






                      share|improve this answer












                      Do you have to export the LD_LIBRARY_PATH? can't you just preface the matlab call with it, e.g.



                      LD_LIBRARY_PATH=$LD_LIBRARY_PATH:/usr/local/MATLAB/MATLAB_Runtime/v94/runtime/glnxa64:/usr/local/MATLAB/MATLAB_Runtime/v94/bin/glnxa64:/usr/local/MATLAB/MATLAB_Runtime/v94/sys/os/glnxa64:/usr/local/MATLAB/MATLAB_Runtime/v94/extern/bin/glnxa64 /usr/local/MATLAB/MATLAB_Runtime/...


                      (I do not exactly know what the executable is called like)



                      You could put that in a little skript



                      Secondly, it could be possible to change the rpath of the executable or some library, so it looks at the correct place directly. I use patchelf for this



                      patchelf --set-rpath 


                      Since there are multiple paths involved it could get a bit tricky, though







                      share|improve this answer












                      share|improve this answer



                      share|improve this answer










                      answered Aug 17 at 13:14









                      mbeyss

                      618117




                      618117












                      • Thanks for your answer, the preface didn't work with me.. I am trying to do the patchelf but it seems complicated. And in the future I might have many C++ classes.. wouldn't this mean that I will need to do it for all of them?
                        – Coderji
                        Aug 17 at 13:53










                      • you would have to do this for every executable / shared library. But If you compile them yourself you must be able to set this at compile time ( or link time to be precise)
                        – mbeyss
                        Aug 17 at 14:03


















                      • Thanks for your answer, the preface didn't work with me.. I am trying to do the patchelf but it seems complicated. And in the future I might have many C++ classes.. wouldn't this mean that I will need to do it for all of them?
                        – Coderji
                        Aug 17 at 13:53










                      • you would have to do this for every executable / shared library. But If you compile them yourself you must be able to set this at compile time ( or link time to be precise)
                        – mbeyss
                        Aug 17 at 14:03
















                      Thanks for your answer, the preface didn't work with me.. I am trying to do the patchelf but it seems complicated. And in the future I might have many C++ classes.. wouldn't this mean that I will need to do it for all of them?
                      – Coderji
                      Aug 17 at 13:53




                      Thanks for your answer, the preface didn't work with me.. I am trying to do the patchelf but it seems complicated. And in the future I might have many C++ classes.. wouldn't this mean that I will need to do it for all of them?
                      – Coderji
                      Aug 17 at 13:53












                      you would have to do this for every executable / shared library. But If you compile them yourself you must be able to set this at compile time ( or link time to be precise)
                      – mbeyss
                      Aug 17 at 14:03




                      you would have to do this for every executable / shared library. But If you compile them yourself you must be able to set this at compile time ( or link time to be precise)
                      – mbeyss
                      Aug 17 at 14:03










                      up vote
                      0
                      down vote



                      accepted










                      The only way it worked for me is by defining LD_PRELOAD and point it to system library. So my current environment would be:



                      LD_LIBRARY_PATH=/usr/local/MATLAB/MATLAB_Runtime/v94/runtime/glnxa64:/usr/local/MATLAB/MATLAB_Runtime/v94/bin/glnxa64:/usr/local/MATLAB/MATLAB_Runtime/v94/sys/os/glnxa64:/usr/local/MATLAB/MATLAB_Runtime/v94/extern/bin/glnxa64:/usr/local/MATLAB/MATLAB_Runtime/v94/sys/opengl/lib/glnxa64
                      LD_PRELOAD=/usr/lib/x86_64-linux-gnu/libexpat.so


                      So in docker, I have created a .matlab file that contains the mentioned env variables. Then, in dockerfile I added the following:



                      services:
                      django: &django
                      build:
                      context: .
                      dockerfile: ./compose/local/django/Dockerfile
                      depends_on:
                      - postgres
                      volumes:
                      - .:/app
                      - shared_upload_tmp:/app_temp
                      - media:/app/computation_server/media
                      env_file:
                      - ./.envs/.local/.django
                      - ./.envs/.local/.postgres
                      - ./.envs/.production/.matlab
                      ports:
                      - "8800:8000"
                      command: /start





                      share|improve this answer

























                        up vote
                        0
                        down vote



                        accepted










                        The only way it worked for me is by defining LD_PRELOAD and point it to system library. So my current environment would be:



                        LD_LIBRARY_PATH=/usr/local/MATLAB/MATLAB_Runtime/v94/runtime/glnxa64:/usr/local/MATLAB/MATLAB_Runtime/v94/bin/glnxa64:/usr/local/MATLAB/MATLAB_Runtime/v94/sys/os/glnxa64:/usr/local/MATLAB/MATLAB_Runtime/v94/extern/bin/glnxa64:/usr/local/MATLAB/MATLAB_Runtime/v94/sys/opengl/lib/glnxa64
                        LD_PRELOAD=/usr/lib/x86_64-linux-gnu/libexpat.so


                        So in docker, I have created a .matlab file that contains the mentioned env variables. Then, in dockerfile I added the following:



                        services:
                        django: &django
                        build:
                        context: .
                        dockerfile: ./compose/local/django/Dockerfile
                        depends_on:
                        - postgres
                        volumes:
                        - .:/app
                        - shared_upload_tmp:/app_temp
                        - media:/app/computation_server/media
                        env_file:
                        - ./.envs/.local/.django
                        - ./.envs/.local/.postgres
                        - ./.envs/.production/.matlab
                        ports:
                        - "8800:8000"
                        command: /start





                        share|improve this answer























                          up vote
                          0
                          down vote



                          accepted







                          up vote
                          0
                          down vote



                          accepted






                          The only way it worked for me is by defining LD_PRELOAD and point it to system library. So my current environment would be:



                          LD_LIBRARY_PATH=/usr/local/MATLAB/MATLAB_Runtime/v94/runtime/glnxa64:/usr/local/MATLAB/MATLAB_Runtime/v94/bin/glnxa64:/usr/local/MATLAB/MATLAB_Runtime/v94/sys/os/glnxa64:/usr/local/MATLAB/MATLAB_Runtime/v94/extern/bin/glnxa64:/usr/local/MATLAB/MATLAB_Runtime/v94/sys/opengl/lib/glnxa64
                          LD_PRELOAD=/usr/lib/x86_64-linux-gnu/libexpat.so


                          So in docker, I have created a .matlab file that contains the mentioned env variables. Then, in dockerfile I added the following:



                          services:
                          django: &django
                          build:
                          context: .
                          dockerfile: ./compose/local/django/Dockerfile
                          depends_on:
                          - postgres
                          volumes:
                          - .:/app
                          - shared_upload_tmp:/app_temp
                          - media:/app/computation_server/media
                          env_file:
                          - ./.envs/.local/.django
                          - ./.envs/.local/.postgres
                          - ./.envs/.production/.matlab
                          ports:
                          - "8800:8000"
                          command: /start





                          share|improve this answer












                          The only way it worked for me is by defining LD_PRELOAD and point it to system library. So my current environment would be:



                          LD_LIBRARY_PATH=/usr/local/MATLAB/MATLAB_Runtime/v94/runtime/glnxa64:/usr/local/MATLAB/MATLAB_Runtime/v94/bin/glnxa64:/usr/local/MATLAB/MATLAB_Runtime/v94/sys/os/glnxa64:/usr/local/MATLAB/MATLAB_Runtime/v94/extern/bin/glnxa64:/usr/local/MATLAB/MATLAB_Runtime/v94/sys/opengl/lib/glnxa64
                          LD_PRELOAD=/usr/lib/x86_64-linux-gnu/libexpat.so


                          So in docker, I have created a .matlab file that contains the mentioned env variables. Then, in dockerfile I added the following:



                          services:
                          django: &django
                          build:
                          context: .
                          dockerfile: ./compose/local/django/Dockerfile
                          depends_on:
                          - postgres
                          volumes:
                          - .:/app
                          - shared_upload_tmp:/app_temp
                          - media:/app/computation_server/media
                          env_file:
                          - ./.envs/.local/.django
                          - ./.envs/.local/.postgres
                          - ./.envs/.production/.matlab
                          ports:
                          - "8800:8000"
                          command: /start






                          share|improve this answer












                          share|improve this answer



                          share|improve this answer










                          answered Nov 13 at 9:13









                          Coderji

                          266




                          266






























                               

                              draft saved


                              draft discarded



















































                               


                              draft saved


                              draft discarded














                              StackExchange.ready(
                              function () {
                              StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2faskubuntu.com%2fquestions%2f1065557%2fset-ld-library-path-correctly%23new-answer', 'question_page');
                              }
                              );

                              Post as a guest















                              Required, but never shown





















































                              Required, but never shown














                              Required, but never shown












                              Required, but never shown







                              Required, but never shown

































                              Required, but never shown














                              Required, but never shown












                              Required, but never shown







                              Required, but never shown







                              Popular posts from this blog

                              mysqli_query(): Empty query in /home/lucindabrummitt/public_html/blog/wp-includes/wp-db.php on line 1924

                              How to change which sound is reproduced for terminal bell?

                              Can I use Tabulator js library in my java Spring + Thymeleaf project?