I need help to compile a script ("iterator.c") into a DLL. I can't use VS2010 since it does not support the features added to C in the C99 standard (I'm using "complex.h" but VB doesn't support it).
我需要帮助将脚本(“iterator.c”)编译成DLL。我不能使用VS2010,因为它不支持在C99标准中添加到C的功能(我使用“complex.h”但VB不支持它)。
I've been looking for a substitute but all I've found is GCC which I don't know how to install/use (really, I've spent like half an hour reading through the documentation and I don't even understand how am I supposed to install it), and Cygwin, which I've already installed but I don't know how to use either. Also, I've installed MinGW but I think it's the same as Cygwin more or less, and I still don't know how to make a DLL.
我一直在寻找替代品,但我发现的只是GCC,我不知道如何安装/使用(真的,我花了半个小时阅读文档,我甚至不懂我应该安装它,和Cygwin,我已经安装但我不知道如何使用它们。另外,我已经安装了MinGW,但我认为它与Cygwin或多或少相同,我仍然不知道如何制作DLL。
It's not like I've been all lazy and haven't even tried it, it's just that these compilers aren't like nothing I've ever used before (mostly Python IDLE and Visual Studio, which make things pretty easy for you). I'm kind of lost.
这并不像我一直都懒惰甚至没有尝试过,只是因为这些编译器并不像我以前用过的任何东西(主要是Python IDLE和Visual Studio,它们让你很容易)。我有点迷茫。
Could someone give me some advice on how to use this tools to make a DLL that I can access from another script? It is really important.
有人可以给我一些关于如何使用这个工具来制作我可以从另一个脚本访问的DLL的建议吗?这非常重要。
Thank you in advance.
先谢谢你。
1 个解决方案
#1
13
You must place __declspec(dllexport) in front of the method you wish to export such as, you could #define this to max it easier
您必须将__declspec(dllexport)放在要导出的方法的前面,例如,您可以#define这个以便更容易
EXPORT_DLL void hello() { ... }
To compile the dll use
编译dll使用
gcc -c -mno-cygwin mydll.c
gcc -shared -o mydll.dll mydll.o -Wl,--out-implib,libmylib.dll.a
then to attach
然后附上
gcc -o myexe.exe test.o mydll.dll
EDIT: Forgot the most important piece, you need to make a mydll.h file to include your method definition so the compiler knows to reserve a spot for the linker to fill in later on. It's as simple as
编辑:忘记最重要的部分,您需要创建一个mydll.h文件以包含您的方法定义,以便编译器知道为链接器保留一个位置以便稍后填写。这很简单
#ifndef MYDLL_H
#define MYDLL_H
extern "C" __declspec(dllexport)
#define EXPORT_DLL __declspec(dllexport)
EXPORT_DLL void hello();
#endif
#1
13
You must place __declspec(dllexport) in front of the method you wish to export such as, you could #define this to max it easier
您必须将__declspec(dllexport)放在要导出的方法的前面,例如,您可以#define这个以便更容易
EXPORT_DLL void hello() { ... }
To compile the dll use
编译dll使用
gcc -c -mno-cygwin mydll.c
gcc -shared -o mydll.dll mydll.o -Wl,--out-implib,libmylib.dll.a
then to attach
然后附上
gcc -o myexe.exe test.o mydll.dll
EDIT: Forgot the most important piece, you need to make a mydll.h file to include your method definition so the compiler knows to reserve a spot for the linker to fill in later on. It's as simple as
编辑:忘记最重要的部分,您需要创建一个mydll.h文件以包含您的方法定义,以便编译器知道为链接器保留一个位置以便稍后填写。这很简单
#ifndef MYDLL_H
#define MYDLL_H
extern "C" __declspec(dllexport)
#define EXPORT_DLL __declspec(dllexport)
EXPORT_DLL void hello();
#endif