以下是practise檔案夾下三個可用檔案:
hello.h
#ifndef HELLO_H_
#define HELLO_H_
void hello();
#endif // !HELLO_H_
file.cpp
#include <iostream>
#include "hello.h"
using namespace std;
void hello()
{
cout << "Hello.c++" << endl;
}
主函式檔案hello.cpp
#include <iostream>
#include"hello.h"
int main(int argc, char **argv)
{
hello();
system("pause");
return 0;
}
然后不知道怎么才能給配置好多檔案編譯環境,另外在終端進行命令編譯卻顯示無法查找相關檔案
命令:g++ .\hello.cpp .\file.cpp -o hello
輸出:
PS H:\project\vscode course\c++_course> g++ .\hello.cpp .\file.cpp -o hello
g++.exe: error: .\hello.cpp: No such file or directory
g++.exe: error: .\file.cpp: No such file or directory
g++.exe: fatal error: no input files
uj5u.com熱心網友回復:
是在作業檔案夾新建的practise檔案夾,現在用vscode打開這個檔案夾,然后g++ -g hello.cpp file.cpp -o hello就成功了,但我想知道這個環境配置如何配置,多檔案編譯的vscode配置。轉載請註明出處,本文鏈接:https://www.uj5u.com/houduan/254134.html
標籤:工具平臺和程序庫
下一篇:程式報錯求解!!!
