Announcement

Collapse
No announcement yet.

.so libraries not linking correctly when I try to build a plugin

Collapse
X
 
  • Filter
  • Time
  • Show
Clear All
new posts

  • .so libraries not linking correctly when I try to build a plugin

    I'm trying to get a V-Ray repo started at work so I can start making some custom texture plugins. I'm working with Linux CentOS Linux release 7.4.1708 (Core), Maya 2018.4.P07, V-Ray Next for Maya, update 1 (v4.12.01.29159), building with rez.

    I'm trying to start with a simple example, the Fresnel texture plugin, but it seems that any .so library I point to in CMakeLists.txt isn't getting found when I load my plugin from Maya's plug-in manager:

    Code:
    // Error: file: /library/rez/ext_packages/app_maya/2018.4.7.2/platform-linux/ext/scripts/others/pluginWin.mel line 290: Unable to dynamically load : /net_home/shane.simms/local_packages/testing/0.0.1/platform-
    linux/app_maya-2018/plugins/testing.so
    libVRaySDKLibrary.so: cannot open shared object file: No such file or directory //
    // Error: file: /library/rez/ext_packages/app_maya/2018.4.7.2/platform-linux/ext/scripts/others/pluginWin.mel line 290: libVRaySDKLibrary.so: cannot open shared object file: No such file or directory (testing) //
    This only crops up when I use .so libraries (libVRaySDKLibrary.so in this case) - .a libraries don't give me any error messages.

    The following is a simplified CMakeLists.txt, which only has one .so library, which gives me the above error (sorry, can't upload files from work so have to dump it here):

    Code:
    CMAKE_MINIMUM_REQUIRED(VERSION 3.3)
    set(CMAKE_VERBOSE_MAKEFILE ON)
    
    # this is the cmake module used to build maya plugins
    include($ENV{DEVKIT_LOCATION}/cmake/pluginEntry.cmake)
    include_directories(/net_home/shane.simms/git/testing/include)
    include_directories(/net_home/shane.simms/git/testing/vraymaya/texfresnel/)
    include_directories(/library/rez/ext_packages/vray_maya/4.12.01.29159.0/platform-linux/app_maya-2018/vray/include)
    
    # set project
    set(PROJECT_NAME testing)
    set(CMAKE_STATIC_LIBRARY_PREFIX "")
    
    # set SOURCE_FILES
    set(
        SOURCE_FILES
            vray/vray_texfresnel/tex_fresnel.cpp
            vraymaya/texfresnel/maya_pluginmain.cpp
            vraymaya/texfresnel/maya_tex_fresnel.cpp
    )
    
    set(treeparser_s_PATH "/library/rez/ext_packages/vray_maya/4.12.01.29159.0/platform-linux/app_maya-2018/vray/lib/libtreeparser_s.a")
    set(plugman_s_PATH "/library/rez/ext_packages/vray_maya/4.12.01.29159.0/platform-linux/app_maya-2018/vray/lib/libplugman_s.a")
    set(jpeg_s_PATH "/library/rez/ext_packages/vray_maya/4.12.01.29159.0/platform-linux/app_maya-2018/vray/lib/libjpeg_s.a")
    set(partio_s_PATH "/library/rez/ext_packages/vray_maya/4.12.01.29159.0/platform-linux/app_maya-2018/vray/lib/libpartio_s.a")
    set(VRaySDKLibrary_PATH "/library/rez/ext_packages/vray_maya/4.12.01.29159.0/platform-linux/app_maya-2018/vray/lib/libVRaySDKLibrary.so") # so
    set(imagesamplers_s_PATH "/library/rez/ext_packages/vray_maya/4.12.01.29159.0/platform-linux/app_maya-2018/vray/lib/libimagesamplers_s.a")
    set(putils_s_PATH "/library/rez/ext_packages/vray_maya/4.12.01.29159.0/platform-linux/app_maya-2018/vray/lib/libputils_s.a")
    set(tiff_s_PATH "/library/rez/ext_packages/vray_maya/4.12.01.29159.0/platform-linux/app_maya-2018/vray/lib/libtiff_s.a")
    set(bmputils_s_PATH "/library/rez/ext_packages/vray_maya/4.12.01.29159.0/platform-linux/app_maya-2018/vray/lib/libbmputils_s.a")
    set(meshes_s_PATH "/library/rez/ext_packages/vray_maya/4.12.01.29159.0/platform-linux/app_maya-2018/vray/lib/libmeshes_s.a")
    set(rayserver_s_PATH "/library/rez/ext_packages/vray_maya/4.12.01.29159.0/platform-linux/app_maya-2018/vray/lib/librayserver_s.a")
    set(vrmat_s_PATH "/library/rez/ext_packages/vray_maya/4.12.01.29159.0/platform-linux/app_maya-2018/vray/lib/libvrmat_s.a")
    set(alembic_s_PATH "/library/rez/ext_packages/vray_maya/4.12.01.29159.0/platform-linux/app_maya-2018/vray/lib/libalembic_s.a")
    set(glvm_s_PATH "/library/rez/ext_packages/vray_maya/4.12.01.29159.0/platform-linux/app_maya-2018/vray/lib/libglvm_s.a")
    set(vrscene_s_PATH "/library/rez/ext_packages/vray_maya/4.12.01.29159.0/platform-linux/app_maya-2018/vray/lib/libvrscene_s.a")
    set(libpng_s_PATH "/library/rez/ext_packages/vray_maya/4.12.01.29159.0/platform-linux/app_maya-2018/vray/lib/liblibpng_s.a")
    set(meshinfosubdivider_s_PATH "/library/rez/ext_packages/vray_maya/4.12.01.29159.0/platform-linux/app_maya-2018/vray/lib/libmeshinfosubdivider_s.a")
    set(osdCPU_s_PATH "/library/rez/ext_packages/vray_maya/4.12.01.29159.0/platform-linux/app_maya-2018/vray/lib/libosdCPU_s.a")
    set(pimglib_s_PATH "/library/rez/ext_packages/vray_maya/4.12.01.29159.0/platform-linux/app_maya-2018/vray/lib/libpimglib_s.a")
    set(openexr_s_PATH "/library/rez/ext_packages/vray_maya/4.12.01.29159.0/platform-linux/app_maya-2018/vray/lib/libopenexr_s.a")
    set(vutils_s_PATH "/library/rez/ext_packages/vray_maya/4.12.01.29159.0/platform-linux/app_maya-2018/vray/lib/libvutils_s.a")
    set(geolib_s_PATH "/library/rez/ext_packages/vray_maya/4.12.01.29159.0/platform-linux/app_maya-2018/vray/lib/libgeolib_s.a")
    set(pnet_s_PATH "/library/rez/ext_packages/vray_maya/4.12.01.29159.0/platform-linux/app_maya-2018/vray/lib/libpnet_s.a")
    set(ptex_s_PATH "/library/rez/ext_packages/vray_maya/4.12.01.29159.0/platform-linux/app_maya-2018/vray/lib/libptex_s.a")
    set(curl_s_PATH "/library/rez/ext_packages/vray_maya/4.12.01.29159.0/platform-linux/app_maya-2018/vray/lib/libcurl_s.a")
    set(VRAYMAYA_LIB "/library/rez/ext_packages/vray_maya/4.12.01.29159.0/platform-linux/app_maya-2018/vray/lib")
    
    # add_executable(main vraymaya/texfresnel/maya_pluginmain.cpp)
    # target_link_libraries(main /library/rez/ext_packages/vray_maya/4.12.01.29159.0/platform-linux/app_maya-2018/vray/lib/libplugman_s.a)
    set(
        LIB_DIRS
            ${VRAYMAYA_LIB}
    )
    
    # Load libraries
    link_directories(${LIB_DIRS})
    # set required libraries
    set(
        LIBRARIES
            OpenMaya
            Foundation
            treeparser_s
            plugman_s
            resman_s
            jpeg_s
            partio_s
            VRaySDKLibrary # so
            imagesamplers_s
            putils_s
            tiff_s
            bmputils_s
            meshes_s
            rayserver_s
            vrmat_s
            alembic_s
            glvm_s
            vrscene_s
            libpng_s
            meshinfosubdivider_s
            osdCPU_s
            pimglib_s
            openexr_s
            vutils_s
            geolib_s
            pnet_s
            ptex_s
            curl_s
    )
    # Build the plugin
    build_plugin()
    # install the plugins
    install(
        TARGETS
            testing
        DESTINATION
            plugins
    )
    install(
        FILES
            shaders/vraytexfresnel.txt
        DESTINATION
            shaders
    )
    # rez-2.18 onwards doesn't provide a default install target
    # we have to provide a phony one
    install(CODE "")
    Any advice on this would be hugely appreciated, please let me know if there are any details I missed out.

  • #2
    Hi,

    Please try to add the absolute directories of any .so files to the LD_LIBRARY_PATH env var prior to launching Maya from the terminal e.g.:

    Code:
    export LD_LIBRARY_PATH=/library/rez/ext_packages/vray_maya/4.12.01.29159.0/platform-linux/app_maya-2018/vray/lib/
    Then run Maya from the same terminal

    Comment


    • #3
      Thanks for your response!

      I've ensured that LD_LIBRARY_PATH is pointing to the correct place, and have spent some time cleaning up CMakeLists.txt, but still getting errors.

      New CMakeLists.txt:

      Code:
      CMAKE_MINIMUM_REQUIRED(VERSION 3.3)
      set(CMAKE_VERBOSE_MAKEFILE ON)
      
      
      # this is the cmake module used to build maya plugins
      include($ENV{DEVKIT_LOCATION}/cmake/pluginEntry.cmake)
      
      # set project
      set(PROJECT_NAME testing)
      
      # vray_maya include dir
      include_directories($ENV{REZ_VRAY_MAYA_ROOT}/vray/include)
      
      # set source files
      set(
          SOURCE_FILES
              vray/vray_texfresnel/tex_fresnel.cpp
              vraymaya/texfresnel/maya_pluginmain.cpp
              vraymaya/texfresnel/maya_tex_fresnel.cpp
      )
      
      # set library dirs
      set(
          LIBRARY_DIRS
              $ENV{REZ_VRAY_MAYA_ROOT}/vray/lib
             $ENV{REZ_VRAY_MAYA_ROOT}/maya_root/lib
      )
      
      # set required libraries
      set(
          LIBRARIES
              OpenMaya
              Foundation
              treeparser_s
              plugman_s
              resman_s
              jpeg_s
              partio_s
              VRaySDKLibrary
              imagesamplers_s
              nvrtc
              putils_s
              vray
              tiff_s
              vrayfreeimage
              vraymdl
              bmputils_s
              meshes_s
              rayserver_s
              vrmat_s
              alembic_s
              vrayosl
              glvm_s
              vrscene_s
              libpng_s
              vray_gpu_common
              nvrtc-builtins
              meshinfosubdivider_s
              osdCPU_s
              pimglib_s
              openexr_s
              vutils_s
              vrayopenimageio
              geolib_s
              pnet_s
              ptex_s
              curl_s
      )
      
      # Build the plugin
      build_plugin()
      
      # install the plugins
      install(
          TARGETS
              testing
          DESTINATION
              plugins
      )
      
      install(
          FILES
              shaders/vraytexfresnel.txt
          DESTINATION
              shaders
      )
      
      
      # rez-2.18 onwards doesn't provide a default install target
      # we have to provide a phony one
      install(CODE "")
      Now Maya is complaining that libnvrtc.so is missing, I assume it wasn't complaining about it before because I wasn't including it, but the missing libraries are always the .so ones for some reason.
      Last edited by shaneasimms; 01-04-2020, 12:06 AM.

      Comment


      • #4
        Hi,

        I'm assuming the first error is hopefully solved.
        The Maya error appears to be of the same kind - the Maya executable can not find the library, which contains executable code it needs to use while running.

        Since this library is part of Nvidia CUDA toolkit, first make sure it's installed properly.
        If this is already done, I suggest to look for the library location and make sure the OS is aware of it. One way is again to add it in the LD_LIBRARY_PATH var, using the : separator.

        Also check this thread for more thorough guide about dynamic libs:
        https://unix.stackexchange.com/quest...cts-at-runtime

        Hope this helps. If you have more issues, please let me know.

        Comment


        • #5
          Sorry Asparuh, I wasn't very clear. The first error isn't solved, I made sure LD_LIBRARY_PATH was getting set correctly and all libraries were being pointed to but was still getting the errors. It's not just CUDA libraries, it's still everything with an .so extension that isn't being found.

          If I remove the CUDA stuff, Maya gives an undefined symbol error, for
          Code:
          VUtils::GetNumDescs()
          - I believe that this is part of VRaySDKLibrary.

          I'm not very experienced with cmake so apologies if I'm missing anything here. I've had several TDs at work take a look at this and no-one can figure out why I'm getting these errors.

          Thanks for the thread, I've had a read through but as I said, I'm quite sure LD_LIBRARY_PATH is pointing to the .so libraries. Is there anything else I could be missing?

          Comment


          • #6
            Hi, Shane

            Meanwhile you can check our cmake project that comes with the installation (samples subfolder) and see if you like it. It's an end-user cmake sample project. We support this one. See if it gives you errors.
            The one that you use is Maya devkit based and might have some issues as we don't support it. Also it's a bit hard to reporoduce it on my side as the files you provide are not the complete set.
            Try our sample project and let me know if that works for you.

            Regards

            Comment

            Working...
            X