Windows表单应用程序与DLL链接 [英] Windows form application linking with DLL

查看:49
本文介绍了Windows表单应用程序与DLL链接的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述


我在c ++中有一个Windows窗体应用程序(vs2015)。我想将DLL链接到这个应用程序并使用dll函数。


我有一个类库项目(.dll)


// test.h   //标题文件


#include" test1.h" //使用的结构在这里定义


命名空间测试


{


class Class1


{


public:


static int write(WRITE_TEST writetest);


};


}


// #include test.cpp


#include" test.h" ;


命名空间测试{


int Class1 :: write(WRITE_TEST writetest){


//实现。


}


以上代码构建为DLL。



<我有一个Windows窗体应用程序。我在这个表单应用程序中添加了上面的dll作为参考。还包括其他包含目录中的dll路径。


#include" test.h"


  &NBSP;测试::的Class1 ::写(writetest); //从dll调用函数。



但我得到的错误是未解析的令牌(0A000499)public:static int _cdecl   test: :Class1 :: write(struct)。



从DLL调用函数时有什么遗漏?

解决方案


我在c ++中有一个Windows窗体应用程序(vs2015)。我想将DLL链接到此应用程序并使用DLL函数...


...



还包括其他包含目录中的dll路径。






为什么这样?附加的include目录属性告诉编译器

在哪里查找其他文件。 (与#include语句一样。)



阅读本文:
$


使用非托管C ++ .NET应用程序中的库(DLL)

https://www.codeproject.com/Articles/14180/Using-Unmanaged-C-Libraries-DLLs-in-NET-Applicatio



这个帖子:



如何在Visual Studio中的Windows Form C ++ .NET项目中添加原生C ++ dll?

http://stackoverflow.com/questions/8711870/how-to-adda-native-c-dll-in-a-windows-form-c-net-project-in-visual-工作室



- Wayne


Hi,

i have a windows form application(vs2015) in c++. i want to link DLL to this application and use dll functions.

i have a class library project(.dll)

//test.h  //header file

#include "test1.h" //structures used are defined here

namespace test

{

class Class1

{

public :

static int write(WRITE_TEST writetest);

};

}

//#include test.cpp

#include "test.h"

namespace test{

int Class1::write(WRITE_TEST writetest){

//implementation.

}

Above code built as DLL.

i have a windows form application. i added the above dll as reference in this form application. Also included the dll path in additional include directories.

#include "test.h"

    test::Class1::write(writetest); //calling function from dll.

but i get the error as unresolved token(0A000499) public:static int _cdecl  test::Class1::write(struct ).

Anything am missing for calling the function from DLL?

解决方案

i have a windows form application(vs2015) in c++. i want to link DLL to this application and use dll functions...

...

Also included the dll path in additional include directories.


Why do that? The additional include directories property tells the compiler
where to look for additional header files. (As in #include statements.)

Read this article:

Using Unmanaged C++ Libraries (DLLs) in .NET Applications
https://www.codeproject.com/Articles/14180/Using-Unmanaged-C-Libraries-DLLs-in-NET-Applicatio

And this thread:

how to adda native C++ dll in a Windows Form C++.NET project in visual studio?
http://stackoverflow.com/questions/8711870/how-to-adda-native-c-dll-in-a-windows-form-c-net-project-in-visual-studio

- Wayne


这篇关于Windows表单应用程序与DLL链接的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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