【发布时间】:2014-04-16 11:27:23
【问题描述】:
我用 C 语言开发了一个 dll,并用这种方法调用了我的 C++ 程序
#include <cstdlib>
#include <iostream>
#include <windows.h>
#ifdef __cplusplus
extern "C" {
#endif
#include "mydll.h"
#ifdef __cplusplus
}
#endif
using namespace std;
int main(int argc, char *argv[])
{
struct myown_struct *ss = NULL;
int i = 0,j = 0, result = 0;
struct myown_struct2 *s = NULL;
myfunction("string1", "string2", "string3", 1500);
system("PAUSE");
return EXIT_SUCCESS;
}
mydll.h:
#ifndef _DLL_H_
#define _DLL_H_
#if BUILDING_DLL
# define DLLIMPORT __declspec (dllexport)
#else /* Not BUILDING_DLL */
# define DLLIMPORT __declspec (dllimport)
#endif /* Not BUILDING_DLL */
struct myown_struct {
int fd;
char buf[32];
unsigned int len;
} __attribute__((packed));
DLLIMPORT void myfunction(char *s1, char* s2, char *s3, int n);
#endif /* _DLL_H_ */
我收到此错误:
C:\Users\user01\Desktop\test\main.cpp 在函数int main(int, char**)
C:\Users\user01\Desktop\test\main.cppmyfunction' undeclared (first use this function)
我该如何解决?
【问题讨论】:
-
向我们展示 mydll.h?似乎您的用法与标头中的签名不匹配,或者未在标头中声明。
-
@crashmstr:你可以看到我的更新
标签: c++ c visual-studio-2012 dll dev-c++