nowrep / obs-vkcapture

OBS Linux Vulkan/OpenGL game capture
GNU General Public License v2.0
532 stars 25 forks source link

Doesn't work with 32bit games #30

Closed scaledteam closed 3 years ago

scaledteam commented 3 years ago

When trying to capture 32bit game, it doesn't want to load library:

ERROR: ld.so: object '/usr/lib/libobs_glcapture.so' from LD_PRELOAD cannot be preloaded (wrong ELF class: ELFCLASS64): ignored.

I tried to compile it with crossbuild-essential-i386, but it can't link some files to OBS.

scaled@librem-15:~/git/obs-vkcapture/build32$ LANG=C cmake -DCMAKE_INSTALL_PREFIX=/usr -DCMAKE_INSTALL_LIBDIR=lib -DCMAKE_CXX_COMPILER=/usr/bin/i686-linux-gnu-g++ -DCMAKE_CXX_COMPILER_AR=/usr/bin/i686-linux-gnu-ar -DCMAKE_CXX_COMPILER_RANLIB=/usr/bin/i686-linux-gnu-ranlib -DCMAKE_C_COMPILER=/usr/bin/i686-linux-gnu-gcc -DCMAKE_C_COMPILER_AR=/usr/bin/i686-linux-gnu-ar -DCMAKE_C_COMPILER_RANLIB=/usr/bin/i686-linux-gnu-ranlib ..
-- The C compiler identification is GNU 10.2.1
-- The CXX compiler identification is GNU 10.2.1
-- Detecting C compiler ABI info
-- Detecting C compiler ABI info - done
-- Check for working C compiler: /usr/bin/i686-linux-gnu-gcc - skipped
-- Detecting C compile features
-- Detecting C compile features - done
-- Detecting CXX compiler ABI info
-- Detecting CXX compiler ABI info - done
-- Check for working CXX compiler: /usr/bin/i686-linux-gnu-g++ - skipped
-- Detecting CXX compile features
-- Detecting CXX compile features - done
-- Found Vulkan: /usr/lib/i386-linux-gnu/libvulkan.so  
-- Could NOT find X11 (missing: X11_X11_LIB) 
-- Configuring done
-- Generating done
-- Build files have been written to: /home/scaled/git/obs-vkcapture/build32
scaled@librem-15:~/git/obs-vkcapture/build32$ LANG=C make
Scanning dependencies of target VkLayer_obs_vkcapture
[  9%] Building C object CMakeFiles/VkLayer_obs_vkcapture.dir/src/vklayer.c.o
/home/scaled/git/obs-vkcapture/src/vklayer.c: In function 'init_device_data':
/home/scaled/git/obs-vkcapture/src/vklayer.c:247:28: warning: cast from pointer to integer of different size [-Wpointer-to-int-cast]
  247 |     add_obj_data(&devices, (uint64_t)GET_LDT(device), data);
      |                            ^
/home/scaled/git/obs-vkcapture/src/vklayer.c: In function 'get_device_data':
/home/scaled/git/obs-vkcapture/src/vklayer.c:254:13: warning: cast from pointer to integer of different size [-Wpointer-to-int-cast]
  254 |             (uint64_t)GET_LDT(device));
      |             ^
/home/scaled/git/obs-vkcapture/src/vklayer.c: In function 'get_device_data_by_queue':
/home/scaled/git/obs-vkcapture/src/vklayer.c:260:13: warning: cast from pointer to integer of different size [-Wpointer-to-int-cast]
  260 |             (uint64_t)GET_LDT(queue));
      |             ^
/home/scaled/git/obs-vkcapture/src/vklayer.c: In function 'remove_device_data':
/home/scaled/git/obs-vkcapture/src/vklayer.c:266:13: warning: cast from pointer to integer of different size [-Wpointer-to-int-cast]
  266 |             (uint64_t)GET_LDT(device));
      |             ^
/home/scaled/git/obs-vkcapture/src/vklayer.c: In function 'add_queue_data':
/home/scaled/git/obs-vkcapture/src/vklayer.c:286:33: warning: cast from pointer to integer of different size [-Wpointer-to-int-cast]
  286 |     add_obj_data(&data->queues, (uint64_t)queue, queue_data);
      |                                 ^
/home/scaled/git/obs-vkcapture/src/vklayer.c: In function 'get_queue_data':
/home/scaled/git/obs-vkcapture/src/vklayer.c:298:13: warning: cast from pointer to integer of different size [-Wpointer-to-int-cast]
  298 |             (uint64_t)queue);
      |             ^
/home/scaled/git/obs-vkcapture/src/vklayer.c: In function 'init_inst_data':
/home/scaled/git/obs-vkcapture/src/vklayer.c:506:30: warning: cast from pointer to integer of different size [-Wpointer-to-int-cast]
  506 |     add_obj_data(&instances, (uint64_t)GET_LDT(instance), idata);
      |                              ^
/home/scaled/git/obs-vkcapture/src/vklayer.c: In function 'get_inst_data':
/home/scaled/git/obs-vkcapture/src/vklayer.c:513:13: warning: cast from pointer to integer of different size [-Wpointer-to-int-cast]
  513 |             (uint64_t)GET_LDT(instance));
      |             ^
/home/scaled/git/obs-vkcapture/src/vklayer.c: In function 'get_inst_data_by_physical_device':
/home/scaled/git/obs-vkcapture/src/vklayer.c:527:25: warning: cast from pointer to integer of different size [-Wpointer-to-int-cast]
  527 |             &instances, (uint64_t)GET_LDT(physicalDevice));
      |                         ^
/home/scaled/git/obs-vkcapture/src/vklayer.c: In function 'remove_free_inst_data':
/home/scaled/git/obs-vkcapture/src/vklayer.c:543:25: warning: cast from pointer to integer of different size [-Wpointer-to-int-cast]
  543 |             &instances, (uint64_t)GET_LDT(inst));
      |                         ^
[ 18%] Building C object CMakeFiles/VkLayer_obs_vkcapture.dir/src/capture.c.o
[ 27%] Linking C shared module libVkLayer_obs_vkcapture.so
[ 27%] Built target VkLayer_obs_vkcapture
Scanning dependencies of target obs_glcapture
[ 36%] Building C object CMakeFiles/obs_glcapture.dir/src/dlsym.c.o
[ 45%] Building C object CMakeFiles/obs_glcapture.dir/src/elfhacks.c.o
[ 54%] Building C object CMakeFiles/obs_glcapture.dir/src/glinject.c.o
[ 63%] Building C object CMakeFiles/obs_glcapture.dir/src/glad/glad.c.o
[ 72%] Building C object CMakeFiles/obs_glcapture.dir/src/capture.c.o
[ 81%] Linking C shared module libobs_glcapture.so
[ 81%] Built target obs_glcapture
Scanning dependencies of target linux-vkcapture
[ 90%] Building C object CMakeFiles/linux-vkcapture.dir/src/vkcapture.c.o
/home/scaled/git/obs-vkcapture/src/vkcapture.c: In function 'vkcapture_source_show':
/home/scaled/git/obs-vkcapture/src/vkcapture.c:205:9: warning: implicit declaration of function 'pthread_mutex_lock' [-Wimplicit-function-declaration]
  205 |         pthread_mutex_lock(&server.mutex);
      |         ^~~~~~~~~~~~~~~~~~
/home/scaled/git/obs-vkcapture/src/vkcapture.c:210:9: warning: implicit declaration of function 'pthread_mutex_unlock' [-Wimplicit-function-declaration]
  210 |         pthread_mutex_unlock(&server.mutex);
      |         ^~~~~~~~~~~~~~~~~~~~
/home/scaled/git/obs-vkcapture/src/vkcapture.c: In function 'obs_module_load':
/home/scaled/git/obs-vkcapture/src/vkcapture.c:620:5: warning: implicit declaration of function 'pthread_mutex_init' [-Wimplicit-function-declaration]
  620 |     pthread_mutex_init(&server.mutex, NULL);
      |     ^~~~~~~~~~~~~~~~~~
/home/scaled/git/obs-vkcapture/src/vkcapture.c:621:9: warning: implicit declaration of function 'pthread_create'; did you mean 'timer_create'? [-Wimplicit-function-declaration]
  621 |     if (pthread_create(&server.thread, NULL, server_thread_run, NULL) != 0) {
      |         ^~~~~~~~~~~~~~
      |         timer_create
/home/scaled/git/obs-vkcapture/src/vkcapture.c: In function 'obs_module_unload':
/home/scaled/git/obs-vkcapture/src/vkcapture.c:634:5: warning: implicit declaration of function 'pthread_join' [-Wimplicit-function-declaration]
  634 |     pthread_join(server.thread, NULL);
      |     ^~~~~~~~~~~~
[100%] Linking C shared module linux-vkcapture.so
/usr/lib/gcc-cross/i686-linux-gnu/10/../../../../i686-linux-gnu/bin/ld: /usr/lib/libobs.so.0: error adding symbols: file in wrong format
collect2: error: ld returned 1 exit status
make[2]: *** [CMakeFiles/linux-vkcapture.dir/build.make:104: linux-vkcapture.so] Error 1
make[1]: *** [CMakeFiles/Makefile2:153: CMakeFiles/linux-vkcapture.dir/all] Error 2
make: *** [Makefile:149: all] Error 2

But i still tried to preload some generated files and program just crashed, when i opened OBS.

LD_PRELOAD=/home/scaled/git/obs-vkcapture/build32/libobs_glcapture.so
/home/scaled/.steam/debian-installation/steamapps/common/Half-Life/hl.sh: line 43: 161106 Segmentation fault      ${DEBUGGER} "${GAMEROOT}"/${GAMEEXE} $@
nowrep commented 3 years ago

Try this to get a 32 bit build

https://github.com/nowrep/obs-vkcapture/blob/ee0be7240d6a38416018347b50379820cd4920d1/dist/PKGBUILD#L26-L36

scaledteam commented 3 years ago

Unfortunately it fails too. Also, now CS1.6 don't want to preload 32 bit library o.O Worms Ultimate Mayhem through wine (OpenGL) don't work too. 64bit games works fine.

GTA San Andreas now works through wine with dxvk, thank you for that.

Directly from terminal:

$ LD_PRELOAD=/home/scaled/git/obs-vkcapture/build32/libobs_glcapture.so ./hl.sh
ERROR: ld.so: object '/home/scaled/git/obs-vkcapture/build32/libobs_glcapture.so' from LD_PRELOAD cannot be preloaded (wrong ELF class: ELFCLASS32): ignored.
ERROR: ld.so: object '/home/scaled/git/obs-vkcapture/build32/libobs_glcapture.so' from LD_PRELOAD cannot be preloaded (wrong ELF class: ELFCLASS32): ignored.
[obs-vkcapture] Init 0.9.0
Using breakpad crash handler
Failed to initalize authentication interface. Exiting...

From Steam:

[obs-vkcapture] Texture GL_RGBA 1920x1080
assert_20210810113223_1.dmp[168475]: Uploading dump (out-of-process)
/tmp/dumps/assert_20210810113223_1.dmp
/home/scaled/.steam/debian-installation/steamapps/common/Half-Life/hl.sh: line 43: 168369 Segmentation fault      ${DEBUGGER} "${GAMEROOT}"/${GAMEEXE} $@
nowrep commented 3 years ago

You have to load the 32bit library to 32bit games and 64bit lib to 64bit games of course.

What is the PKGBUILD doing is to build both 32 and 64bit libraries and installs them system-wide (/usr/lib and /usr/lib32) which makes the LD_PRELOAD=libobs_glcapture.so choose the correct library to preload.

Library path may be different on your system, if you are on Debian it would be /usr/lib/x86_64-linux-gnu and /usr/lib/x86_32-linux-gnu.

scaledteam commented 3 years ago

Strange that CS 1.6 don't want to preload 32bit and 64bit libraries. But why?

ERROR: ld.so: object '/usr/lib/libobs_glcapture.so' from LD_PRELOAD cannot be preloaded (wrong ELF class: ELFCLASS64): ignored.
ERROR: ld.so: object '/home/scaled/git/obs-vkcapture/build32/libobs_glcapture.so' from LD_PRELOAD cannot be preloaded (wrong ELF class: ELFCLASS32): ignored.

Also, how to use pkgbuild properly? I just compiled program twice with cmake.

nowrep commented 3 years ago

Strange that CS 1.6 don't want to preload 32bit and 64bit libraries. But why?

I have no idea here, sorry.

Also, how to use pkgbuild properly? I just compiled program twice with cmake.

That's only for ArchLinux.

scaledteam commented 3 years ago

Ok, thank you. Will try to place library into /usr/lib/x86_32-linux-gnu later.

nowrep commented 3 years ago

If you are going to set LD_PRELOAD with absolute path to correct library, you don't really have to. It's only done like that so you can just use obs-glcapture %command% and it will work for both 32 and 64 bit.