鱼C论坛

 找回密码
 立即注册
查看: 1603|回复: 3

[已解决]vscode里C语言多文件编程debug弹出error -1

[复制链接]
发表于 2022-6-24 04:40:44 | 显示全部楼层 |阅读模式

马上注册,结交更多好友,享用更多功能^_^

您需要 登录 才可以下载或查看,没有账号?立即注册

x

vscode里debug源文件的时候不仅自动把我放在同一个文件夹里的exe文件给删除了,而且弹出了这个

> Executing task: C/C++: gcc.exe 生成活动文件 <

正在启动生成...
E:\msys2\mingw64\bin\gcc.exe -fdiagnostics-color=always -g C:\Users\wyy\Desktop\summer\program\C_project\src\TarjanDFS.c -o C:\Users\wyy\Desktop\summer\program\C_project\src\TarjanDFS.exe
E:/msys2/mingw64/bin/../lib/gcc/x86_64-w64-mingw32/10.3.0/../../../../x86_64-w64-mingw32/bin/ld.exe: C:\Users\wyy\AppData\Local\Temp\cc3M2Y92.o: in function `Tarjan':
C:/Users/wyy/Desktop/summer/program/C_project/src/TarjanDFS.c:19: undefined reference to `CreateStack'
E:/msys2/mingw64/bin/../lib/gcc/x86_64-w64-mingw32/10.3.0/../../../../x86_64-w64-mingw32/bin/ld.exe: C:/Users/wyy/Desktop/summer/program/C_project/src/TarjanDFS.c:21: undefined reference to `push'
E:/msys2/mingw64/bin/../lib/gcc/x86_64-w64-mingw32/10.3.0/../../../../x86_64-w64-mingw32/bin/ld.exe: C:/Users/wyy/Desktop/summer/program/C_project/src/TarjanDFS.c:51: undefined reference to `pop'
E:/msys2/mingw64/bin/../lib/gcc/x86_64-w64-mingw32/10.3.0/../../../../x86_64-w64-mingw32/bin/ld.exe: C:\Users\wyy\AppData\Local\Temp\cc3M2Y92.o: in function `main':
C:/Users/wyy/Desktop/summer/program/C_project/src/TarjanDFS.c:69: undefined reference to `CreateDirGraph'

collect2.exe: error: ld returned 1 exit status
生成已完成,但出现错误。
The terminal process terminated with exit code: -1.


exe 文件由makefile生成的,这里是makefile配置
#
# 'make'        build executable file 'main'
# 'make clean'  removes all .o and executable files
#

# define the C compiler to use
CC = gcc

# define any compile-time flags
CFLAGS        := -Wall -Wextra -g

# define library paths in addition to /usr/lib
#   if I wanted to include libraries not in /usr/lib I'd specify
#   their path using -Lpath, something like:
LFLAGS =

# define output directory
OUTPUT        := C:\Users\wyy\Desktop\summer\program\C_project

# define source directory
SRC                := src

# define include directory
INCLUDE        := include

# define lib directory
LIB                := lib

ifeq ($(OS),Windows_NT)
MAIN        := TarjanDFS.exe
SOURCEDIRS        := $(SRC)
INCLUDEDIRS        := $(INCLUDE)
LIBDIRS                := $(LIB)
FIXPATH = $(subst /,\,$1)
RM                        := del /q /f
MD        := mkdir
else
MAIN        := TarjanDFS
SOURCEDIRS        := $(shell find $(SRC) -type d)
INCLUDEDIRS        := $(shell find $(INCLUDE) -type d)
LIBDIRS                := $(shell find $(LIB) -type d)
FIXPATH = $1
RM = rm -f
MD        := mkdir -p
endif

# define any directories containing header files other than /usr/include
INCLUDES        := $(patsubst %,-I%, $(INCLUDEDIRS:%/=%))

# define the C libs
LIBS                := $(patsubst %,-L%, $(LIBDIRS:%/=%))

# define the C source files
SOURCES                := $(wildcard $(patsubst %,%/*.c, $(SOURCEDIRS)))

# define the C object files
OBJECTS                := $(SOURCES:.c=.o)

#
# The following part of the makefile is generic; it can be used to
# build any executable just by changing the definitions above and by
# deleting dependencies appended to the file from 'make depend'
#

OUTPUTMAIN        := $(call FIXPATH,$(OUTPUT)/$(MAIN))

all: $(OUTPUT) $(MAIN)
        @echo Executing 'all' complete!

$(OUTPUT):
        $(MD) $(OUTPUT)

$(MAIN): $(OBJECTS)
        $(CC) $(CFLAGS) $(INCLUDES) -o $(OUTPUTMAIN) $(OBJECTS) $(LFLAGS) $(LIBS)

# this is a suffix replacement rule for building .o's from .c's
# it uses automatic variables $<: the name of the prerequisite of
# the rule(a .c file) and $@: the name of the target of the rule (a .o file)
# (see the gnu make manual section about automatic variables)
.c.o:
        $(CC) $(CFLAGS) $(INCLUDES) -c $<  -o $@

.PHONY: clean
clean:
        $(RM) $(OUTPUTMAIN)
        $(RM) $(call FIXPATH,$(OBJECTS))
        @echo Cleanup complete!

run: all
        ./$(OUTPUTMAIN)
        @echo Executing 'run: all' complete!





谢谢各位相助啊
最佳答案
2022-6-24 09:15:17
        错误原因是,被调用的函数 “CreateStack()” 未定义。
想知道小甲鱼最近在做啥?请访问 -> ilovefishc.com
回复

使用道具 举报

发表于 2022-6-24 09:15:17 From FishC Mobile | 显示全部楼层    本楼为最佳答案   
        错误原因是,被调用的函数 “CreateStack()” 未定义。
想知道小甲鱼最近在做啥?请访问 -> ilovefishc.com
回复 支持 反对

使用道具 举报

发表于 2022-6-24 09:29:19 | 显示全部楼层
in function `Tarjan':
    undefined reference to `CreateStack'
TarjanDFS.c:21: undefined reference to `push'
TarjanDFS.c:51: undefined reference to `pop'
in function `main':
    TarjanDFS.c:69: undefined reference to `CreateDirGraph'

这报错信息都告诉你了,你就是不看
想知道小甲鱼最近在做啥?请访问 -> ilovefishc.com
回复 支持 反对

使用道具 举报

 楼主| 发表于 2022-6-26 04:13:41 | 显示全部楼层
那好像是个bug真的不是我的锅
想知道小甲鱼最近在做啥?请访问 -> ilovefishc.com
回复 支持 反对

使用道具 举报

您需要登录后才可以回帖 登录 | 立即注册

本版积分规则

小黑屋|手机版|Archiver|鱼C工作室 ( 粤ICP备18085999号-1 | 粤公网安备 44051102000585号)

GMT+8, 2024-10-6 05:53

Powered by Discuz! X3.4

© 2001-2023 Discuz! Team.

快速回复 返回顶部 返回列表