Edy81
Posts: 7
Joined: Fri Mar 21, 2014 9:48 am
Location: Spain

Freepascal error with SDL

Fri Mar 21, 2014 10:04 am

How can I compile this ?

program sdltest;
{$linklib gcc}
{$linklib SDLmain}
uses sdl;
var
scr: PSDL_Surface; // Our main screen
begin
SDL_Init(SDL_INIT_VIDEO); // Initialize the video SDL subsystem
scr:=SDL_SetVideoMode(640, 480, 8, SDL_SWSURFACE); // Create a software window of 640x480x8 and assign to scr
SDL_Quit; // close the subsystems and SDL
end.

yes is the demo at the wiki of lazarus

they say use

fpc -Fu<pathtosdl.pas files> -Fi<pathtosdl.inc files> example.pas

but I don't know where are the inc files and the error is something can't find
lgcc

My FPC install is without lazarus I plan to use raspberry just with keyboard so I'm just on a terminal no x11
Raspberrypi model B with usb hub of 4 ports, wifi
Os Arch / Raspbian

Thaddy
Posts: 174
Joined: Wed Mar 06, 2013 11:28 am

Re: Freepascal error with SDL

Fri Mar 21, 2014 7:51 pm

First, you have to check where libggc.a is installed.
You can find it by typing;
sudo / -name libgcc.a

It is probably in /usr/lib.
In that case type:
export GCCLIBDIR=/usr/lib

Now fpc will be able to find GCC.
Let me know what the next error is.
Otherwise install FPC2.7.1 from http://freepascal.thaddy.co.uk/raspberrypi.html
and try again.
The versions on my website are almost never more than a few days old and may help.

mob-i-l
Posts: 267
Joined: Sat Dec 29, 2012 2:45 am
Location: Lund, Skåne/Scania, Sweden
Contact: Website Facebook Google+ Twitter YouTube

Re: Freepascal error with SDL

Thu Mar 17, 2016 3:21 pm

I can compile and run the example if i remove the line with gcc. I discovered it's possible to also remove the line with SDLmain. I added a 5 s delay so I can see the window.

Code: Select all

program sdltest;
uses sdl;
var 
  scr: PSDL_Surface; // Our main screen
begin
  SDL_Init(SDL_INIT_VIDEO); // Initialize the video SDL subsystem
  scr:=SDL_SetVideoMode(640, 480, 8, SDL_SWSURFACE); // Create a software window of 640x480x8 and assign to scr
  SDL_Delay(5000);
  SDL_Quit; // close the subsystems and SDL
end.
I installed fpc using sudo apt-get install lazarus-ide-gtk2 (I had to fix some things manually after installation to get Lazarus IDE to work with code completion -- YMMV). I first installed the SDL-libraries following http://pp4s.co.uk/main/gs-pi-sdl.html. I have downloaded SDL-headers in the directory above my project using git clone https://github.com/ev1313/Pascal-SDL-1.2-Headers.git. I compile with:
fpc -Fu../Pascal-SDL-1.2-Headers/ -Fi../Pascal-SDL-1.2-Headers/ sdltest.pas and run with ./sdltest. This example works both with and without X-Windows. The other SDL-examples on PP4S also worked.
Have Pi0&1A&1B&1B+&2B&3B&4B w/ Raspbian. Started w/ BASIC on ABC80&ZX81 then Forth, Z80… https://scratch.mit.edu/users/mobluse/ https://github.com/mobluse/ https://twitter.com/mobluse/ https://YouTube.com/MOBiL4u/

Return to “Other programming languages”