从库创建 DLL,无需任何新代码
我有一个使用托管 c++ 并使用本机 c++ 库的 dll。然后这个 dll 又被 ac# 接口使用。正如您可能猜到的,托管 C++ 只是互操作代码。其中没有任何内容被导出。
我们有一个新要求,即托管 C++ 和本机 C++ 都可由外部 C++ 可执行文件访问(用于内部测试目的)。因此,我正在考虑将托管 C++ 层更改为库,并有一个单独的项目,通过使用托管库和本机库来创建 dll。那里不会有任何新代码。这只是一个消耗两个库的项目。然后,我们可以有另一个项目,它也使用这两个库并在上面添加一些测试代码。但我在让它发挥作用方面遇到了很大的困难。我无法让 IDE 生成我的 dll。有人对我有什么建议吗?
I have a dll that uses managed c++ and consumes a native c++ library. This dll is then in turn consumed by a c# interface. As you probably guessed, the managed c++ is just interop code. Nothing in this is exported.
We have a new requirement that both the managed c++ and native c++ be accessed by an external c++ executable (for internal testing purposes). So I was thinking of changing the managed c++ layer to a lib, and have a separate project that creates the dll by consuming the managed and the native libs. There wouldn't be any new code in there. It's just a project that consumes the two libs. Then, we could have another project that also consumes these two libs and adds on top a bit of test code. But I'm having a great deal of difficulty in getting this to work. I cannot get the IDE to generate my dll. Does anyone have any suggestions for me?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
您无法从托管代码创建静态链接库,VS 构建系统不支持它。托管代码的存储单元是程序集。它们不是在构建时链接的,而是在运行时发生的。请注意,需要管理您的测试程序才能测试您的包装器。
You cannot create a static link library from managed code, there's no support for it in the VS build system. The unit of storage for managed code is an assembly. They are not linked at build time, it happens at runtime. Beware that your test program needs to be managed in order to test your wrapper.