【发布时间】:2020-03-11 00:18:39
【问题描述】:
我正在尝试在 c 中使用我的头文件。当我使用代码块时,它会处理标题包含部分,但在 vs 代码中,我还无法弄清楚。这就是我在 vs 代码中得到的。这些文件位于同一文件夹中。我正在使用 gcc。
#include "assPQ.h"
。 . .
PS C:\Users\xxx\Desktop\xxxx\ass> cd "c:\Users\xxx\Desktop\xxxx\ass\" ; if ($?) { gcc coffeeShopSimulator.c -o coffeeShopSimulator } ; if ($?) { .\coffeeShopSimulator }
c:/mingw/bin/../lib/gcc/mingw32/8.2.0/../../../../mingw32/bin/ld.exe: C:\Users\xxx\AppData\Local\Temp\cc6RasGF.o:coffeeShopSimulator.c:(.text+0xf): undefined reference to `CreateListPQ'
【问题讨论】:
-
“使用我的头文件”还是使用库?
-
看起来你的头文件是方形的,这是链接器抱怨它找不到
CreateListPQ函数的二进制代码:stackoverflow.com/questions/22426574/gcc-undefined-reference-to -
我正在写标题。 assPQ.h 和 assPQ.c 在 main.c 中使用,然后我收到错误消息。
-
你的构建线是什么?您需要包含 assPQ.c 文件,例如“gcc assPQ.c main.c”
-
{ "type": "shell", "label": "gcc.exe build active file", "command": "C:\\MinGW\\bin\\gcc.exe", "args": [ "-g", "${file}", "-o", "${fileDirname}\\${fileBasenameNoExtension}.exe" ], "options": { "cwd": "C:\\MinGW\\bin" }, "problemMatcher": [ "$gcc" ], "group": "build" }你是说这个吗?
标签: c gcc visual-studio-code header include