thodan/bop_renderer

Building error

greatwallet opened this issue · 5 comments

Environment

  • ubuntu 18.04
  • python 3.6

Error
Complete building successfully.
When trying to import bop_renderer in /path/to/bop_renderer/lib, the message displays as:

>>> import os
>>> os.listdir('./')
['3rd', 'bop_renderer.cpython-36m-x86_64-linux-gnu.so', 'Makefile', 'CMakeFiles', 'cmake_install.cmake', 'CMakeCache.txt']
>>> import bop_renderer
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
ImportError: libLLVMX86Disassembler.so.4: cannot open shared object file: No such file or directory

Hi, I've encountered the same problem and fixed it by setting environment variables.
Specifically,

export LD_LIBRARY_PATH="{path/to/LLVM/library}:{path/to/osmesa/library}"

Hope this helps!

Hi, I've encountered the same problem and fixed it by setting environment variables.
Specifically,

export LD_LIBRARY_PATH="{path/to/LLVM/library}:{path/to/osmesa/library}"

Hope this helps!

Hi! Thanks for the advice, but I don't think it's working.
Actually, I looked into bop_renderer/CMakeLists.txt, and found that it has nothing to do with LLVM library. I tried to add following lines to CMakeLists.txt:

...

# llvm
set(LLVM_LIBRARIES $ENV{LLVM_PREFIX}/lib/libLLVMX86Disassembler.so.4)
include_directories($ENV{LLVM_PREFIX}/include)

...

# try to link LLVM library here
link_directories(${LLVM_PREFIX}/lib)
target_link_libraries(bop_renderer PRIVATE ${OSMESA_LIBRARIES} PRIVATE ${LLVM_LIBRARIES}

After doing compilation job, however, same error occurs as ImportError: libLLVMX86Disassembler.so.4: cannot open shared object file: No such file or directory

Also, I've tried to copy libLLVMX86Disassembler.so.4 directly to bop_renderer/build but still in vain ;(

I am curious that @kimbochen did you build it successfully with python 2.7 or 3.6? Currently bop_renderer only supports python==3.6 right now. I think I may have to trace the old commits of this repo and rebuild it.

OK, Problem Solved!
Solution
Copy all library files to your library path of your python environment.
Take myself as an example, I use anaconda as my python environment

cp /path/to/llvm/lib/*.so* /path/to/anaconda3/envs/${your_environment_name}/lib

After doint this, I successfully running bop_renderer/samples/renderer_minimal.py without bugs.

Nevertheless I don't think it's a elegant solution, @thodan @MartinSmeyer would you please take some time to look into this and provide a clean way to solve this?

I think adding this into ~/.bashrc would also make it work:
export LD_LIBRARY_PATH=/opt/llvm/lib/:$LD_LIBRARY_PATH.

BTW, I can confirm that bop_renderer can at least be built with python 3.7, by changing the version in CMakeLists.txt.

Another helpful thing to do is to look where exactly this shared object is stored.
Typing:

locate libLLVMX86Disassembler.so.4

helped me find out that my shared object was in
/home/user/marzdr/bop_renderer/osmesa-install/build/llvm-4.0.1.src/build/lib/libLLVMX86Disassembler.so.4

Then I just added the lib directory to my LD_LIBRARY_PATH and it worked. You can also put it in your ~/.bashrc to automate the process.

export LD_LIBRARY_PATH=/home/user/marzdr/bop_renderer/osmesa-install/build/llvm-4.0.1.src/build/lib/:$LD_LIBRARY_PATH