简体   繁体   English

将BPL与在其他BPL中实现的组件一起安装

[英]Install BPL with components implemented in an other BPL in

I am using C++ Builder 10 Seattle and i am trying to install a component package which registers components that are implemented in a different bpl. 我正在使用C ++ Builder 10 Seattle,并且试图安装一个组件包,该组件包注册在其他bpl中实现的组件。

Technically i have done this: 从技术上讲,我这样做:

I created two packages. 我创建了两个包。 One is defined as runtime only (comps.bpl), the other is for design time (compsIDE.bpl). 一个定义为仅运行时(comps.bpl),另一个定义为设计时(compsIDE.bpl)。 All components I implemented my self are contained in the runtime lib. 我实现自己的所有组件都包含在运行时库中。 In the package for design time I included the fcomps.bpi and add a Unit called compsreg.cpp. 在设计时间包中,我包含了fcomps.bpi并添加了一个名为compsreg.cpp的单元。 In the Unit I use the following code to install components from comps.lib: 在单元中,我使用以下代码从comps.lib安装组件:

#include "MyComponent.h"

namespace comps
{
    void __fastcall PACKAGE Register()
    {
        TComponentClass classes[1] = {__classid(TMyComponent)};
        RegisterComponents("MyComponents", classes, 0);
    }
}

The problem is that the components doesn't get installed. 问题是没有安装组件。 I use the same technique for Delphi units, which are also included in the comps.bpl and they get installed. 我对Delphi单元使用了相同的技术,这些单元也包含在comps.bpl中并安装了它们。

Has anybody an idea why the Register method don't register the components? 有谁知道为什么Register方法不注册组件? I think the only reason can be that the method never gets called for C++ but for Delphi... 我认为唯一的原因可能是该方法从未被C ++调用,而是被Delphi调用...

Hoping for your help... Kerem 希望得到您的帮助...

add a Unit called compsreg.cpp 添加一个名为compsreg.cpp的单元

This is the root of the problem. 这是问题的根源。 The namespace in the file MUST match the filename, otherwise the IDE will not be able to find the exported Register() function correctly. 文件中的namespace必须与文件名匹配,否则IDE将无法正确找到导出的Register()函数。 You need to change namespace comps to namespace compsreg instead. 您需要改为将namespace comps更改为namespace compsreg

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM