Compile Error: undefined reference to `main' collect2: error.
i use plc -c my_sample.st -o my_sample.o then i use plc my_sample.st -o my_sample --linker=cc. In my_sample.st,it's a simple function, starts with FUNCTION name, ends with END_FUNTION. When i compile it, it occurred "(.text+0x1b): undefined reference to `main' collect2: error: ld returned 1 exit status An error occurred during linking: An error occured during linking." what should i resolve it?
The linker expects an entry point in the form of a main function. You're most likely missing that in your program. Try to add the main function, then call your other function within there.
The linker expects an entry point in the form of a
mainfunction. You're most likely missing that in your program. Try to add themainfunction, then call your other function within there.
Thanks for you reply!What I want to do is let Rusty batch check some st scripts for syntax and lexical errors.These st scripts are ready-made,about 500 of them,each containing one function or more.If I add a main function and call the target function within main,I still need to manually add parameter to each function call.Do you have any suggestions?
If you are truly only interested in checking for syntax and semantic errors you may want to use plc --check. Maybe also check plc --help while you are at it.
if you have multiple files that all depend on each others, you can also create a project (see the plc.json and build configuration in the help) and then you can use plc check to check the entire project.
Using plc --check *.st will also work to check all files at the same time. You might need this if the files have depend on each others since there is no include mechanism in plc