编译链接问题

问题描述

C语言在编译的时候,提示链接的时候没有找到相应的方法

问题分析

代码文件结构:

test.c

test/1.c

test/1.h

test.c代码:

#include "test/1.h"

void main() {

hello();

}

test/1.c代码:

void hello() {

printf("hello");

}

test/1.h代码:

#include "stdio.h"

void hello();

问题解决

由于IDE使用的是vscode, 它使用json文件来管理编译,需要修改json文件:

task.json文件:

cpp 复制代码
{
    "tasks": [
        {
            "type": "cppbuild",
            "label": "C/C++: cl.exe build active file",
            "command": "cl.exe",
            "args": [
                "/Zi",
                "/EHsc",
                "test\\1.c",//修改这里
                "/Fe${fileDirname}\\${fileBasenameNoExtension}.exe",
                "${file}"
            ],
            "options": {
                "cwd": "${fileDirname}"
            },
            "problemMatcher": [
                "$msCompile"
            ],
            "group": {
                "kind": "build",
                "isDefault": true
            },
            "detail": "Task generated by Debugger."
        }
    ],
    "version": "2.0.0"
}
相关推荐
坚持编程的菜鸟15 小时前
模拟实现memmove
c语言·算法·模拟实现memmove
BUG研究员_15 小时前
Runnable与LCEL
开发语言·人工智能·python
坚持编程的菜鸟17 小时前
编写判断大小端程序
c语言·算法·判断大小端
牛艺翔17 小时前
C++基础
开发语言·c++
键盘会跳舞17 小时前
C++ :容器适配器stack源码级拆解
开发语言·c++··stack·先进后出
美味蛋炒饭.17 小时前
Git 版本控制(下)
开发语言·git·学习·总结·后端开发
我星期八休息18 小时前
网络编程—网络层
开发语言·前端·网络·人工智能·智能路由器
问商十三载18 小时前
RAG 检索效果差怎么排查?2026 五层诊断法完整指南
开发语言·人工智能·windows·python·算法
不负岁月无痕18 小时前
简单理解操作系统结构
java·linux·c语言·开发语言·c++·面试
SomeB1oody18 小时前
【RustyML入门】2.9. MeanShift
开发语言·后端·机器学习·rust·教程