I got a VST plug-in working under Lazarus!

DSP, Plugin and Host development discussion.
RELATED
PRODUCTS

Post

jorgen wrote:Space Boy, you must replace "program" with "library" in test_dll.lpr

Dll is called dynlib on mac, but I dont think you can do it with FPC yet. It compiles, but the .dynlib doesnt work/load. (unless they have fixed it recently)

cheers
jorgen
I don't think so.

Check carefully what I wrote.

The "test_dll.lpi/test_dll.lpr" compiles (under Lazarus) to an application (i.e. .exe) that, when executed, loads two .dlls. The individual .dlls are compiled from the other project files, "mydll.lpi" for the Lazarus .dll and "mydllD.dpr" for the Delphi .dll.
Image

Post

Yeah, I was a bit qucik reading your msg. Your code look 100% ok to me. Did you check with LoadLibray instead of statis likning? maybe try with a simple windows.pas MessageBox instead of ShowMessage and including classes etc.

cheers
jorgen
Half developer half human
XT Software
http://www.energy-xt.com

Post

Code: Select all

library mydll;

{$mode objfpc}{$H+}

uses
  Classes,
  SysUtils,
  Windows;

procedure DllMessage; export;
begin
 MessageBox(0,PChar('Hello world from a Lazarus DLL'),PChar('Lazarus'),mb_ok)
end;

exports DllMessage;

begin
end.
Works when complied using Lazarus.

So, the ShowMessage and Dialogs are causing the problem.
Image

Post

I've checked out the Lazarus website numerous times and salivated over the remote possibility that I could somehow make a Mac VST of Glitch this way, so I would be very interested to hear how things turn out. If something does get figured out the information would be an invaluable resource to the Delphi VST community.
I'm Kieran, aka dblue, aka illformed | illformed.com | Glitch 2 now available for Windows, Mac and Linux!

Post

well, it's good newws that you've got it working to some extent :)

Can you get a GUIless plug compiled? That would be a start. I was wondering about using TPngImage for gfx. There is a supporting library (I have it somewhere) which has an imagelist which works with it. You can drop the VCL with a compiler option, which should be good.. whether you can drop the LCL, I don't know..

LCL should be available in a dll, I would have thought.

at least there's progress :)

DSP
Image

Post

Hi,

Some progress on the Lazarus front.

I managed to get the 'Demo_NoGUI' plug-in from Tobybears template to compile AND work using Lazarus. :shock:

Anyone here interested to know how I did this?
Image

Post

Space Boy wrote:Anyone here interested to know how I did this?
yes

Post

Yes, please share Spacey, this is a great move towards portability for all those excellent Delphi-based VST plugins :cool:
Music with dinner is an insult both to the cook and the violinist.

Post

O.K.

Setting Up Lazarus
  1. Download and unpack Tobybear's VST Plugin template from here http://www.tobybear.de/d_template.html
  2. Download and install the latest 'Daily Snapshot' of Lazarus from here http://www.de.freepascal.org/lazarus/
  3. Download and install the current stable release of Free Pascal from here http://www.freepascal.org/
  4. Copy all the files from the Free Pascal directory '~FPC\2.0.2\bin\i386-win32' to the Lazarus directory '~Lazarus\pp\bin\i386-win32'
  5. Important Run Lazarus and, under the 'Tools' menu, execute 'Build Lazarus'. This will re-compile Lazarus using the compiler files from the Free Pascal release.
  6. When compile is complete you are now ready to try compiling a plugin.
Compiling a Plug-in
  1. Under windows, navigate to the directory of 'Toby's_VST_Template'.
  2. Copy all the files from the 'CommonVST' directory into the 'Demo_NoGUI' directory.
  3. Start Lazarus.
  4. Create a new Application and save it in the 'Demo_NoGUI' directory as 'VSTPlugin.lpi' (you can also use your own name for the project).
  5. Go to the Lazarus 'Tools' menu and choose 'Convert Delphi unit to Lazarus unit' navigate to the 'Demo_NoGUI' directory and select all the *.pas files, including 'uPlugin.pas' (ignore unit1.pas) and convert them (there will be some complaints about missing units (choose to comment them out).
  6. Once the files are converted switch to the 'VSTPlugin.lpr' view. Open the Lazarus project inspector and remove the 'unit1.pas' from the project and add the 'uPlugin.pas' in its place.
  7. Go back to the 'VSTPlugin.lpr' editor window and select everything within the editor and delete it.
  8. Open the original Delphi 'VSTPlugin.dpr' file in Lazarus (via the File menu) select, copy and paste everthing into the 'VSTPlugin.lpr' file.
  9. In the 'VSTPlugin.lpr' file add a 'Classes,' above the 'uPlugin' in the 'uses' section.
  10. Add a '{$MODE Delphi}' under the 'library VSTPlugin;' declaration.
  11. Open the Project -> 'Project Options' and set the target file name to 'VSTplugin.dll'
  12. Under the 'Miscellaneous' section tick only 'Main unit has uses section......' and 'Always build'.
  13. Save project and then compile using Ctrl-F9.
  14. There may be some complaints from 'DAudioEffectX.pas', 'DDspUtils.pas' and 'DVstTemplate.pas'. To fix this add a 'Windows,' (or 'LCLType,' also works) after the 'LCLIntf,' declaration in the 'uses' section of each unit that complains.
  15. Recompile and your .dll should be created.
  16. Test the plug-in in your favourite host.
First one back to me with a working plug-in is.....erm.....the winner!

.....and, quite probably, the second person in the world to compile a working VST plug-in under Lazarus. :wink:

I have been contributing bug reports to the Lazarus effort and so some progress is taking place.

I did managed to build a plug-in with editor, but I couldn't get the editor to show. I'm hoping that when there is enough critical mass of people who can build a plug-in with Lazarus the pace of progress will improve.

Let us know how you get on.

I'm goin' for a cup a' tea :)
Image

Post

This is the good shit!
Means I can start compiling dunc's stuff on me mac in a while :)
Image
Shuriken.se, sonic weapons for the music ninja!

Post

SB - that is superb! I'll be trying that out. I've been tinkering, but not got anything as conclusive as you.

Is it definately a problem with LCL and dlls?

DSP
Image

Post

Space Boy, your instructions work perfectly, but why is the dll so large? (3815 kb)

Post

Read the lazarus documentation.. there is a problem with their win32 linker - it includes the kitchen sink, no matter what you tell it..

You need to use their strip tool, and they suggest using UPX as well to get the footprint down..

Hopefully they'll get it sorted to be somewhat smaller again :)

DSP
Image

Post

Ok thanks for that, it's down to 1209 kb now, still pretty huge for a filter with 2 controls and no gui! How big is the Delphi version?

Post

kalmovax wrote:How big is the Delphi version?
About 10 times smaller. The bloated size is a problem with Lazarus OR the Free Pascal compiler.
Image

Post Reply

Return to “DSP and Plugin Development”