编译链接问题

问题描述

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"
}
相关推荐
泡海椒22 分钟前
告别 iText 繁杂配置:jquick-pdf 极简 PDF 生成实战(零基础上手)
java·开发语言·pdf
Navigator_Z10 小时前
LeetCode //MySQL - 1251. Average Selling Price
c语言·算法·leetcode
君顾111 小时前
上海24小时自助健身房系统开发实战指南:从架构设计到落地部署
java·开发语言·健身房
Escalating_xu11 小时前
【C语言数据类型和变量·上】从内置类型到变量模型:一次讲透 sizeof、signed/unsigned 与作用域
c语言
香菜TTT12 小时前
大模型上下文协议(MCP):AI 应用的“USB-C”接口技术
开发语言·人工智能·经验分享
aramae12 小时前
模拟实现strlen()函数 (C语言)
c语言·开发语言·后端
jimy113 小时前
readelf 查看“派生类”的vtable符号
开发语言·c++
ctlover14 小时前
排序与查找算法详解
开发语言·python
YYYing.14 小时前
【C++进阶系列 (七)】C++ RTTI 深度剖析:从 typeid 到 dynamic_cast 的底层之旅
开发语言·c++·c/c++·rtti
多弗朗皮卡丘15 小时前
数据结构9:排序算法
c语言·数据结构·排序算法