2
votes

I was trying to compile libSDL-1.2.14 for my mips platform.
But it was not successful.

These were the steps that I tried out :

  1. export PATH=/opt/mips-4.3/bin:$PATH
  2. Went inside the libSDL-1.2.14 source folder.
  3. Gave a "./configure --prefix=/usr/local/SDL_Lib --host=mips-linux-gnu"
  4. Executed the "make" command

This was the error received :

cc1: warning: include location "/usr/include" is unsafe for cross-compilation
./src/audio/dma/SDL_dmaaudio.c: In function 'DMA_WaitAudio': ./src/audio/dma/SDL_dmaaudio.c:167: error: can't find a register in class 'COP3_REGS' while reloading 'asm'
./src/audio/dma/SDL_dmaaudio.c:167: error: 'asm' operand has impossible constraints make: * [build/SDL_dmaaudio.lo] Error 1

But then i reconfigured the make file by giving the following commands :

  1. make clean
  2. ./configure --prefix=/usr/local/SDL_Lib --host=mips-linux-gnu CPPFLAGS=-I/opt/mips-4.3/mips-linux-gnu/libc/usr/include/
  3. make

NOTE : /opt/mips-4.3/mips-linux-gnu/libc/usr/include/ - This is the path where you can locate the select.h file for the mips Platform. It contains the definitions of the macros FD_ZERO and FD_SET.

Still I am getting the same error.

cc1: warning: include location "/usr/include" is unsafe for cross-compilation
./src/audio/dma/SDL_dmaaudio.c: In function 'DMA_WaitAudio':
./src/audio/dma/SDL_dmaaudio.c:167: error: can't find a register in class 'COP3_REGS' while reloading 'asm'
./src/audio/dma/SDL_dmaaudio.c:167: error: 'asm' operand has impossible constraints make: * [build/SDL_dmaaudio.lo] Error 1

Please help me with some valuable pointers.

Thanks,
Sen

1
About the "/usr/include" warning, it's usually easier to cross-compile from a chroot environment without access to your system headers.ninjalj

1 Answers

2
votes

First, don't set the path to the cross-compiler as the first part of your PATH, set it as last:

export PATH=$PATH:<path to cross-compiler>

It's safer this way. Second, run ./configure --help to get all the options. What that error message would say if it was smarter is the following:

  1. You're trying to cross-compile since you're setting the --host flag
  2. But you're not changing any of the other options for where to find includes and libs for the target environment
  3. I'm going to use /usr/include by default
  4. But that's for the host system which will not work when cross-compiling

Check what other configure options you need to set to tell the configure script where to find the .h files (includes) and the libraries for your target. These usually come with the cross-compiler that you download. Also, you should probably set the CROSS_COMPILE environment variable to the cross-compiler prefix before running configure. The prefix is the part before gcc in a cross-compiler, assuming you're using GCC as your cross-compiler.