gccshakespeare-lang

Shakespeare Programming Language - errors while compiling


To translate hello.spl to C, I run ./spl2c <hello.spl> hello.c which works fine.

Next I run gcc hello.c, but I get this error:

fatal error: spl.h: No such file or directory.

spl.h and hello.c are in the same directory. I tried to change the include statement in hello.c from #include <spl.h> to #include "spl.h", but then I get several errors when running gcc hello.c such as:

undefined reference to 'global_initialize'

undefined reference to 'initialize_character'

Could anyone tell me what's going on?


Solution

  • The function global_initilize, initialize_character are declared but not define in hello.c. I think your program hello.c is depending on a library ("spl" library?) which is not included in your compile command.

    You should have one of the following:

    gcc hello.c whatever_file_who_define_undefined_function.c
    gcc hello.c -lwhatever_lib_that_define_undefined_function.so
    

    EDIT :

    http://shakespearelang.sourceforge.net/report/shakespeare/#SECTION00070000000000000000 you need to include libspl.a library to make it work

    So your compile option should be the following:

    gcc hello.c -Ipath/to/spl/include/ -Lpath/to/spl/library -llibspl.a
    

    or (*.a is static library, so it can be handle like a object file)

    gcc hello.c -Ipath/to/spl/include/ path/to/spl/library/libspl.a