尝试使用 gcc 编译一个用 C 编写的简单 DLL。
尝试遵循许多教程,但即使我将文件精简到最基本的内容,也无法编译它。
test_dll.c
#include <stdio.h>
__declspec(dllexport) int __stdcall hello() {
printf ("Hello World!\n");
}
Run Code Online (Sandbox Code Playgroud)
尝试使用命令编译它
gcc -c test_dll.c
Run Code Online (Sandbox Code Playgroud)
失败,得到这个输出
test_dll.c: In function '__declspec':
test_dll.c:3:37: error: expected '=', ',', ';', 'asm' or '__attribute__' before 'hello'
__declspec(dllexport) int __stdcall hello() {
^
test_dll.c:5:1: error: expected '{' at end of input
}
^
Run Code Online (Sandbox Code Playgroud)
海湾合作委员会版本
gcc version 4.8.4 (Ubuntu 4.8.4-2ubuntu1~14.04.3)
Run Code Online (Sandbox Code Playgroud)