我正在尝试编译并链接以下源和头文件
#include <stdio.h>
#include "source.h"
int main(void)
{
three_lines();
return 0;
}
void three_lines(void);
使用如下所示的命令。
cl /W4 /EHsc source.c /link source.h
但是我收到以下错误。
Microsoft (R) C/C++ Optimizing Compiler Version 19.14.26433 for x86
Copyright (C) Microsoft Corporation. All rights reserved.
source.c
Microsoft (R) Incremental Linker Version 14.14.26433.0
Copyright (C) Microsoft Corporation. All rights reserved.
/out:source.exe
source.h
source.obj
source.h : fatal error LNK1107: invalid or corrupt file: cannot read at 0x61
有人可以指导我如何解决这个问题吗?
提前谢谢了。
/link
选项用于将目标文件链接在一起。你有一个头文件。这不会被链接,而是包含在内。当您使用#include "source.h"
时,预处理器会自动执行此操作。
摆脱/link
选项,它应该编译。