Forum > General

Disable relocation


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


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

--- Code: ---library minimal;

{$mode objfpc}{$H+}


// 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;
  s :ansistring; // reference counted and memory managed strings.

  // 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 code ---

- 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. :)
--- End quote ---

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.


I tried to run the Quick compile on a 32bit Windows XP SP2 operating system.

I got the same error messages.

Quick compile doesn't compile a exe. You only can use it as some kind of syntax check.


--- Quote ---Quick compile doesn't compile a exe. You only can use it as some kind of syntax check.
--- End quote ---

I could create exe file. But I would like to create DLL file for further use with another program language MQL4.

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).


[0] Message Index

Go to full version