What is the best way to install components?
Asked Answered
C

4

9

Installing components under Delphi XE3 is a nightmare.

  • First I need to add source files to

    Tools -> Options -> Library

  • then I need to find a normal package and compile it

  • finally I need to find design time package and install it.

This is just quite tedious and error prone. Is there a nicer way to install components?

I have found Delphi Package Installer. Unfortunately it doesn't support Delphi XE3 or above.

I have heard that there is something similar which produces exe packages that install themselves (something like Inno Setup) but I can't find such thing.

Cubbyhole answered 9/12, 2012 at 19:32 Comment(15)
@TLama Most components don't have installers. Anyway this way a pretty trivial task before Delphi 2005 and they complicated the process then.Cubbyhole
@Cubbyhole It's no different now from how it was in D6.Explicative
@Tom, I know, it was just a sidenote and a hidden advice to make installer for your own components to save this hard work for the others. Anyway, interesting project that Delphi Package Installer you've mentioned in your question edit. I'll have to find time to try it.Function
@DavidHeffernan I remember back in the Delphi 7 times I could just select a PAS file and install it without any packages.Cubbyhole
@Tom: No, it's not. It's the exact same process that has existed since Delphi 6 (which I said in my answer). The product that produced .exes was the Mustang Peak Component Installer (developed for installing VirtualTreeView), which is no longer available. It required more work to set up than normal installation does, because it was designed for installing on many machines (distribution of component libraries) and not for installing a set of package files you might have.Groping
@Function If I find a way to make nice installers then I am definitely going to repack all popular components like JVCL or Cindy.Cubbyhole
@Cubbyhole As in Component | Install Component and then select a unit file name. That same feature that I am looking at in XE3?Explicative
@Cubbyhole - try lazyproject.infoHale
@KenWhite Here JVCL packaged using Inno Setup: cc.embarcadero.com/Author/54776 Maybe there are some simple scripts for Inno to make installers.Cubbyhole
@Tom: There probably are, but that's for component vendors to do (as I've said three times here), not for just installing a component library you find somewhere and want to install. You have to write the .ISS script specifically for everything that you install; there is (and can't be) a generic "install a bunch of components" script. If you want an installer built, contact the component vendor/author.Groping
@KenWhite I am interested in either a simple way to install components I have or a simple way to create an installer for the components I have. So once make an installer I can just use it.Cubbyhole
Then feel free to write one that does exactly what you want it to do. :-) You do have an IDE and compiler.Groping
The die-hard delphi guys don't see any problem, but i have to agree with Tom that it's unnecessarily complicated to install components in deelphi. Some lessons can be learnt by looking at how other IDE's solved this.Bleary
I remember back in the Delphi 7 times I could just select a PAS file @Cubbyhole you mean DclUsr.DPK - User Custom Coponents package, empty by default, but where you could add separate components. It is kind of legacy from Delphi 2, where like in Lazarus today you recompiled IDE to make component appear. Well, you still can do it, at least in XE2: go main menu, components, install component, into existing package and choose DclUsr.dpkFleawort
I've been using Delphi for a while, and I've always think that components are a hassle to maintain, specially when setting up a new development environment.Psychodiagnosis
G
10

No. The steps above are required.

First, adding the file path to Tools->Options->Delphi Options->Library Path is so the compiler knows where to find the files to compile them. (Actually, it's not required - you can eliminate this step by making sure that the .dpk files are in the same folder as the .pas files, and that all .pas file names are listed in the includes section in the .dpk. If the .pas files are in a different location, you'll need to either use relative paths in the .dpk (eg., MyComponents in '..\Source\MyComponents.pas') or add the location of the .pas files to Project->Options->Delphi Compiler->Search Path.)

The next step (finding the "normal package") is in order to build the runtime package. It's required, because the design-time package (next step) requires the code that's in that package in order to function in the Form Designer. It's also needed when you decide to build your application with runtime packages, if you use the third-party components and want to distribute the runtime package for it.

The separate design-time package (the third step) is required because designtime code can only be used at design-time; there's nothing that can be distributed with an application if it's built with runtime packages and the package build in step 2 is one of them.

This has been the way components are installed since around Delphi 3 or so, and the requirement to separate out designtime code into it's own package started being advised in Delphi 5 and enforced in Delphi 6 (when they relocated much of the IDE designtime support into their own separate packages and stopped distributing the source for them).

There really are no other options, unless the vendor supplies pre-build designtime and runtime packages for you, or supplies an installer that will do all of the above steps. (Most don't.) But if you update your Delphi version, you'd still have to go through the steps above.

Groping answered 9/12, 2012 at 19:47 Comment(11)
Modifying Tools->Options->Delphi Options->Library Path could be optional if the .dpk file listed every file. Which seems to me to be a better way to do it than rely on a global search path.Explicative
Like you say, this is only a 'problem' if you are making a package yourself or if you downloaded a component without packages. Normally, downloaded or purchased components will have complete dpk files, which include all files (so you don't need to alter the library path) and ofter even have an installer. +1 for answering this question at all.Sarrusophone
David and GolezTroi: Both good points. I decided to just address the poster's list rather than writing a book, though; it got long enough as it is. :-) Please feel free to edit that paragraph if you'd like, though.Groping
Global Tools->Options->Delphi Options->Library Path paths are NOT designed for source code. Please never set paths to source code in global library path.Hale
I understand the process but I think this could be done in a simpler way. Like a special file which lists all the source files, dependencies and stuff. You just doubleclick and voila- installed.Cubbyhole
@Serg: Please read the previous comments before posting one. :-) I've already addressed this with David and GolezTroi: I replied to what the poster specifically asked; I did not write a book on best practices for installing component libraries. As I said in the other comment, please feel free to edit that paragraph if you'd like.Groping
@Tom: That's called an installer (which I mentioned in my answer), and the vendor needs to supply it. If you want them to, tell them.Groping
If the .pas files are in a different directory, you just need to specify a relative path in the .dpk file. Like use MyUnit in 'Path\To\MyUnit.pas';Explicative
@David: Except if you're talking about someone else's package source, in which case you don't want to modify it. (It breaks updates/patches.) But I'll edit again to include that too.Groping
@KenWhite I'd expect packages to be delivered as a bundle that can simply be compiled and installed, so long as the original directory structure is respected.Explicative
@David: Yeah, you'd expect that. You don't always get it. :-)Groping
N
3

What about the built-in component installer? It is part of Delphi XE, XE2 and XE3 and a description can be found here (I wrote it). It will even install components in C++Builder. You can instal into an existing package or into a new one, which it will create for you.

Neill answered 10/12, 2012 at 12:18 Comment(2)
Nice article, but when I have a bunch of DPKs then I still have to install them manually- one by one.Cubbyhole
The question was about components. Packages can indeed only be installed one by one, AFAIK. Hmmm... I could try to extend the component installer to install multiple packages.Neill
D
2

I would say that the best way to install components is to use your build manager (for example FinalBuilder) and add each component to a manager-project file which sets the necessary paths, builds the DPK files, and 'installs' the component in the IDE by making a registry entry. That way you have a documented procedure which allows you reliably to set up or repair your complete, tested, Delphi development environment. You can simply re-run the project when a component has been updated and tested. It is also quite easy to tweak an existing project to handle a new Delphi version.

The big disadvantage of a vendor-supplied installer is that all the ones I have seen simply overwrite the previous version on updates. I prefer to control the install myself, so that I have previous component source versions archived and available for comparison, in case testing reveals a problem with an upgrade. The 'one-click install' sounds fine, until a minor component upgrade suddenly causes your application to stop working.

Drislane answered 10/12, 2012 at 1:6 Comment(1)
Maybe I am lucky but I never had any problems with components upgrades. And such 1 click installer could still save lots of time if components were fine.Cubbyhole
L
2

Take a look at "Lazy Delphi Builder". It was created to simplify build/installation of many components at once. It resolves packages dependencies automatically. Free to use. Link to some old tutorial

Leibowitz answered 21/12, 2012 at 15:7 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.