I'm trying to use a third party framework, that needs a library, in Delphi IOS. To get Delphi to link it in i've entered the following statement:
procedure StubProc1; cdecl; external 'AerServSDK.a' dependency 'libxml2.2';
When i build it i get the following error:
[DCC Error] E2597 ld: library not found for -llibxml2.2
The library is in the usr\lib directory, and it doesn't matter whitch library i try. Apparently some searchpath needs to be updated, but where and how??
The solution is, to omit the "lib" part of the library name. So it's:
procedure StubProc1; cdecl; external 'AerServSDK.a' dependency 'xml2.2';
You must add the path to the library in the source path of the project (like you do with .pas file).
add theses 2 rows :
procedure StubProc1; cdecl; external 'AerServSDK.a';
procedure StubProc2; cdecl; external 'libxml2.2';
AerServSDK.a and libxml2.2 (ie: the file libxml2.2 without any extension) must be in your source path
Related
I have a DLL it crated with Delphi xe10.2 and it contain a function
function calc(b : integer;a:integer) : Integer;
begin
Result := a+b;
end;
and i will call it on other program like this
function calc(b : integer;a:integer): Integer; stdcall; external 'my.dll';
i copied the DLL in System32 folder and application .exe folder
procedure TForm1.Button1Click(Sender: TObject);
begin
showmessage(inttostr(calc(2,3)));
end;
but when i run from delphi IDE nothing happened.it dont show any error and also dont show application main form...
how can i fix this ?!
System32 is the 64-bit system folder. Your application is a 32-bit application, and hence does not search for DLLs in System32. It will search in SysWOW64 instead, which is the 32-bit system folder. If you ran the program without debugging, you would see an error message telling you that the DLL could not be located.
Now, you should never modify the contents of system folders. Remove the DLL from System32 and instead place it in the same directory as your executable file.
The other problem, given the code shown, is that the exported DLL function uses the register calling convention, but you import it using the stdcall calling convention. You must ensure that the calling conventions used by DLL and EXE match each other.
I want to consume c obj files in delphi xe3.
When linked obj files, shows this error:
`[dcc32 Error] Unit1.pas(149): E2065 Unsatisfied forward or external declaration: '_exit'`
can i implement _exit function?
Yes you can indeed do this. Typically you will link the .obj file to a single unit in your project. Implement the exit function in that unit and the Delphi linker will find it.
....
implementation
....
{$LINK foo.obj}
procedure _exit(status: Integer); cdecl;
begin
// your implementation goes here
end;
As I've illustrated this you place the function in the implementation section of the unit. It does not need to be visible externally to the unit.
You might have multiple different units that link to C objects, in which case you can place your C runtime functions, like exit, in a single unit, and use that from each other unit that links to C objects. In that scenario then you need to expose each function in the interface section so that the linker can see the function.
I am convert component from delphi 5 to delphi xe5`.
I build it completely but still while installation
following error come
The procedure entry point SymGetSymFromAddrW could not be located in
the dynamic link library IMAGEHLP.DLL
SymGetSymFromAddrW has been superceded by SymGetSymFromAddr64 on modern Windows versions. You need to use it instead. It has a very similar definition as SymGetSymFromAddr - just redefine it yourself, and use your version instead:
function SymGetSymFromAddr64(hProcess: THandle; dwAddr: DWord64;
pdwDisplacement: PDWord64; var Symbol: TImagehlpSymbol): Bool; stdcall;
function SymGetSymFromAddr64; external ImagehlpLib name 'SymGetSymFromAddr64W';
See the documentation for SymGetSymFromAddr64 for more info.
I'm not having any luck importing a Delphi DLL into Inno Setup (Unicode). The DLL has a simple procedure..
procedure Foo(); stdcall;
begin
end;
exports
Foo;
The DLL is included in the installer source, and added to the files list:
[Files]
Source: "MyDLL.dll"; Flags: dontcopy
Then, I extract this DLL in the initialization:
function InitializeSetup(): Boolean;
begin
ExtractTemporaryFile('MyDLL.dll');
end;
And finally, declared this procedure in the script:
function DoFoo(): Bool;
external 'Foo#MyDLL.dll stdcall';
However, when I run the setup, I get an error:
Cannot Import dll: <utf8>MyDLL.dll.
What am I doing wrong?
Since you haven't used delayed loading in your function import, Inno Setup loader failed to run because it didn't found your library. That's because checks whether function exports are available are performed before the InitializeSetup event is fired and so your library was not yet extracted from the archive.
In your case is adding delayload import option the right way. But you can omit manual extracting and tell the installer to extract the library for you if you add files: prefix before the library file name. This prefix is documented as:
During Setup, a special 'files:' prefix may also be used to instruct
Setup to automatically extract one or more DLLs from the [Files]
section before loading the first DLL.
The whole import in your case can be then shortened to:
[Files]
Source: "MyDLL.dll"; Flags: dontcopy
[Code]
procedure Foo;
external 'Foo#files:MyDLL.dll stdcall delayload';
I found the solution right after posting this question by using delayload on the import...
function DoFoo(): Bool;
external 'Foo#MyDLL.dll stdcall delayload';
I want to convert the WebKit framework by following the patterns used in other Objective C frameworks included in Delphi XE2.
I am getting the following error message:
Project ProjectFM raised exception class EObjectiveC with message 'ObjectiveC class WebView could not be found'.
I have a included the WebKit framework in the Remote Profiles, by adding is follows:
Path: /System/Library/Frameworks
Framework: WebKit
I have followed the pattern found in MacAPI.Foundation.pas to begin translating the WebView.h file as follows:
WebViewClass = interface(NSViewClass)
['{0D9F44B7-09FD-4E35-B96E-8DB71B9A2537}']
{class} function canShowMIMEType(MIMEType: NSString): Boolean; cdecl;
end;
WebView = interface(NSView)
['{C36D8016-2FCB-49F0-BA1C-C9913A37F9AC}']
procedure close; cdecl;
end;
TWebView = class(TOCGenericImport<WebViewClass, WebView>) end;
Also, does the GUID for the interface have any relevance?
Can anybody provide any guidance as to what steps must be followed to tap into any of the additional objective c frameworks not included in XE2.
Thanks,
Phil