PascalGameDevelopment/SDL2-for-Pascal

Problem with missing "SDL.dll" library and with the names of required libraries

flowCRANE opened this issue · 5 comments

  1. To handle sounds, the SDL2_mixer.pas unit and the SDL2_mixer.dll library are required. However, a program that uses functions from this unit requires the SDL_mixer.dll library, not SDL2_mixer.dll. Changing the name of this dll solves the problem, but the SDL should use original dll names, with 2 in dll filenames.

  2. The change of name described above is not enough. The second problem is that in addition to the SDL2.dll library, the SDL.dll library is also required, which is not available for download from the official SDL website. This problem can be solved simply by copying the SDL2.dll library and naming it SDL.dll. However, keeping two copies of the same library just for the program to run properly is just a madness.

Unfortunately, the sources contain the correct dll names (all of them with the SDL2_* prefix, and the main library is named SDL2.dll, so also correctly). If so, where is the problem?

Hi,

first off, thanks for all the detailed issues. Because of rare time, I'm not able to address all of them at once.

About this particular issue: I'm not able to reproduce it. - I am just using the SDL2 and SDL2_mixer files as shipped and it is not necessary to rename them. In our translantion code, as you pointed out, too, the names are written correctly.

What environment do you use to compile your programs?
Could you ship a short example code for me to test the behaviour?

About this particular issue: I'm not able to reproduce it. - I am just using the SDL2 and SDL2_mixer files as shipped and it is not necessary to rename them.

This would indicate that you already have SDL.dll and SDL_mixer.dll somewhere in your system directory (eg. in Windows\system32 folder), so the program doesn't report any problems with initialization. I need to deal with textures and sounds, so I'm using the following libraries:

  • SDL2.dll
  • SDL2_image.dll
  • SDL2_mixer.dll

When I run the program directly from executable file, I get the following message:

sdl problem

As you can see, application require SDL.dll library. If I copy the SDL2.dll file and rename it to SDL.dll, everything is fine, but the next problem is with sound library. After run the program, I get another error:

mixer problem

So now I have to rename SDL2_mixer.dll to SDL_mixer.dll and only then the application works correctly:

app is working

I don't know if this problem exists only for me, but evidently SDL refers to libraries with names that don't match those that can be downloaded from the official SDL website.

What environment do you use to compile your programs?

I always use Lazarus on the latest stable version and build projects with it. I'm currently using Lazarus version 2.0.12:

image

OS is Windows 10 64-bit — version 21H1, build 19043.1165 (all available updates installed).

Could you ship a short example code for me to test the behaviour?

Yep — SDL tester.zip

This archive contains a small program in which I test various SDL functions — window handling, rendering, sounds, and joystick support. I'm going to apply everything to my game design, which is why the application looks the way it does. Don't worry about the quality of the code, because it is quickly tested various things. The most important things about SDL are in the .lpr file (eg. SDL initialization).

This archive contains the full source code, all dlls, as well as the executable and resources (graphics, sounds, etc.).

suve commented

Your tester program contains a small, but critical, bug.

uses
  SDL2, SDL_Mixer, ...

You're pulling in SDL_Mixer, not SDL2_Mixer. You're not getting a "missing unit" error because FPC ships its own SDL1 units.

Damn, a typo crept in… Everything works fine after repairing the unit names in all uses sections. At least as far as the required libraries are concerned — unfortunately other problems exist (remaining issues) still. This issue can be closed, problem with unit names doesn't exists. Thank you for pointing out my mistake.

I'm glad, this is nothing more serious. :-)

Thanks, suve!