fbertola / bgfx-python

Python 3.7+ wrapper for the BGFX library. 🐍
BSD 2-Clause "Simplified" License
121 stars 6 forks source link

build fails on linux #6

Closed salotz closed 4 years ago

salotz commented 4 years ago

I was trying to build myself:

python setup.py build

Before this I had built binder myself (following the basic instructions just running build.py) and this install LLVM 6.0.1 instead of 4.0.0 which is in the build scripts, so I changed that to match.

And it fails with this:

[17/21] Linking CXX shared module shaderc.cpython-38-x86_64-linux-gnu.so
FAILED: shaderc.cpython-38-x86_64-linux-gnu.so 
: && /usr/bin/c++ -fPIC -std=c++14 -fPIC -D__STDC_FORMAT_MACROS -D__STDC_LIMIT_MACROS -D__STDC_CONSTANT_MACROS -DNDEBUG -ffast-math -fomit-frame-pointer -fno-var-tracking-assignments -g -O3 -msse2  -O3 -DNDEBUG  -lrt -ldl -lglut -lGLU -lGL -lm  -Wl,--unresolved-symbols=ignore-all -Wl,--version-script="/home/salotz/tree/personal/projects/tutorials/python.bgfx/bgfx-python/_skbuild/linux-x86_64-3.8/cmake-build/CMakeFiles/shaderc-version-script.map" -shared  -o shaderc.cpython-38-x86_64-linux-gnu.so CMakeFiles/shaderc.dir/home/salotz/tree/personal/projects/tutorials/python.bgfx/bgfx-python/dependencies/bgfx/tools/shaderc/shaderc_glsl.cpp.o CMakeFiles/shaderc.dir/home/salotz/tree/personal/projects/tutorials/python.bgfx/bgfx-python/dependencies/bgfx/tools/shaderc/shaderc_hlsl.cpp.o CMakeFiles/shaderc.dir/home/salotz/tree/personal/projects/tutorials/python.bgfx/bgfx-python/dependencies/bgfx/tools/shaderc/shaderc_metal.cpp.o CMakeFiles/shaderc.dir/home/salotz/tree/personal/projects/tutorials/python.bgfx/bgfx-python/dependencies/bgfx/tools/shaderc/shaderc_pssl.cpp.o CMakeFiles/shaderc.dir/home/salotz/tree/personal/projects/tutorials/python.bgfx/bgfx-python/dependencies/bgfx/tools/shaderc/shaderc_spirv.cpp.o CMakeFiles/shaderc.dir/home/salotz/tree/personal/projects/tutorials/python.bgfx/bgfx-python/dependencies/bgfx/src/vertexlayout.cpp.o CMakeFiles/shaderc.dir/home/salotz/tree/personal/projects/tutorials/python.bgfx/bgfx-python/dependencies/bgfx/src/shader_spirv.cpp.o CMakeFiles/shaderc.dir/shaderc_python.cpp.o CMakeFiles/shaderc.dir/shaderc_module.cpp.o  /home/salotz/tree/personal/projects/tutorials/python.bgfx/bgfx-python/src/../dependencies/bgfx/.build/linux64_gcc/bin/libbxRelease.a  /home/salotz/tree/personal/projects/tutorials/python.bgfx/bgfx-python/src/../dependencies/bgfx/.build/linux64_gcc/bin/libfcppRelease.a  /home/salotz/tree/personal/projects/tutorials/python.bgfx/bgfx-python/src/../dependencies/bgfx/.build/linux64_gcc/bin/libglslangRelease.a  /home/salotz/tree/personal/projects/tutorials/python.bgfx/bgfx-python/src/../dependencies/bgfx/.build/linux64_gcc/bin/libglsl-optimizerRelease.a  /home/salotz/tree/personal/projects/tutorials/python.bgfx/bgfx-python/src/../dependencies/bgfx/.build/linux64_gcc/bin/libspirv-optRelease.a  /home/salotz/tree/personal/projects/tutorials/python.bgfx/bgfx-python/src/../dependencies/bgfx/.build/linux64_gcc/bin/libspirv-crossRelease.a && cd /home/salotz/tree/personal/projects/tutorials/python.bgfx/bgfx-python/_skbuild/linux-x86_64-3.8/cmake-build && /usr/bin/strip -s /home/salotz/tree/personal/projects/tutorials/python.bgfx/bgfx-python/_skbuild/linux-x86_64-3.8/cmake-build/shaderc.cpython-38-x86_64-linux-gnu.so
/usr/bin/ld: cannot find -lglut
collect2: error: ld returned 1 exit status
[19/21] Building CXX object CMakeFiles/bgfx_lib.dir/bgfx_python.cpp.o
ninja: build stopped: subcommand failed.
Traceback (most recent call last):
  File "/home/salotz/.pyenv/versions/tutorial.python.bgfx/lib/python3.8/site-packages/skbuild/setuptools_wrap.py", line 589, in setup
    cmkr.make(make_args, env=env)
  File "/home/salotz/.pyenv/versions/tutorial.python.bgfx/lib/python3.8/site-packages/skbuild/cmaker.py", line 496, in make
    raise SKBuildError(

An error occurred while building with CMake.
  Command:
    cmake --build . --target install --config Release --
  Source directory:
    /home/salotz/tree/personal/projects/tutorials/python.bgfx/bgfx-python
  Working directory:
    /home/salotz/tree/personal/projects/tutorials/python.bgfx/bgfx-python/_skbuild/linux-x86_64-3.8/cmake-build
Please see CMake's output for more information.

I think the important line is:

/usr/bin/ld: cannot find -lglut
fbertola commented 4 years ago

Hi @salotz! You didn't speficy the linux distro but, assuming you're using Ubuntu/Debian, just install these dependencies:

$ sudo apt-get install freeglut3-dev mesa-utils libglew-dev libglu-dev
salotz commented 4 years ago

Hi! Yes you assumed right :) This worked for me to build but now I am getting errors when I import. Before I start posting traces what is your setup? And are you currently able to build on HEAD and if so exactly how from a clean pull?

Do you have to build the bindings before running python setup.py install?

Still trying to figure out how this system is actually put together without knowing anything about bgfx or pybind :P

fbertola commented 4 years ago

My setup for Linux is a CentOS machine and the compiler is Clang. GCC is way pickyer on the linking order and that could be the problem. If you could share the log I can fix the setup for GCC.

fbertola commented 4 years ago

Closing for lack of further details.