Hi,
I created a simple library, with just one function.
After compiling it a libsimple.dylib file was generated.
I created a test lib project where I import the function.
Also, copied the dylan file in the project's folder, as well to x86_64-darwin
When compiling the project I received this error
Compile Project, Target: Libtest: Exit code 1, Errors: 4, Hints: 3
Hint: Start of reading config file /Users/julian/FpcUpDeluxe/fpcupdeluxe/fpc/bin/x86_64-darwin/fpc.cfg
Hint: End of reading config file /Users/julian/FpcUpDeluxe/fpcupdeluxe/fpc/bin/x86_64-darwin/fpc.cfg
Verbose: Free Pascal Compiler version 3.3.1-r48994 [2021/03/17] for x86_64
Verbose: Copyright (c) 1993-2021 by Florian Klaempfl and others
Verbose: Target OS: Darwin for x86_64
Verbose: Compiling Libtest.lpr
Verbose: Compiling mainform.pas
Verbose: Compiling simple.pas
Verbose: Assembling simple
mainform.pas(19,28) Verbose: Parameter "Sender" not used
mainform.pas(34,3) Hint: Unit "simple" not used in MainForm
Verbose: Assembling mainform
Libtest.lpr(13,20) Verbose: Unit "simple" not used in Libtest
Verbose: Assembling libtest
Verbose: Compiling resource /Users/julian/Project/ProjectL/Applications/Research/Libtest/lib/x86_64-darwin/Libtest.or
Verbose: Linking /Users/julian/Project/ProjectL/Applications/Research/Libtest/Libtest
Error: linker: Undefined symbols for architecture x86_64:
Error: linker: "_sum2int", referenced from:
Debug: "_sum2int", referenced from:
Debug: _SIMPLE_$$_SUM2INT$LONGINT$LONGINT$$LONGINT in simple.o
Error: ld: symbol(s) not found for architecture x86_64
An error occurred while linking
Error: Error while linking
Verbose: There were 1 errors compiling module, stopping
Verbose: Compilation aborted
Verbose: /Users/julian/FpcUpDeluxe/fpcupdeluxe/fpc/bin/x86_64-darwin/ppcx64 returned an error exitcode
the import code looks like this
unit simple;
{$mode ObjFPC}{$H+}
interface
uses
Classes, SysUtils;
const
lib_path = '/Users/julian/Project/ProjectL/Libraries/simplelib/';
simple_lib = 'simple.dylib';
{$linklib simple.dylib}
function sum2int(val1, val2: Integer): Integer; {$IFNDEF WINDOWS}cdecl{$ELSE}stdcall{$ENDIF};
{$EXTERNALSYM sum2int}
implementation
function sum2int(val1, val2: Integer): Integer; {$IFNDEF WINDOWS}cdecl{$ELSE}stdcall{$ENDIF};
external simple_lib name 'sum2int';
end.
In the code I tried also with
simple_lib = 'simple';
simple_lib = 'simple.dylib';
simple_lib = 'libsimple.dylib';
I searched the web and the forum but the articles I read didn't help me much.
May be you can give some more information about the error.