LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   Programming (https://www.linuxquestions.org/questions/programming-9/)
-   -   Compiling 32-bit SDL on a 64-bit machine (https://www.linuxquestions.org/questions/programming-9/compiling-32-bit-sdl-on-a-64-bit-machine-896859/)

MTK358 08-11-2011 07:35 PM

Compiling 32-bit SDL on a 64-bit machine
 
How do I compile a 32-bit version of SDL so that 32-bit applications will use it? The reason I want to do this is because the version in the Arch repository isn't the newest, and doesn't directly support PulseAudio. I'm hoping that this will fix some issues I'm having.

markush 08-12-2011 11:58 AM

Hello MTK358,

I cannot answer your question, but the documentation for CLFS (Cross-Linux-From-Scratch) is known to be excellent: http://trac.cross-lfs.org/

hope this helps

Markus

MTK358 08-12-2011 12:16 PM

Just to be clear, I'm not compiling for another 32-bit machine, I'm compiling them to run in this one (which has multilib installed) so that 32-bit applications running on it will use the library I compiled.

Is the link you posted still relavent for this?

markush 08-12-2011 12:19 PM

You may look at AlienBobs multilib-packages for Slackware. They provide to compile packages for 32-bit machines: http://alien.slackbook.org/dokuwiki/...kware:multilib
There may be explanations which point you in the right direction.

Markus

MTK358 08-12-2011 01:18 PM

That doesn't explain how to compile 32-bit compatibility packages, but how to use Slackware-specific tools to convert 32-bit Slackware packages into 32-bit compatibility packages for a multilib system.

I guess I could modify the 32-bit Arch packages in a similar way, but Arch works differently: it has /usr/lib and /usr/lib32, not /usr/lib64 and /usr/lib.

Also, I see that SDL is split into multiple packages, such as sdl_image, sdl_mixer, etc.. When I compile the SDL package downloaded for the SDL website, does it come with all of these? Will just running "make install" install all of them?

markush 08-12-2011 02:36 PM

You could as well install Arch 32bit in a virtual machine and use this for package building.

Markus

MTK358 08-12-2011 02:43 PM

Quote:

Originally Posted by markush (Post 4441169)
You could as well install Arch 32bit in a virtual machine and use this for package building.

AFAIK, 32-bit Arch puts 32-bit libraries into /usr/lib, and 64-bit Arch puts 64-bit libraries into /usr/lib.

Another thing I wanted to ask:

Code:

$ env | egrep 'LD|LIB'
TK_LIBRARY=/usr/lib
TIX_LIBRARY=
LIBGL_DRIVERS_PATH=/usr/lib/xorg/modules/dri/
LD_LIBRARY_PATH=/opt/opencascade/lib:/home/michael/GNUstep/Library/Libraries:/usr/lib
TCL_LIBRARY=/usr/lib
TCLLIBPATH=/usr/lib
LIBRARY_COMBO=gnu-gnu-gnu
ITK_LIBRARY=/usr/lib
ITCL_LIBRARY=/usr/lib

I see that LD_LIBRARY_PATH contains paths to 64-bit libraries, but there is nothing that says where 32-bit libraries are. How does it know where to get the libraries if I start a 32-bit application that uses shared libraries?

markush 08-12-2011 03:09 PM

When I look at the Arch-Wiki https://wiki.archlinux.org/index.php...side_Arch64.3F I understand that they have a similar approach as AlienBob's multilib for Slackware. I'm not a programmer, but hopfully you'll find an answer to your question in the link.

Markus

MTK358 08-12-2011 04:03 PM

Quote:

Originally Posted by markush (Post 4441189)
When I look at the Arch-Wiki https://wiki.archlinux.org/index.php...side_Arch64.3F I understand that they have a similar approach as AlienBob's multilib for Slackware. I'm not a programmer, but hopfully you'll find an answer to your question in the link.

That link talks about having basically a separate 32-bit system that you can chroot into in a directory under your 64-bit system (https://wiki.archlinux.org/index.php...d_32bit_system), not about multilib.

I think I'll report this thread to be moved to the Programming forum.

archtoad6 08-12-2011 04:20 PM

MTK358,

While compiling is often part of writing s/w, it can also be part of the installation process. That is the case here. I don't think Programming is the right home for this thread, especially since you are getting answers here.

markush 08-12-2011 04:25 PM

Quote:

Originally Posted by archtoad6 (Post 4441247)
...
especially since you are getting answers here.

Well, he's only got answers from me, but I'm not a programmer and did not really get the question.

And I'm not sure as well if it is a programming-question or not. Actually it is more distribution-specific, but the Arch-forum here at LQ has not that much frequency. Maybe an Arch-only forum would be a better place for this question.

@MTK358: good luck :)

Markus

Tinkster 08-12-2011 05:38 PM

Moved to programming @ OPs request.

MTK358 08-13-2011 01:33 PM

I wrote this PKGBUILD:

Code:

pkgname=lib32-sdl
pkgver=1.2.14
pkgrel=1
arch=(x86_64)
url="http://www.libsdl.org"
source=("http://www.libsdl.org/release/SDL-${pkgver}.tar.gz")
sha1sums=(ba625b4b404589b97e92d7acd165992debe576dd)

build() {
    cd "$srcdir/SDL-$pkgver"
    CFLAGS=-m32 CXXFLAGS=-m32 LDFLAGS=-m32 ./configure --prefix=/usr
    CFLAGS=-m32 CXXFLAGS=-m32 LDFLAGS=-m32 make
    make DESTDIR="$pkgdir" install

    # rename /usr/lib to /usr/lib32 and delete everything else
    mv "$pkgdir/usr/lib" "$pkgdir/lib32"
    rm -r "$pkgdir/usr/*"
    mv "$pkgdir/lib32" "$pkgdir/usr"
}

But when I run makepkg, it prints this error message and quits:

Code:

./src/video/SDL_RLEaccel.c: Assembler messages:
./src/video/SDL_RLEaccel.c:831: Error: unsupported for `movq'
./src/video/SDL_RLEaccel.c:831: Error: unsupported for `movq'
./src/video/SDL_RLEaccel.c:831: Error: unsupported for `movq'
./src/video/SDL_RLEaccel.c:831: Error: unsupported for `movq'
./src/video/SDL_RLEaccel.c:930: Error: unsupported for `movq'
./src/video/SDL_RLEaccel.c:930: Error: unsupported for `movq'
./src/video/SDL_RLEaccel.c:930: Error: unsupported for `movq'
./src/video/SDL_RLEaccel.c:930: Error: unsupported for `movq'
make: *** [build/SDL_RLEaccel.lo] Error 1
==> ERROR: A failure occurred in build().
    Aborting...

How do I fix it?

And two other questions:

How do I find out the dependencies so that I can put them in the PKGBUILD?

Will the package created by this PKGBUILD be equivanent to installing just the "sdl" package, or the "sdl" package and all of the "sdl_*" (i.e. sdl_image, sdl_mixer, etc.) packages?

markush 08-13-2011 02:00 PM

Hi MTK358,

I'm playing a bit with Arch :)

I've installed x86_64 with multilib. I get the same error when using your PKGBUILD, but it compiles properly when using .configure && make in the sources. I suppose you have a mistake in the CFLAGS or LDFLAGS.

Markus

MTK358 08-13-2011 02:06 PM

Quote:

Originally Posted by markush (Post 4442016)
it compiles properly when using .configure && make in the sources. I suppose you have a mistake in the CFLAGS or LDFLAGS.

Do you mean this:

Code:

./configure
make

or this:

Code:

CFLAGS=-m32 CXXFLAGS=-m32 LDFLAGS=-m32 ./configure
CFLAGS=-m32 CXXFLAGS=-m32 LDFLAGS=-m32 make

?

Note that if I remove all those variables from the ./configure line (but still leave them on the make line), it compiles successfully, but file says that the resulting libraries are 64-bit.


All times are GMT -5. The time now is 03:10 PM.