My goal is to get a very simple proof of concept FPC (3.0.4, powerpc64) library working with C (gcc 4.8.3) on an AIX 64-bit machine (7.1).
My FPC library consists of two files:
HelloWorldLib.lprlibrary HelloWorldLib;
uses
HelloWorldFunctions;
exports
HelloWorld;
begin
end.
HelloWorldFunctions.pasunit HelloWorldFunctions;
interface
procedure HelloWorld; cdecl;
implementation
procedure HelloWorld; cdecl;
begin
Writeln('Hello, world.');
end;
end.
My C application is a very simple consumer:
helloworld.cextern void HelloWorld(void);
int main()
{
HelloWorld();
return 0;
}
For compiling the library, I have tried many of the FPC arguments listed here:
https://www.freepascal.org/docs-html/user/userap1.html. It successfully compiles a libHelloWorldLib.a archive file. E.g.
fpc HelloWorldLib.lpr -B -CN -l -O2 -MobjFPC
For compiling the C application I use the following command, and have tried multiple variations on this as well:
gcc -o hw helloworld.c -L. -lHelloWorldLib
I receive the following error message: "ld: 0711-317 ERROR: Undefined symbol: .HelloWorld". If I use "g++" instead of "gcc", I get: "ld: 0711-317 ERROR: Undefined symbol: .HelloWorld()".
If I use "dump -HTv libHelloWorldLib.a", I get nothing, which seems to indicate that there are no symbols in the archive.
I'd appreciate any assistance that can be provided. Thanks!