本机C ++:编写和调用DLL的示例 [英] native C++: an example of writing and calling a DLL

查看:57
本文介绍了本机C ++:编写和调用DLL的示例的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

Hi Gang:

这位C ++新手感到沮丧.

我已经用本机C ++为客户端编写了一个仪器驱动程序.我需要将其包装在可以由其现有应用程序调用的DLL中.我的交付物之一是一个简单的测试应用程序,它演示了DLL的功能.

我没想到会有这么多麻烦!我还没有找到调用简单DLL的方法.我有一本书中的示例无效,而MSDN中的示例无效.我正在使用VS2005.

这是我通过非常简单的控制台应用程序调用非常简单的DLL时遇到的错误:

错误1错误LNK2019:无法解析的外部符号公共:静态double __cdecl MyFuncs :: MyMathFuncs :: Add(double,double)"(?Add @ MyMathFuncs @ MyFuncs @@ SANNN @ Z)在函数_wmain中引用ExecDLL.obj

我已经在项目属性中设置了DLL的路径.似乎正在查看头文件中的代码:"__cedcl MyFuncs ... etc.

但是我被困住了.如果我有一个可行的简单示例,则可以从那里开始构建.

我真的很感激任何帮助.

谢谢,

Roger

Hi Gang:

This C++ newbie is getting frustrated.

I''ve written an instrument driver in native C++ for a client. I need to wrap it in a DLL that can be called by their existing application. One of my deliverables is a simple test application that demonstrates the DLL''s functions.

I never anticipated having this much trouble! I haven''t found a way to call a simple DLL. The example from a book I have doesn''t work and the example in MSDN doesn''t work. I''m using VS 2005.

Here''s the error I get for calling a very simple DLL with a very simple console application:

Error 1 error LNK2019: unresolved external symbol "public: static double __cdecl MyFuncs::MyMathFuncs::Add(double,double)" (?Add@MyMathFuncs@MyFuncs@@SANNN@Z) referenced in function _wmain ExecDLL.obj

I''ve set the path to the DLL in the project properties. It seems like it is seeing the code in the header file: "__cedcl MyFuncs...etc.

But I''m stuck. If I had a simple example that worked, I can build from there.

I''ll REALLY APPRECIATE any help.

Thanks,

Roger

推荐答案

Google(和MSDN)可以解救! 演练:创建和使用动态链接库 [ ^ ]它"甚至对于VS2005也是如此!

下次,请尝试首先使用Google搜索.
Google (and MSDN) to the rescue! Walkthrough: Creating and Using a Dynamic Link Library [^] It''s even for VS2005!

Next time, try googling first...


这不是DLL,而是链接器的问题;您是否已将 .lib 文件的路径添加到项目中?
This is not a DLL but a linker issue; have you added the path to the .lib file to your project?


这篇关于本机C ++:编写和调用DLL的示例的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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