从调用一个Win32的.lib项目函数使用/ clr从一个项目,是一个纯粹的Win32项目,没有CLR [英] Calling a function from a Win32 .lib project with /clr from a project that is a pure Win32 project, no clr

查看:291
本文介绍了从调用一个Win32的.lib项目函数使用/ clr从一个项目,是一个纯粹的Win32项目,没有CLR的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想知道我怎么叫究竟从项目A :: ClassA的:: FuncA(功能),它是从项目B :: ClassB的一个Win32的.lib使用/ clr :: FuncB()不具有CLR支持是一个纯粹的Win32项目。 这两个项目都是在相同的解决方案。

I want to know how do I exactly call a function from ProjectA::ClassA::FuncA() that is a Win32 .lib with /clr from a ProjectB::ClassB::FuncB() that does not have clr support and is a pure Win32 project. Both these projects are under same solution.

首先,这是我曾尝试: 1.创建的项目A与.LIB 2.增加的.lib路径项目B的属性(在连接器:输入:Add.Dependencies) 3.我增加了.H由项目A在项目B产生的.LIB 4.创建了项目A :: ClassA的对象在项目B :: ClassB的,并试着拨打FuncA()。

First, this is what I have tried: 1. Created the ProjectA with the .lib 2. Added the .lib path to ProjectB properties (in Linker:Input:Add.Dependencies) 3. I added the .h for the .lib created by ProjectA in ProjectB 4. Created the object for ProjectA::ClassA in ProjectB::ClassB and tried to call the FuncA().

我收到以下错误:

1错误LNK2019错误:无法解析的外部符号市民:静态无效__cdecl ClassA的:: FuncA(无效)(FuncA @ ClassA的@@ SAXXZ?)的函数引用市民:静态无效__cdecl ClassB的:: FuncB(无效) (?FuncB @ ClassB的@@ SAXXZ)Helper.obj

Error 1 error LNK2019: unresolved external symbol "public: static void __cdecl ClassA::FuncA(void)" (?FuncA@ClassA@@SAXXZ) referenced in function "public: static void __cdecl ClassB::FuncB(void)" (?FuncB@ClassB@@SAXXZ) Helper.obj

我使用第三方的.lib S在项目B成功。我遵循相同的过程,但它失败;唯一的区别是项目A()是使用CLR支持

I am using third-party .lib s in ProjectB successfully. I follow the same process but it fails; the only difference being ProjectA() is with CLR support.

我缺少的东西?请赐教; - )

Am I missing something? Please enlighten me ;-)

谢谢!

推荐答案

本机code可以调用管理code,但一个需要在同/ CLR编译源$ C ​​$ C文件来完成。你需要一点点的适配器类的原生(没有参考)的项目B。如果这些实例方法,那么你就需要 gcroot<>在适配器存储一个引用托管类。

Native code can call managed code but that needs to be done in a source code file that's compiled with /clr. You need a little adapter class that's native (no "ref") in ProjectB. If these are instance methods then you'll need gcroot<> in the adapter to store a reference to the managed class.

这篇关于从调用一个Win32的.lib项目函数使用/ clr从一个项目,是一个纯粹的Win32项目,没有CLR的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆