Lazarus

Programming => General => Topic started by: Relative on April 05, 2010, 10:29:58 pm

Title: Disable relocation
Post by: Relative on April 05, 2010, 10:29:58 pm
Hi Programmers!

I'm a beginner Lazarus user. I just installed the program and wanted to make my first simple program.

I followed the instructions for the first example - minimal called - on this page: Creating Metatrader DLLs with Lazarus / Free Pascal (http://"http://www.forexfactory.com/showthread.php?t=219576")

So,

- I created a new Project: 'click on Project -> new project -> Library'
- Copied the below code to the Source Editor window:

Code: [Select]
library minimal;

{$mode objfpc}{$H+}

uses
  sysutils;

// strings from and to Metatrader will always be passed
// as PChar which is a pointer to a nullterminated C-string.
function foo(x: double; y: PChar): PChar; stdcall;
var
  s :ansistring; // reference counted and memory managed strings.

begin
  // our PChar will be copied into an ansistring automatically,
  // no need to worry about the ugly details of memory allocation.
  s := 'Hello ' + FloatToStr(x) + ' ' + y + '!';

  // cast it back into a pointer. Metatrader will copy the
  // string from the pointer into it's own memory.
  result := PChar(s);
end;

exports
  foo;

begin
end.

- I saved the project to an empty folder.
- Then I ran the Quick compile.

Finally, I got these messages:

Quote
minimal(1,1) Warning: Relocatable DLL or executable minimal debug info does not work, disabled.
minimal(1,1) Warning: To allow debugging for win32 code you need to disable relocation with -WN option
Project "minimal" successfully built. :)

The Lazarus didn't make *.dll file. It made an exe file - but I don't think so it is working. Really, I don't know, but I couldn't use. Anyway, I need the dll file.

So, what can I do for creating my dll file? How can I disable the mentioned relocation with the -WN option?

Do you have any idea? What can I do? I would be happy, if you could help me.

(I use Windows 7 64bit operating system.)

Thank you in advance.

Relative
Title: Re: Disable relocation
Post by: Relative on April 06, 2010, 11:54:06 am
I tried to run the Quick compile on a 32bit Windows XP SP2 operating system.

I got the same error messages.
Title: Re: Disable relocation
Post by: Marc on April 06, 2010, 12:14:22 pm
Quick compile doesn't compile a exe. You only can use it as some kind of syntax check.
Title: Re: Disable relocation
Post by: Relative on April 06, 2010, 12:24:27 pm
Quote
Quick compile doesn't compile a exe. You only can use it as some kind of syntax check.

I could create exe file. But I would like to create DLL file for further use with another program language MQL4 (http://"http://www.mql4.com/").
Title: Now, it works!
Post by: Relative on April 06, 2010, 02:11:44 pm
Now, It works!  :)

I shouldn't use quick-compile but build instead. I deleted everything except the lpi and the lpr files and then I pushed Ctrl-F9 (Build).
TinyPortal © 2005-2018