Skip to content

[Linux, SDL_bgi 2.6.0] Error while linking: undefined reference to 'xkbhit' #1

@rchastain

Description

@rchastain

Hello! Congratulations for this very nice project.

I installed on Linux SDL_bgi 2.6.0. When I try to compile an example from ubgi, I get this error:

[roland@localhost examples (master)]$ fpc -B -Fu.. exus.pas
Free Pascal Compiler version 3.2.0 [2020/07/05] for x86_64
Copyright (c) 1993-2020 by Florian Klaempfl and others
Target OS: Linux for x86-64
Compiling exus.pas
exus.pas(3,2) Note: APPTYPE is not supported by the target OS
Compiling /home/roland/Documents/pascal/sources/ubgi/ubgi.pas
Linking exus
/usr/bin/ld : /home/roland/Documents/pascal/sources/ubgi/ubgi.o : dans la fonction « UBGI_$$_KEYPRESSED$$BOOLEAN » :
ubgi.pas:(.text.n_ubgi_$$_keypressed$$boolean+0xa) : référence indéfinie vers « kbhit »
Error: Error while linking
Fatal: There were 1 errors compiling module, stopping
Fatal: Compilation aborted
Error: /usr/bin/ppcx64 returned an error exitcode

After taking a look into ubgi.pas, I tried this.

function KeyPressed(): Boolean;
begin
{$IFDEF LINUX}
  Result := XKbHit() <> 0;
{$ELSE}
  Result := KbHit() <> 0;
{$ENDIF}
end;

With that modification, I can compile the example. (But I understood later that it wasn't the correct solution. See correct solution below.)

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions