Search code examples
prologgnu-prolog

Is there way I could fix this error ? Undefined symbols for architecture x86_64: (gnu-prolog)


My program runs fine on swi prolog but when i try run it using gnu-prolog. It does not run successfully. Im getting this error which I have no idea how to fix.

This is my first error

gprolog [myprojectname]

?- ran the program calling the function
uncaught exception: error(existence_error(procedure,writeln/1),comp/0)

I ran it in one line it did not work

i tried to run it in different way on terminal gplc [myprojectname]

gplc [myprojectname]

Undefined symbols for architecture x86_64:
  "predicate(writeln/1)", referenced from:
      predicate(comp/2) in gplcML9Z1g.o
      _Lpred2_1 in gplcML9Z1g.o
      _Lpred2_2 in gplcML9Z1g.o
      _Lpred2_3 in gplcML9Z1g.o
  _Lpred2_4 in gplcML9Z1g.o

ld: symbol(s) not found for architecture x86_64 clang: error: linker command failed with exit code 1 (use -v to see invocation) compilation failed


Solution

  • The writeln/1 predicate is not a standard predicate and is not supported in GNU Prolog. Replace it with a combination of the standard predicates write/1 and nl/0.