Recent

Author Topic: Disable relocation  (Read 5247 times)

Relative

  • Jr. Member
  • **
  • Posts: 56
  • Sedo est anima rerum.
    • FxCoder
Disable relocation
« 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

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

Relative

  • Jr. Member
  • **
  • Posts: 56
  • Sedo est anima rerum.
    • FxCoder
Re: Disable relocation
« Reply #1 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.

Marc

  • Administrator
  • Hero Member
  • *
  • Posts: 2556
Re: Disable relocation
« Reply #2 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.
//--
{$I stdsig.inc}
//-I still can't read someones mind
//-Bugs reported here will be forgotten. Use the bug tracker

Relative

  • Jr. Member
  • **
  • Posts: 56
  • Sedo est anima rerum.
    • FxCoder
Re: Disable relocation
« Reply #3 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.

Relative

  • Jr. Member
  • **
  • Posts: 56
  • Sedo est anima rerum.
    • FxCoder
Now, it works!
« Reply #4 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