小编Cas*_*ion的帖子

尝试使用 gcc 编译用 C 编写的简单 dll 失败

尝试使用 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)

c dll gcc declspec

3
推荐指数
1
解决办法
5353
查看次数

标签 统计

c ×1

declspec ×1

dll ×1

gcc ×1