3

Ok, so for a game I'm working on, my programmer has decided to use FreePascal with SDL, and has shown me that it works (though he is using a Linux OS and I'm not). I have tried multiple methods of linking the SDL2.dll and the accompanying header files to the Lazarus project, but none of them seem to be working. Here's what I've tried so far:

  1. Adding the .dlls to the project folder of the project I'm working with
  2. Adding the .dlls to the FPC "Units" folder in my OS
  3. Adding the .dlls path in the project options window
  4. Adding the .dlls folder directly in the fpc.cfg file:

searchpath for libraries

-FlC:\lazarus\fpc\$FPCVERSION/lib

-Fl/lib;/usr/lib

-FlC:\lazarus\fpc\$FPCVERSION/lib/$FPCTARGET

-FlC:\lazarus\fpc\$FPCVERSION/lib/$FPCTARGET/SDL2

searchpath for tools

-FDC:\lazarus\fpc\$FPCVERSION/bin/$FPCTARGET

So I do also have them in the Uses location:

uses

{$IFDEF UNIX}{$IFDEF UseCThreads}

cthreads,

{$ENDIF}{$ENDIF}

Classes, sysutils, SDL2, SDL2_ttf

Basically, how do I link the SDL2 library to Lazarus on a Windows 8 OS?

Nate H.
  • 31
  • 2

2 Answers2

0

I asume the target is Windows OS, otherwise the DLL is not going to work. Place SDL.dll in the application directory, this is the first place Windows looks for any DLL.

Define the functions as

function name(params: types); cdecl; external 'SDL.dll';

cdecl varies depending on the way the parameters are passed to the function. Hope this will get you started.

henry
  • 5,923
  • 29
  • 46
Herman
  • 11
  • 3
0

Basically he's telling you to use the Jedi headers which are fundamentally broken, and I'm probably the developer (or one of several that you were referencing here, put the dll file in the application directory. Your uses clause is correct, but you're forgetting a lot of units. You're going to be running into a lot of hiccups with that Library (sdl, and I've tried to work around a great deal of them) and I am not getting proper acknowledgement for doing so.

at this time I'm leaning into Cairo.

Microsoft (gh) is playing games with my source code. I found another git repository I will be uploading shortly.

look for Lazarus graphics. It's a misnomer right now because my lcl programming is not up to snuff, but I am getting there.

This should compile no problem with the Vs Studio or vs code application, which I understand hovers around 15 GB. (I can fit an entire Linux installation in that amount of space) .

You may have downloaded a 32-bit library on a 64-bit platform or vice versa and that will introduce a lot of serious issues.

The Jedi headers are the Pascal port (of c headers) for this implicit use, that you are trying to reference. Without them you're not getting anywhere.