Watch, Follow, &
Connect with Us

For forums, blogs and more please visit our
Developer Tools Community.


Welcome, Guest
Guest Settings
Help

Thread: Unresolved external erro when no compiled with no link to runtime packages


This question is answered. Helpful answers available: 2. Correct answers available: 1.


Permlink Replies: 3 - Last Post: Feb 22, 2016 10:10 AM Last Post By: Remy Lebeau (Te...
Sam Verstaen

Posts: 2
Registered: 1/12/13
Unresolved external erro when no compiled with no link to runtime packages  
Click to report abuse...   Click to reply to this thread Reply
  Posted: Feb 19, 2016 10:22 AM
I created my own component called "TPlotter". This has also a design time form to change settings. Everything works fine, the component compiles, builds, installs (into "Samspackage"), and is able to be used in applications. Building and running the application works fine.

Next, I want to build a version of my application into a stand-alone executable, so I de-select "Link with runtime packages" to have all the libraries included in my exe.

When doing this, I get following error :

[ilink32 Error] Error: Unresolved external '__fastcall Designeditors::TComponentEditor::TComponentEditor(System::Classes::TComponent *, System::DelphiInterface<Designintf::IDesigner>)' referenced from C:\USERS\PUBLIC\DOCUMENTS\EMBARCADERO\STUDIO\15.0\DCP\SAMSPACKAGE.LIB|PlotterEditor
[ilink32 Error] Error: Unresolved external 'Designeditors::TComponentEditor::' referenced from C:\USERS\PUBLIC\DOCUMENTS\EMBARCADERO\STUDIO\15.0\DCP\SAMSPACKAGE.LIB|PlotterEditor
[ilink32 Error] Error: Unresolved external '__fastcall Designeditors::TComponentEditor::ExecuteVerb(int)' referenced from C:\USERS\PUBLIC\DOCUMENTS\EMBARCADERO\STUDIO\15.0\DCP\SAMSPACKAGE.LIB|PlotterEditor
[ilink32 Error] Error: Unresolved external '__fastcall Designeditors::TComponentEditor::GetVerb(int)' referenced from C:\USERS\PUBLIC\DOCUMENTS\EMBARCADERO\STUDIO\15.0\DCP\SAMSPACKAGE.LIB|PlotterEditor
[ilink32 Error] Error: Unresolved external '__fastcall Designeditors::TComponentEditor::GetVerbCount()' referenced from C:\USERS\PUBLIC\DOCUMENTS\EMBARCADERO\STUDIO\15.0\DCP\SAMSPACKAGE.LIB|PlotterEditor
[ilink32 Error] Error: Unresolved external '__fastcall Designeditors::TComponentEditor::Copy()' referenced from C:\USERS\PUBLIC\DOCUMENTS\EMBARCADERO\STUDIO\15.0\DCP\SAMSPACKAGE.LIB|PlotterEditor
[ilink32 Error] Error: Unresolved external '__fastcall Designeditors::TComponentEditor::PrepareItem(int, System::DelphiInterface<Designmenus::IMenuItem>)' referenced from C:\USERS\PUBLIC\DOCUMENTS\EMBARCADERO\STUDIO\15.0\DCP\SAMSPACKAGE.LIB|PlotterEditor
[ilink32 Error] Error: Unresolved external '__tpdsc__ Designeditors::TComponentEditor' referenced from C:\USERS\PUBLIC\DOCUMENTS\EMBARCADERO\STUDIO\15.0\DCP\SAMSPACKAGE.LIB|PlotterEditor
[ilink32 Error] Error: Unresolved external '__fastcall Designintf::RegisterComponentEditor(System::TMetaClass *, System::TMetaClass *)' referenced from C:\USERS\PUBLIC\DOCUMENTS\EMBARCADERO\STUDIO\15.0\DCP\SAMSPACKAGE.LIB|TPlotter


What does this mean?

I'm using Win7 32-bit, C++ builder XE7 Starter
Remy Lebeau (Te...


Posts: 9,447
Registered: 12/23/01
Re: Unresolved external erro when no compiled with no link to runtimepackages  
Click to report abuse...   Click to reply to this thread Reply
  Posted: Feb 19, 2016 10:47 AM   in response to: Sam Verstaen in response to: Sam Verstaen
Sam wrote:

When doing this, I get following error :

{code}

[ilink32 Error] Error: Unresolved external '__fastcall
Designeditors::TComponentEditor::TComponentEditor(System::Classes::TCo
mponent *, System::DelphiInterface<Designintf::IDesigner>)' referenced
from
C:\USERS\PUBLIC\DOCUMENTS\EMBARCADERO\STUDIO\15.0\DCP\SAMSPACKAGE.LIB|
PlotterEditor

You clearly have design-time code in a runtime package. DO NOT DO THAT!
You must put your run-time code in a runtime-only package, and your design-time
code in a separate designtime-only package that Requires the runtime package.

--
Remy Lebeau (TeamB)
Sam Verstaen

Posts: 2
Registered: 1/12/13
Re: Unresolved external erro when no compiled with no link to runtime packages  
Click to report abuse...   Click to reply to this thread Reply
  Posted: Feb 20, 2016 8:15 AM   in response to: Sam Verstaen in response to: Sam Verstaen
Ok, from other forums and consulting the almighty internet, I got indeed several hints that it was indeed related to a split into design and runtime packages. Unfortunately the Embarcadero documentation is not so clear about this issue, so I post here below my solution, for future reference to anyone.

So, you can make runtime and design time packages. The documentation about this is pretty clear : "Run-time packages provide functionality when a user runs an application. Design-time packages are used to install components in the IDE and to create special property editors for custom components."
However what I was struggling with is what code should belong to run time and what to design time packages.

From other forums I found also this:
italics
You can group the two codebases (runtime and design time parts) into a single package only if your design-time code does not do anything that is not forbidden in run-time code, such as implementing design-time editors/wizards. If all your design-time code is doing is registering your component(s), then that is fine because RegisterComponents() is implemented in the RTL's runtime package. But anything beyond that, you must split the code into separate run-time and design-time packages. Design-time code is not allowed to be linked into run-time executables.

The run-time package must be marked in the Project Options as being runtime only, and links to the RTL/VCL runtime packages as needed. The design-time package must be marked as being designtime only in the Projct Options, link to the RTL's DesignIDE package, and Require your runtime package.

Then the Register() function must be moved from the run-time package into the design-time package. Then also the namespace has to be modified according to the file in which the Register() function is declared.
italics
Also realize that when creating a new package, the default setting (in Menu->Project->Options->Description->Usage options) for type of package is "Design and runtime" (don't know what that means though).

So, to solve my problem, in practice it meant :
- Make a new package, called something that refers to Design Time, e.g. add "DT" at the end
- Change the package type (Options->Description) of the original package into "Runtime only", and the package type of the new package into "Designtime only"
- In the DT package, make a new source file that refers to design time (e.g. TPlotterDP.cpp in my case)
- Remove following code from the original package source file (e.g. TPlotter.cpp) and place it into the newly made design time source file
\code
//---------------------------------------------------------------------------
static inline void ValidCtrCheck(TPlotter *)
{
new TPlotter(NULL);
}
//---------------------------------------------------------------------------
namespace Tplotter
{
void __fastcall PACKAGE Register()
{
TComponentClass classes[1] = {__classid(TPlotter)};
RegisterComponents(L"Sam", classes, 0);
RegisterComponentEditor(classes[0], __classid(TPlotterEditor));
}
}
//---------------------------------------------------------------------------
\endcode
- If copy-pasted, you might need to change the namespace nominator also e.g. to namespace Tplotterdt
- In the header file, do not forget to include the header files of the component itself (e.g. in my case "TPlotter.h")
- In the runtime source code, also remove any references to the design time editor, if any, and place it into the newly made design time source file, e.g. #include "PlotterEditor.h" and #include "FormPlotterEditor.h"
- If any, remove editor source files (e.g. "PlotterEditor") from the runtime package and include it in the design time package.

Then compile/build the runtime package and the design time package and install the components. Works fine now for me.

Further note: I came across this problem when I was trying to make a self standing exe, i.e. an exe file which includes all the libs and packages and does not need separate distribution of these bpi/dll files.
Hereby I also realized that there are TWO settings to be changed in Menu->Project->Options...
- Runtime Packages : deselect "Link with runtime packages"
- C++ Linker : deselect "Link with Dynamic RTL"

Hope it might help someone in the future...
Remy Lebeau (Te...


Posts: 9,447
Registered: 12/23/01
Re: Unresolved external erro when no compiled with no link to runtimepackages  
Click to report abuse...   Click to reply to this thread Reply
  Posted: Feb 22, 2016 10:10 AM   in response to: Sam Verstaen in response to: Sam Verstaen
Sam wrote:

However what I was struggling with is what code should belong to run time
and what to design time packages.

Any code directly related to the functionality of the actual component itself
goes in the runtime package.

Any code related to the IDE's interaction with the component goes in the
designtime package.

Also realize that when creating a new package, the default setting (in
Menu->Project->Options->Description->Usage options) for type of
package is "Design and runtime" (don't know what that means though).

Exactly what its name suggests. It makes the package usable as both a
runtime package and a designtime package without having to separate the code
into two different packages. This works only in one situation, mentioned
in the comments you quoted:

"You can group the two codebases (runtime and design time parts) into a single
package **only if** your design-time code does not do anything that is not
forbidden in run-time code, such as implementing design-time editors/wizards.
If all your design-time code is doing is registering your component(s), then
that is fine because RegisterComponents() is implemented in the RTL's runtime
package."

Most component developers do not usually need to implement custom editors
for their components, that is why the default setting is for a package to
be both runtime and designtime. When you start implementing custom editors,
then you have to create separate packages.

--
Remy Lebeau (TeamB)
Legend
Helpful Answer (5 pts)
Correct Answer (10 pts)

Server Response from: ETNAJIVE02