c++ - Visual Studio Code C++ 包含本地文件
问题描述
几天以来,我试图包含我的自定义头文件
你好世界.cpp:
#include <iostream>
#include "MyFunctions.h"
int main(){
printHelloWorld();
return 0;
}
我的函数.cpp
#include <iostream>
#include "MyFunctions.h"
int printHelloWorld(){
std::cout <<"Hello World" << std::endl;
return 0;
}
我的函数.h
#pragma once
int printHelloWorld();
错误信息:
[Running] cd "c:\Users\juriw\Desktop\Projekts\C++\Learning\" && g++ HelloWorld.cpp -o HelloWorld && "c:\Users\juriw\Desktop\Projekts\C++\Learning\"HelloWorld
C:\Users\juriw\AppData\Local\Temp\ccCJZTCT.o:HelloWorld.cpp:(.text+0xc): undefined reference to `printHelloWorld()'
collect2.exe: error: ld returned 1 exit status
到目前为止有什么问题吗?
我多次重新安装 vsc、扩展和编译器。我是新手,不知道代码是错误的还是我搞砸了配置。还有什么我可以告诉你的,以确定问题吗?
解决方案
推荐阅读
- php - Stripe - 将新客户添加到现有计划中?
- laravel - Inertia.js 发布后,有什么方法可以在控制器中下载文件(PDF)?
- django-models - 终端发出不存在 Django 模块“模型”的错误消息,但它在目录中
- prolog - 带有多个谓词的 Prolog setOf
- java - java - 用json对象数组替换JSON中的字符串
- flutter - 命令 PhaseScriptExecution 因非零退出而失败
- linux - 使 socat 链接到 udp rs232 连接的串行设备持久的最佳方法是什么?
- python - 按列过滤熊猫数据帧,然后按列内的值
- angular - 类型 'any[]' 不可分配给类型 'never'
- php - redis导致phpmyadmin中的错误