libsdl-org / sdl12-compat

An SDL-1.2 compatibility layer that uses SDL 2.0 behind the scenes.
Other
196 stars 40 forks source link

[i386] testing and build instructions for i386 on amd64? #173

Closed arrowgent closed 2 years ago

arrowgent commented 2 years ago

linux

for i386 games without good source code (quake4) etc is there a method for cmake and instruction on the README to build a separate i386 library?

ldd quake4.x86|grep SDL libSDL-1.2.so.0 => /usr/lib/i386-linux-gnu/libSDL-1.2.so.0 (0xf7e7d000)

currently the instructions on an x86_64 environment build only an amd64 library.

im not a cmake build wizard, so a little help here so people wouldnt have to spend hours searching how to setup an i386 build

build both or build option during cmake output to:

build/lib32
build/lib64
sezero commented 2 years ago

Set CC to gcc -m32 maybe?

arrowgent commented 2 years ago

cmake -Bbuild -DCMAKE_C_FLAGS=-m32 -DCMAKE_BUILD_TYPE=Release .

this requires libsdl2-dev:i386 and a ton of packages, surprisingly i did not have already. though i dont normally compile i386 obviously it requires libsdl1.2-dev:i386 which i already have


cmake -Bbuild -DCMAKE_C_FLAGS=-m32 -DCMAKE_BUILD_TYPE=Release .

-- The C compiler identification is GNU 9.3.0
-- Detecting C compiler ABI info
-- Detecting C compiler ABI info - done
-- Check for working C compiler: /usr/bin/cc - skipped
-- Detecting C compile features
-- Detecting C compile features - done
-- Found SDL2: /usr/lib/i386-linux-gnu/libSDL2.so (found version "2.0.20") 
-- Found SDL2main: /usr/lib/i386-linux-gnu/libSDL2main.a (found version "2.0.20") 
-- Performing Test HAVE_WDECLARATION_AFTER_STATEMENT
-- Performing Test HAVE_WDECLARATION_AFTER_STATEMENT - Success
-- Performing Test HAVE_WERROR_DECLARATION_AFTER_STATEMENT
-- Performing Test HAVE_WERROR_DECLARATION_AFTER_STATEMENT - Success
-- Looking for immintrin.h
-- Looking for immintrin.h - found
-- Found OpenGL: /usr/lib/i386-linux-gnu/libOpenGL.so  found components: OpenGL 
-- Configuring done
-- Generating done
-- Build files have been written to: /home/build/libsdl12-compat/sdl12-compat/build

cmake --build build

[  1%] Building C object CMakeFiles/SDL.dir/src/SDL12_compat.c.o
[  2%] Linking C shared library libSDL-1.2.so
[  2%] Built target SDL
[  4%] Building C object CMakeFiles/SDLmain.dir/src/SDLmain/dummy/SDL_dummy_main.c.o
[  5%] Linking C static library libSDLmain.a
[  5%] Built target SDLmain
[  7%] Building C object CMakeFiles/checkkeys.dir/test/checkkeys.c.o
[  8%] Linking C executable checkkeys
[  8%] Built target checkkeys
[ 10%] Building C object CMakeFiles/graywin.dir/test/graywin.c.o
[ 11%] Linking C executable graywin
[ 11%] Built target graywin
[ 13%] Building C object CMakeFiles/loopwave.dir/test/loopwave.c.o
[ 14%] Linking C executable loopwave
[ 14%] Built target loopwave
[ 16%] Building C object CMakeFiles/testalpha.dir/test/testalpha.c.o
[ 17%] Linking C executable testalpha
[ 17%] Built target testalpha
[ 19%] Building C object CMakeFiles/testbitmap.dir/test/testbitmap.c.o
[ 20%] Linking C executable testbitmap
[ 20%] Built target testbitmap
[ 22%] Building C object CMakeFiles/testblitspeed.dir/test/testblitspeed.c.o
[ 23%] Linking C executable testblitspeed
[ 23%] Built target testblitspeed
[ 25%] Building C object CMakeFiles/testcdrom.dir/test/testcdrom.c.o
[ 26%] Linking C executable testcdrom
[ 26%] Built target testcdrom
[ 27%] Building C object CMakeFiles/testcursor.dir/test/testcursor.c.o
[ 29%] Linking C executable testcursor
[ 29%] Built target testcursor
[ 30%] Building C object CMakeFiles/testerror.dir/test/testerror.c.o
[ 32%] Linking C executable testerror
[ 32%] Built target testerror
[ 33%] Building C object CMakeFiles/testfile.dir/test/testfile.c.o
[ 35%] Linking C executable testfile
[ 35%] Built target testfile
[ 36%] Building C object CMakeFiles/testgamma.dir/test/testgamma.c.o
[ 38%] Linking C executable testgamma
[ 38%] Built target testgamma
[ 39%] Building C object CMakeFiles/testthread.dir/test/testthread.c.o
[ 41%] Linking C executable testthread
[ 41%] Built target testthread
[ 42%] Building C object CMakeFiles/testiconv.dir/test/testiconv.c.o
[ 44%] Linking C executable testiconv
[ 44%] Built target testiconv
[ 45%] Building C object CMakeFiles/testjoystick.dir/test/testjoystick.c.o
[ 47%] Linking C executable testjoystick
[ 47%] Built target testjoystick
[ 48%] Building C object CMakeFiles/testkeys.dir/test/testkeys.c.o
[ 50%] Linking C executable testkeys
[ 50%] Built target testkeys
[ 51%] Building C object CMakeFiles/testloadso.dir/test/testloadso.c.o
[ 52%] Linking C executable testloadso
[ 52%] Built target testloadso
[ 54%] Building C object CMakeFiles/testlock.dir/test/testlock.c.o
[ 55%] Linking C executable testlock
[ 55%] Built target testlock
[ 57%] Building C object CMakeFiles/testoverlay.dir/test/testoverlay.c.o
[ 58%] Linking C executable testoverlay
[ 58%] Built target testoverlay
[ 60%] Building C object CMakeFiles/testoverlay2.dir/test/testoverlay2.c.o
[ 61%] Linking C executable testoverlay2
[ 61%] Built target testoverlay2
[ 63%] Building C object CMakeFiles/testpalette.dir/test/testpalette.c.o
[ 64%] Linking C executable testpalette
[ 64%] Built target testpalette
[ 66%] Building C object CMakeFiles/testplatform.dir/test/testplatform.c.o
[ 67%] Linking C executable testplatform
[ 67%] Built target testplatform
[ 69%] Building C object CMakeFiles/testsem.dir/test/testsem.c.o
[ 70%] Linking C executable testsem
[ 70%] Built target testsem
[ 72%] Building C object CMakeFiles/testsprite.dir/test/testsprite.c.o
[ 73%] Linking C executable testsprite
[ 73%] Built target testsprite
[ 75%] Building C object CMakeFiles/testtimer.dir/test/testtimer.c.o
[ 76%] Linking C executable testtimer
[ 76%] Built target testtimer
[ 77%] Building C object CMakeFiles/testver.dir/test/testver.c.o
[ 79%] Linking C executable testver
[ 79%] Built target testver
[ 80%] Building C object CMakeFiles/testvidinfo.dir/test/testvidinfo.c.o
[ 82%] Linking C executable testvidinfo
[ 82%] Built target testvidinfo
[ 83%] Building C object CMakeFiles/testwin.dir/test/testwin.c.o
[ 85%] Linking C executable testwin
[ 85%] Built target testwin
[ 86%] Building C object CMakeFiles/testwm.dir/test/testwm.c.o
[ 88%] Linking C executable testwm
[ 88%] Built target testwm
[ 89%] Building C object CMakeFiles/threadwin.dir/test/threadwin.c.o
[ 91%] Linking C executable threadwin
[ 91%] Built target threadwin
[ 92%] Building C object CMakeFiles/torturethread.dir/test/torturethread.c.o
[ 94%] Linking C executable torturethread
[ 94%] Built target torturethread
[ 95%] Building C object CMakeFiles/testdyngl.dir/test/testdyngl.c.o
[ 97%] Linking C executable testdyngl
[ 97%] Built target testdyngl
[ 98%] Building C object CMakeFiles/testgl.dir/test/testgl.c.o
[100%] Linking C executable testgl
[100%] Built target testgl

build amd64 -rwxrwxr-x 1 build build 221936 Mar 17 08:05 libSDL-1.2.so.1.2.53*

compared i386 -rwxrwxr-x 1 build build 238056 Mar 17 10:59 libSDL-1.2.so.1.2.53*


verifying quake4 ln -s libSDL-1.2.so.1.2.53 libSDL-1.2.id.so.0 ldd quake4smp.x86|grep SDL libSDL-1.2.id.so.0 (0xf7d0f000)

ln -s libSDL-1.2.so.1.2.53 libSDL-1.2.so.0 ldd quake4.x86|grep SDL libSDL-1.2.so.0 => /home/games/quake4/libSDL-1.2.so.0 (0xf7ecc000)

--------------- R_InitOpenGL ----------------
Initializing SDL subsystem
Loading GL driver 'libGL.so.1' through SDL
SDL_ListModes:
1920x1080 1680x1050 1600x900 1440x900 1280x1024 1280x800 1280x720 1024x768 800x600 720x576 720x480 
720x400 640x480 
8/8/8/8 RGBA bits, 24 depth bits, 8 stencil bits
16 pixels multisampling

some notes on the readme? or we can leave it here for curious to search for. ideally i think when setting this option it could automatically setup a build32 or build/lib32 folder a few options in the cmake "if -DCMAKE_C_FLAGS=-m32 then build+32 = build32" https://github.com/libsdl-org/sdl12-compat/blob/main/CMakeLists.txt

so that if the i386/32bit flag is enabled it creates a build32 folder

sezero commented 2 years ago

cmake -Bbuild -DCMAKE_C_FLAGS=-m32 -DCMAKE_BUILD_TYPE=Release .

That CMAKE_C_FLAGS=-m32 doesn't overwrite any other CFLAGS we are setting but only adds to them, does it?

arrowgent commented 2 years ago

honestly i have no idea.

i ran testgl and testplatform then moved the library to quake4 and ran quake4.x86 with no issues

beyond it working i couldnt tell you what does what

also let me update the previous cmake output to include everything

sezero commented 2 years ago

honestly i have no idea.

make VERBOSE=1 should output with compiler command line (in a loud and ugly way.) Or, you can browse the generated CMakeFiles/SDL.dir/flags.make file.

arrowgent commented 2 years ago

flags.make

# CMAKE generated file: DO NOT EDIT!
# Generated by "Unix Makefiles" Generator, CMake Version 3.22

# compile C with /usr/bin/cc
C_DEFINES = -DSDL_EXPORTS -D_REENTRANT

C_INCLUDES = -I/usr/include/SDL2

C_FLAGS = -m32  -Wall -Wdeclaration-after-statement -Werror=declaration-after-statement -O3 -DNDEBUG -fPIC

attached output of make VERBOSE=1 make_v.txt

sezero commented 2 years ago

OK then, looks good to me.

Someone should add a note to readme (or to the cmake script itself.)

arrowgent commented 2 years ago

thanks for the writeup icculus!