ev1313 / Pascal-SDL-2-Headers

These are the Pascal SDL 2 Headers.
Mozilla Public License 2.0
113 stars 48 forks source link

Unit names not recognized correctly in Linux? #30

Closed Free-Pascal-meets-SDL-Website closed 7 years ago

Free-Pascal-meets-SDL-Website commented 8 years ago

A reader reported this (ref):

Had some weird results on Linux with the SDL2 units, had to rename them to use lowercase prefixes (i.e sdl2_image instead of SDL2_image). The project using the units would build fine in Lazarus, but code completion (ctrl+space) triggered errors (unit not found), and compiling from command line also reported errors about missing units. Might be the same case on OSX, haven’t tried it yet.

I guess it has to do with the case sensitivity of file names in Linux. At the moment I can't try it out myself.

frostney commented 8 years ago

I believe that's the case because the unit names themselves are lowercased in the files themselves. If the unit name would be SDL2_image in the file itself, this would work as expected and may be a better choice than lowercasing all the filenames.

Free-Pascal-meets-SDL-Website commented 8 years ago

Good idea. Did you experience this issue, too?

For me though, your suggestion doesn't seem to be the reason for this (although I like the idea to change the unit names to match exactly their file names.)

Some units have matching file and unit names already:

The remaining files mismatch the unit names in terms of letter-capitalization:

For me all of them compile well under Linux Mint (Debian/Ubuntu based). For code completion (ctrl+space) I indeed experienced something strange for different projects. Usually code completion worked but sometimes it didn't. This was independent of the actually SDL2 units used. On closer look when checking for the sdl2 source path (Project > Project Options... > Paths), the field "Other unit files (-Fu)" was (surprisingly) empty if the error occured. For this project to compile though, it had to be filled at least one time (at least for the first compile the other day) because otherwise the project will refuse to compile at all.

I'm a little bit confused at the moment. Lazarus bug?

JazzMaster commented 7 years ago

theres a working sdl bgi driver for c but im a massively confused here. c uses as a system path. the code is similar to old bgi pascal flavors. Im just wonder ing how trip it and if this code does the same?

include <SDL2/SDL_bgi.h>

seems to be the offender.

should I use uses SDL_BGI;

instead? and yes, im aware of the c linkage

ev1313 commented 7 years ago

If you include sdl.pas it should include everything. The only exceptions are sublibraries of SDL like net, audio, etc (which are in separate .pas files). So it should work, if you just include sdl.pas, else i've missed converting sdl_bgi.h || it was included in a new version.

suve commented 7 years ago

My comment to #54 went unanswered, so I'm going to re-post it here.

To quote the FPC User Guide: (link)

On systems where filenames are case sensitive (such as UNIX and Linux), the compiler will :

    Search for the original file name, i.e. preserves case.
    Search for the filename all lowercased.
    Search for the filename all uppercased.

As such, I think this issue could be fixed by just changing all the units to use all-lowercase filenames.

ev1313 commented 7 years ago

Fixed it. Sorry for the delay.