1

I'm using gcc-linaro-arm-linux-gnueabihf-4.8-2014.04_linux to cross compile the following SDL code. usingubuntu-14.04

#include "SDL/SDL.h" 




int main( int argc, char* args[] ) {
//The images 
SDL_Surface* hello = NULL; 
SDL_Surface* screen = NULL;

//Start SDL 
SDL_Init( SDL_INIT_EVERYTHING ); 
//Set up screen
screen = SDL_SetVideoMode( 640, 480, 32, SDL_SWSURFACE ); 
//Load image
hello = SDL_LoadBMP( "Canada-Flag.bmp" );


//Apply image to screen
SDL_BlitSurface( hello, NULL, screen, NULL ); 
//Update Screen SDL_Flip( screen ); 
//Pause 
SDL_Delay( 2000 );




//Free the loaded image 
SDL_FreeSurface( hello ); 
//Quit SDL 
SDL_Quit();
return 0; 
} 

I'm compiling the code by using the following command.

arm-linux-gnueabihf-gcc -o /home/samples/display1 /home/samples/display1.c -lSDL

following is the error whai i get it after that.

/usr/lib/gcc-cross/arm-linux-gnueabihf/4.8/../../../../arm-linux-gnueabihf/bin/ld:  cannot find -lSDL collect2: error: ld returned 1 exit status

But the same code if i compile it for the host computer with.

gcc -o /home/samples/display1 /home/samples/display1.c -lSDL

it gives no errors and works well.

Please can you suggest.

0

You are missing the setup of the link path, like: -L/path/to/libswithsdl then -lSDL

example:

arm-none-linux-gnueabi-gcc -I./thirdparty/sdl/include -L./thirdparty/sdl/lib ./src/main.c -o ./out/main

the lib folder must contain the .so files so you are just adding to the search path, this will be fine for linking.

You need to make sure to have the lib on the target, either push it with the executable, use rpath or set LD_LIBRARY_PATH to include that search path

New contributor
David is a new contributor to this site. Take care in asking for clarification, commenting, and answering. Check out our Code of Conduct.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.