Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Question about using obs-glcapture script for 32-bit programs #36

Open
scaledteam opened this issue Aug 21, 2021 · 19 comments
Open

Question about using obs-glcapture script for 32-bit programs #36

scaledteam opened this issue Aug 21, 2021 · 19 comments

Comments

@scaledteam
Copy link
Contributor

Hi again! obs-vkcapture got 32-bit programs support, but in Debian 11 it tricky to use. Obs-glcapture script don't preload 32-bit libraries in Debian, but LD_PRELOAD=/usr/local/lib/i686-linux-gnu/libobs_glcapture.so %command% works fine. I compiled and installed plugin using my own script. I used /usr/local prefix because my OBS compiled from source and installed into /usr/local.

#! /bin/bash

cmake -B build -S . -DCMAKE_INSTALL_PREFIX=/usr/local \
        -DCMAKE_INSTALL_LIBDIR=lib \
        -DCMAKE_INSTALL_DATADIR=/share \
        -DCMAKE_BUILD_TYPE=Release
make -C build

export CFLAGS="-m32 ${CFLAGS}"
export CXXFLAGS="-m32 ${CXXFLAGS}"
export LDFLAGS="-m32 ${LDFLAGS}"

echo $CFLAGS
cmake -B build32 -S . -DCMAKE_INSTALL_PREFIX=/usr/local \
	-DCMAKE_INSTALL_LIBDIR=lib/i686-linux-gnu \
	-DCMAKE_INSTALL_DATADIR=/share \
	-DCMAKE_LIBRARY_PATH=/usr/local/lib/i686-linux-gnu \
	-DCMAKE_BUILD_TYPE=Release \
	-DBUILD_PLUGIN=OFF
make -C build32

sudo checkinstall --default --pkgname=obs-studio-local-vkcapture --fstrans=no --backup=no --pkgversion="$(date +%Y%m%d)" --deldoc=yes sh -c 'make -C build install; make -C build32 install'

But whereis libobs_glcapture.so command shows only 64-bit library. I checked /etc/ld.so.conf.d/i386-linux-gnu.conf file and it said that /usr/local/lib/i686-linux-gnu directory is used by 'ldconfig', so 32-bit library must appear in whereis command output too.
/usr/local/lib/i686-linux-gnu:

# Multiarch support
/usr/local/lib/i386-linux-gnu
/lib/i386-linux-gnu
/usr/lib/i386-linux-gnu
/usr/local/lib/i686-linux-gnu
/lib/i686-linux-gnu
/usr/lib/i686-linux-gnu

So, how to make obs-glcapture script work for Debian 11?

@scaledteam
Copy link
Contributor Author

By the way, obs-vkcapture script works great for 64-bit and 32-bit games. Also, yesterday i tested latest release on my livestream and it works great for native programs, thank you!

@nowrep
Copy link
Owner

nowrep commented Aug 21, 2021

Have you run ldconfig? It's probably not in cache ldconfig -p | grep libobs_glcapture.

@scaledteam
Copy link
Contributor Author

Oops, i found old library from my previous install attempts. Now Garry's Mod and Counter Strike 1.6 (native) works fine with old library removed, but Serious Sam 2 and Worms Ultimate Mayhem through Wine still require LD_PRELOAD=/usr/local/lib/i686-linux-gnu/libobs_glcapture.so. Both games use OpenGL by design.

libobs_glcapture.so (libc6,x86-64) => /usr/local/lib/libobs_glcapture.so
libobs_glcapture.so (libc6) => /usr/local/lib/i686-linux-gnu/libobs_glcapture.so
libobs_glcapture.so (libc6) => /lib32/libobs_glcapture.so

@scaledteam
Copy link
Contributor Author

Thank you for advice, i didn't know about -p option in ldconfig. I think now it works properly for native apps, but not for wine.

@nowrep
Copy link
Owner

nowrep commented Aug 21, 2021

You can try LD_LIBRARY_PATH=/usr/local/lib/i686-linux-gnu if it helps.

@scaledteam
Copy link
Contributor Author

I added LD_LIBRARY_PATH=/usr/local/lib/i686-linux-gnu:$LD_LIBRARY_PATH into obs-glcapture script, but it doesn't help.

@scaledteam
Copy link
Contributor Author

Also interesting thing, if you launch Steam with obs-glcapture command, it looks and captures like that:
изображение

It also says many times this message, and steamwebhelper eats exactly 100% CPU (in htop) and don't close after closing Steam.

(steam:44948): LIBDBUSMENU-GLIB-WARNING **: 16:42:09.524: Trying to remove a child that doesn't believe we're it's parent.

When Steam launched with LD_PRELOAD=/usr/local/lib/i686-linux-gnu/libobs_glcapture.so steam, it captures great, but i can't open any game. It will be great i can just preload library in Steam and capture any game i want, but probably not possible now. I think that happend because Steam use mix of 32-bit and 64-bit components. Also, Veloren game (native Vulkan game) with Airshipper launcher (which also use Vulkan) works fine. I open launcher with obs-vkcapture and it captures both launcher and game.
изображение

@scaledteam
Copy link
Contributor Author

scaledteam commented Aug 23, 2021

@nowrep, i think that you answered my question, but obs-glcapture script still don't works perfect (works for anything i tested except wine. wine require LD_PRELOAD with full path to 32-bit library) Probably we need to post instructions to compile it in generic distro not only for native architecture, but also 32-bit version, and some tips and tricks how to enable capture if obs-glcapture script doesn't work for certain program.

@nowrep
Copy link
Owner

nowrep commented Aug 23, 2021

Probably would be a good idea to setup a blacklist same as mangohud does. It should "fix" the steam issue.

As for why obs-glcapture isn't working for you for 32bit apps, I really have no idea. It works for me on ArchLinux.

@nowrep
Copy link
Owner

nowrep commented Aug 23, 2021

Are you running it with Proton from Steam (so it runs in the Steam runtime)? Maybe the library isn't available from the sandbox.

@scaledteam
Copy link
Contributor Author

I tested more times on more programs and found that native wine works fine with obs-glcapture script, wine from steam require LD_PRELOAD=/usr/local/lib/i686-linux-gnu/libobs_glcapture.so to work with 32-bit OpenGL programs. But also, obs-vkcapture works fine for 32-bti directx apps (with dxvk, of course). Also native 32-bit apps from Steam works fine too with obs-glcapture So this is only Steam Proton issue with 32-bit OpenGL apps.

@nowrep
Copy link
Owner

nowrep commented Aug 23, 2021

Makes sense, your custom library path won't be available inside the sandbox. Vulkan capture works because steam runtime will make all Vulkan layers from host available in the sandbox.
To fix it I think it should be enough to install 32bit libobs_glcapture.so to your default system 32bit library path.

@nowrep
Copy link
Owner

nowrep commented Aug 24, 2021

Actually in Steam case the problem is in the dlsym, so blacklist won't help.

@gegoxaren
Copy link

Greetings!
Sorry to disturb you all, but I'm trying to build this on Debian 12 x86_64, but want to build the x86 library, using a modified version of the script provided above, but I get stuck.

Here is my version of the script, note that I've added random options that I found around the internet hoping it'd work, but alas it did not:

# ...
# ....
export CFLAGS="-m32 ${CFLAGS}"
export CXXFLAGS="-m32 ${CXXFLAGS}"
export LDFLAGS="-m32 ${LDFLAGS}"
export LD_LIBRARY_PATH=/usr/lib/i386-linux-gnu/:/usr/lib/gcc/i686-linux-gnu

echo $CFLAGS
cmake -B build32 -S . -DCMAKE_INSTALL_PREFIX=/usr/ \
	-DCMAKE_INSTALL_LIBDIR=/usr/lib/i386-linux-gnu/ \
	-DCMAKE_INSTALL_DATADIR=/usr/share/ \
	-DCMAKE_LIBRARY_PATH=/usr/lib/gcc/i686-linux-gnu/ \
	-DCMAKE_BUILD_TYPE=Release \
	-DBUILD_PLUGIN=OFF \
	-DCMAKE_LIBRARY_ARCHITECTURE=i386-linux-gnu
	-DCMAKE_SHARED_LINKER_FLAGS=-m32 \
	-DCMAKE_MODULE_LINKER_FLAGS=-m32 \
	-DFIND_LIBRARY_USE_LIB32_PATHS=TRUE \
	-DCMAKE_EXE_LINKER_FLAGS=-m32 \
	-DCMAKE_ASM-ATT_FLAGS=-m32 \
	-DCMAKE_C_COMPILER=gcc \
	-DCMAKE_CXX_COMPILER=gcc \
	-DCMAKE_LINKER=gcc
make -C build32

I get the following output:

$ LANG=C ./build.sh 
-m32
-- The C compiler identification is GNU 12.2.0
-- The CXX compiler identification is GNU 12.2.0
-- Detecting C compiler ABI info
-- Detecting C compiler ABI info - failed
-- Check for working C compiler: /usr/bin/cc
-- Check for working C compiler: /usr/bin/cc - broken
CMake Error at /usr/share/cmake-3.25/Modules/CMakeTestCCompiler.cmake:70 (message):
  The C compiler

    "/usr/bin/cc"

  is not able to compile a simple test program.

  It fails with the following output:

    Change Dir: /home/gego/svn/obs-vkcapture/master/build32/CMakeFiles/CMakeScratch/TryCompile-6xxTBh
    
    Run Build Command(s):/usr/bin/gmake -f Makefile cmTC_81517/fast && /usr/bin/gmake  -f CMakeFiles/cmTC_81517.dir/build.make CMakeFiles/cmTC_81517.dir/build
    gmake[1]: Entering directory '/home/gego/svn/obs-vkcapture/master/build32/CMakeFiles/CMakeScratch/TryCompile-6xxTBh'
    Building C object CMakeFiles/cmTC_81517.dir/testCCompiler.c.o
    /usr/bin/cc   -m32  -o CMakeFiles/cmTC_81517.dir/testCCompiler.c.o -c /home/gego/svn/obs-vkcapture/master/build32/CMakeFiles/CMakeScratch/TryCompile-6xxTBh/testCCompiler.c
    Linking C executable cmTC_81517
    /usr/bin/cmake -E cmake_link_script CMakeFiles/cmTC_81517.dir/link.txt --verbose=1
    /usr/bin/cc -m32  -m32  CMakeFiles/cmTC_81517.dir/testCCompiler.c.o -o cmTC_81517 
    /usr/bin/ld: skipping incompatible /usr/lib/gcc/x86_64-linux-gnu/12/libgcc.a when searching for -lgcc
    /usr/bin/ld: cannot find -lgcc: No such file or directory
    /usr/bin/ld: skipping incompatible /usr/lib/gcc/x86_64-linux-gnu/12/libgcc.a when searching for -lgcc
    /usr/bin/ld: cannot find -lgcc: No such file or directory
    collect2: error: ld returned 1 exit status
    gmake[1]: *** [CMakeFiles/cmTC_81517.dir/build.make:99: cmTC_81517] Error 1
    gmake[1]: Leaving directory '/home/gego/svn/obs-vkcapture/master/build32/CMakeFiles/CMakeScratch/TryCompile-6xxTBh'
    gmake: *** [Makefile:127: cmTC_81517/fast] Error 2
    
    

  

  CMake will not be able to correctly generate this project.
Call Stack (most recent call first):
  CMakeLists.txt:3 (project)


-- Configuring incomplete, errors occurred!
See also "/home/gego/svn/obs-vkcapture/master/build32/CMakeFiles/CMakeOutput.log".
See also "/home/gego/svn/obs-vkcapture/master/build32/CMakeFiles/CMakeError.log".
./build.sh: line 23: -DCMAKE_SHARED_LINKER_FLAGS=-m32: command not found
make: Entering directory '/home/gego/svn/obs-vkcapture/master/build32'
make: *** No targets specified and no makefile found.  Stop.
make: Leaving directory '/home/gego/svn/obs-vkcapture/master/build32'

as you can see, the linker is looking in the wrong place, and causes the whole build to fail. Any idea what can be done to make it work?

Thanks in advance,
Gego.

@nowrep
Copy link
Owner

nowrep commented Jun 21, 2023

You're probably missing lib32 dev packages.

@gegoxaren
Copy link

gegoxaren commented Jun 21, 2023

I installed lib32gcc-12-dev and lib32gcc-11-dev and output is the same.

Edit:
I installed lib32stdc++-12-dev and lib32stdc++-11-dev, and now it works... Just missing the Vulkan stuff...

Edit 2: I installed the following, I can continue a bit...
libvulkan-dev:i396 libopengl-dev:i386

But... Now I get this message:

CMake Error at /usr/share/cmake-3.25/Modules/FindPackageHandleStandardArgs.cmake:230 (message):
  Could NOT find OpenGL (missing: OPENGL_glx_LIBRARY)
Call Stack (most recent call first):
  /usr/share/cmake-3.25/Modules/FindPackageHandleStandardArgs.cmake:600 (_FPHSA_FAILURE_MESSAGE)
  /usr/share/cmake-3.25/Modules/FindOpenGL.cmake:443 (FIND_PACKAGE_HANDLE_STANDARD_ARGS)
  CMakeLists.txt:8 (find_package)

I do have the library installed:

$ sudo ldconfig -p | grep glx
	libxcb-glx.so.0 (libc6,x86-64) => /lib/x86_64-linux-gnu/libxcb-glx.so.0
	libxcb-glx.so.0 (libc6) => /lib/i386-linux-gnu/libxcb-glx.so.0

Last edit:
I needed libgl1-mesa-dev:i386 too... now it seems to compile.

So finally here are the libraries you need:
libvulkan-dev:i396 libopengl-dev:i386 libgl1-mesa-dev:i386 lib32stdc++-12-dev lib32stdc++-11-dev libobs0:i386

@Monsterovich
Copy link

The problem is that OBS no longer provides libraries for 32 bit, now you can't build a library for LD_PRELOAD.

@asdfghjkl403622
Copy link

Hey, I might be missing something, but obs-glcapture and obs-gamecapture do not work on tf2 after installing all the 32bit drivers. Mangohud seems to pick up on it just fine, and I've looked at the other github issue saying to install the 32bit vkcapture library, which I did through the aur. tf2 still does not get picked up by obs though. Am I reading something wrong or is there other information I can present? thanks

@nowrep
Copy link
Owner

nowrep commented Aug 30, 2023

You need to install 32bit obs-vkcapture package.

Check logs when launching the game with VK_LOADER_DEBUG=all env variable and it should tell you why the Vulkan layer wasn't loaded.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

5 participants