Author Topic: Compiling with 32bit SDL lib on a 64 bit system.  (Read 3590 times)

overlord (OP)

  • *
  • Posts: 7
Compiling with 32bit SDL lib on a 64 bit system.
« on: January 25, 2014, 02:40:11 am »
I'm running a 64bit OS Arch linux. I have the 32 bit libs for sdl installed but do I need to pass a different argument to the compiler to specify to use the 32bit libs. I'm using the command:
Code: [Select]
mipsel-linux-g++ -o foo foo.cpp -lSDL
While it compiles fine it segfaults on the Zero. I know my code is good because if I compile for my OS is runs just dandy. But I'm curious if it's trying to build with the 64bit libs.

I know that typically I'd pass the -m32 option to g++ but since we're using the toolchain how do I do this or is my problem something totally different than this.
« Last Edit: January 25, 2014, 02:48:40 am by overlord »

pcercuei

  • ***
  • Posts: 1428
    • My devblog
Re: Compiling with 32bit SDL lib on a 64 bit system.
« Reply #1 on: January 25, 2014, 03:28:08 am »
This has the information you're looking for: http://wiki.gcw-zero.com/Makefile#Cross-compile_an_SDL_program

overlord (OP)

  • *
  • Posts: 7
Re: Compiling with 32bit SDL lib on a 64 bit system.
« Reply #2 on: January 25, 2014, 07:34:38 am »
Ok My brain is fried, I've been researching this all day. I can't for the life of me get anything to work right today. If I had hair it'd be on the floor right now. Folloing the abouve linked page, I set up a make file to compile my sdl test I created. I figure if I can get one thing going it may encourage me a bit to continue. It didn't compile. Compiles on my system, not the toolchain. Soooo, I made a simple hello world to test with, same problem. Following the page I have a makefile made, pretty much copied, lol.

Code: [Select]

TARGET := test
OBJS := test.o
CC := $(CROSS_COMPILE)g++

$(TARGET): $(OBJS)
$(CC) $(CPPFLAGS) $^ -o [email protected]

clean:
rm -f $(TARGET) $(OBJS)

But instead of it compiling, like the above linked page said, I get:

Code: [Select]
test.o: could not read symbols: File in wrong format
I figure it's using my system's ld but darned if I can figure out how to get it to stop.

I'm really starting to get discouraged. I just want to learn to code a bit for the Zero, but heck I can't even get something compiled for it if I did write it.

Ziz

  • *
  • Posts: 284
    • http://ziz.gp2x.de
Re: Compiling with 32bit SDL lib on a 64 bit system.
« Reply #3 on: January 25, 2014, 08:05:54 am »
First of all, I don't think, it has anything to do with your 64 or 32 bit SDL installed. In any case the SDL libraries of the gcw matter. I just compiled something within a 64 bit system just yesterday and it worked like a charm.

When you call your new fancy Makefile, what do you pass?
I think
Code: [Select]
make CC=/opt/gcw0-toolchain/usr/bin/mipsel-gcw0-linux-uclibc-should work.

Maybe you have already a compiled .o file (gcw format) and now you try to link it with your systems g++/ld (or the other way around).
So try
Code: [Select]
make cleanfor every new try to be sure. ;)

greetings, Ziz
I am a leaf on the wind - watch how I soar. Wash

pcercuei

  • ***
  • Posts: 1428
    • My devblog
Re: Compiling with 32bit SDL lib on a 64 bit system.
« Reply #4 on: January 25, 2014, 11:10:46 am »
If you use C++, replace "CC" by "CXX" in the Makefile.

overlord (OP)

  • *
  • Posts: 7
Re: Compiling with 32bit SDL lib on a 64 bit system.
« Reply #5 on: January 25, 2014, 03:35:10 pm »
If you use C++, replace "CC" by "CXX" in the Makefile.

That was it! You know I changed them to CXX at some point last night, But didn't change CFLAGS to CPPFLAGS. Changing both worked for me. Thanks.

Oh Zitz, you are correct about it using the toolchain's SDL. I wasn't thinking about it right.

overlord (OP)

  • *
  • Posts: 7
Re: Compiling with 32bit SDL lib on a 64 bit system.
« Reply #6 on: January 25, 2014, 05:01:53 pm »
Still no go. The source compiles but when run on the Zero I get... "Can't load library 'D1Ev'". What's weird is if I don't specify an output name with th -o option the a.out I get runs just fine. That blows my freaking mind. I'm done with this stuff for a while.

overlord (OP)

  • *
  • Posts: 7
Re: Compiling with 32bit SDL lib on a 64 bit system.
« Reply #7 on: January 25, 2014, 07:13:31 pm »
Ok I don't know what's going on here but look at this... I used the makefile and source for the vsync test from here... https://github.com/gcwnow/tests. Since it was confirmed to be working in this post... http://boards.dingoonity.org/gcw-development/newly-compiled-apps-%27killed%27-immediately-after-execution/. Here are my results.



Any clues as to what causes it? All of the binaries in the toolchain are executable.

edit: When I compile this for my desktop it runs great.

I get this when I use gdb on the binary on the Zero.





Edit : Ok I got it working. Apparently transfering the file with Filezilla is causing the issue. When I transfer using ftp in the cl it works perfectly. This is an odd issue.

« Last Edit: January 25, 2014, 08:29:17 pm by overlord »

Nebuleon

  • Guest
Re: Compiling with 32bit SDL lib on a 64 bit system.
« Reply #8 on: January 25, 2014, 10:47:36 pm »
Binary transfer mode. In FileZilla Client, go to Transfer / Transfer type / Binary.

Set it now before more of your transfers get corrupted.