Need help! Writing dll. lazarus / 16-Databases ---------------------------------------------------------------------- FreekNel · 2008-04-15 06:59 Hi people. Sorry for my english. I tried to write library which executes basic buisnes-rules for my program. And I have a problem which stops all process. For tests I write a simple library. Code: [Select] library lib_main; {$mode delphi}{$H+} uses   Classes, SysUtils, u_data; exports   SomeFunc name 'SomeFunc'; begin end. unit u_data; {$mode delphi}{$H+} interface uses   Classes, SysUtils;   function SomeFunc(aValue: string): string; stdcall; implementation function SomeFunc(aValue: string): string; stdcall; begin   Result := aValue+aValue; end; end. I use string type to verify that problem is not linked with strings. {$H+} option is to control Heap, as I understand. heap.inc is a functional analog of SharedMem in Delphi. Part of program for test library. Code: [Select] function SomeFunc(aValue: string): string; stdcall; external 'lib_main.dll'; And it works good. After this I add a package for work with FB database. So, library code looks: Code: [Select] library lib_main; {$mode delphi}{$H+} uses   Classes, SysUtils, u_data, fiblaz; exports   SomeFunc name 'SomeFunc'; begin end. When I test "new" library my program fails with message(translated from russian): Error initializing application (0xC0000005). I tried to add another units in uses section for tests. Sometime I get error "Error initializing application (0xC0000142)" Is it a bag of FPC or I do something incorrect? ---------------------------------------------------------------------- Phil · 2008-04-15 13:51 Quote from: "FreekNel"Is it a bag of FPC or I do something incorrect? In general you don't pass dynamically allocated types to or from a library. You can pass these types: pchar, integer, etc. That may not have anything to do with your problem. Thanks. -Phil ---------------------------------------------------------------------- Leledumbo · 2008-04-16 03:48 Quote{$H+} option is to control Heap, as I understand. Just to guide you to the right way, {$H+} means 'string' type will be an alias to 'ansistring' instead of the default 'shortstring' as long as it isn't appended with square brackets ([]). Don't know why they (fpc developers) use H, perhaps they're out of letter. ---------------------------------------------------------------------- Marc · 2008-04-16 09:17 H+ is delphi compatible ---------------------------------------------------------------------- FreekNel · 2008-04-16 17:26 Thanks to all, but it isn't solves my problem. I wrote same test library in Delphi 7. It works. I can't understand, what is wrong in my actions...One person advice me to look at initialize section in linked unit. I find only standart procedure of registration package... ---------------------------------------------------------------------- FreekNel · 2008-04-17 02:43 Tried to write console application. Result is: [FORMS.PP] ExceptionOccurred   Sender=Exception   Exception=Unknown Run-Time error : 202   Stack trace:   $100094B3 TApplication.HandleException Unknown Run-Time error : 202   Stack trace:   $100094B3 Can't find module in components which uses Forms ---------------------------------------------------------------------- Phil · 2008-04-17 03:08 Quote from: "FreekNel"Tried to write console application. Result is: [FORMS.PP] ExceptionOccurred   Sender=Exception   Exception=Unknown Run-Time error : 202   Stack trace:   $100094B3 TApplication.HandleException Unknown Run-Time error : 202   Stack trace:   $100094B3 Can't find module in components which uses Forms In general you don't use Forms in console apps or libraries (DLL's). Thanks. -Phil ---------------------------------------------------------------------- FreekNel · 2008-04-17 03:21 Quote In general you don't use Forms in console apps or libraries (DLL's). Yes, but fiblaz uses Forms. Variables such as Application, Screen and so on. As for me, I need FIBDataBase and FIBQuery units only. Tests fail After excluding Forms unit, I have another ErrorCode - 0xC0000142. Probably, it's nessesary to use Delphi to write my library...