使用动态库 [英] Using dynamic libraries

查看:46
本文介绍了使用动态库的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在尝试使用Visual Studio和C#编写网站.我需要使用C ++库A.我有A.h标头,A.lib是静态版本,A.dll是动态版本.

我需要编写自己的函数库-B库,在C ++中也将使用库A .由于最终结果是一个网站,因此我需要创建动态库(?).我跟着 来自http://msdn.microsoft.com/zh-cn/library/ms235636.aspx的创建和使用DLL的指令,并且有效.

I need to write my own library of functions - library B, in C++ that will also use library A.  Since the end result is a website, I need to create dynamic libraries (?).  I followed the instruction from http://msdn.microsoft.com/en-us/library/ms235636.aspx to create and use a DLL and that worked.

我尝试编写使用A和B的测试程序C.cpp.我无法识别和使用动态库.是否要使用A.dll或A.lib构建B.dll?我如何能 获取链接器以链接B.dll与A.dll?  如何获取链接器以将C.cpp与A.dll和B.dll链接?

I tried writing a test program C.cpp, that uses A and B.  I cannot get anything to recognize and work with dynamic libraries.  Do I build B.dll using A.dll or A.lib?  How do I get the linker to link B.dll with A.dll?  How do I get the linker to link C.cpp with A.dll and B.dll?

推荐答案

我将创建一个/CLR DLL项目(例如,称为"B",它将创建一个动态链接库称为B.DLL). B的源代码将使用A.h标头,该标头可能声明了A.DLL库的入口点,以便创建包装程序.这 代码应使用C ++/CLI编写,可从任何C#客户端代码中调用.

I would create a /CLR DLL project (say, called "B", which will create a dynamic link library called B.DLL). The source code for B will use the A.h header which presumably declares the entry points to the A.DLL library in order to create your wrapper. The code should be written in C++/CLI which will be callable from any C# client code.

我建议投资 N. Sivakumar的C ++/CLI实战. C ++/CLI的语法不同于C ++,因此无法在这样的简短文章中进行总结.

I suggest investing in the book C++/CLI in Action by N. Sivakumar. The syntax for C++/CLI is different from C++, and cannot sensibly be summarized in a short post like this.


这篇关于使用动态库的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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