Markus Gerwinski wrote:
I'm currently trying to call a Pascal routine from within a C program. To this mail I attached a few sources demonstrating the way I'm trying to do so. Compiling them with
gpc -c foo.pas gcc footest.c -o footest
leads to an error message "undefined reference to `Bar'".
What am I doing wrong?
a) You must link the Pascal object file: gcc footest.c foo.o -o footest b) You must init the RTS etc. (if the Pascal code uses any of it which most Pascal code does), see the demo programs gpc_c_pas.pas and gpc_c_unit.pas. c) You should specify the asmname of the Pascal routine: procedure bar; asmname 'Bar'; (Currently, this is the default used by GPC, but this will change soon as a preparationn for qualified identifiers, and you probably don't want your code to break then.) Frank -- Frank Heckenbach, frank@g-n-u.de, http://fjf.gnu.de/, 7977168E GPC To-Do list, latest features, fixed bugs: http://www.gnu-pascal.de/todo.html GPC download signing key: 51FF C1F0 1A77 C6C2 4482 4DDC 117A 9773 7F88 1707