Mihail
Mihail

Reputation: 125

Modifying tasks.json to compile multiple c++ files

I have 2 cpp files in /home/misha/proga/c++again folder: one with main function, and another with a function definition declared in the first one. I want to compile both of them. Here https://code.visualstudio.com/docs/cpp/config-mingw#_modifying-tasksjson it explains how to do that, but I'm stuck.

First, I build C/C++: g++ build active task. Second, I replace ${workspaceFolder}\\*.cpp instead of ${file}. Then, if I run built task, it says that g++: error: /home/misha/proga/c++again*.cpp: No such file or directory

What am I doing wrong? Thanks.

I'm using Ubuntu 19.10 and VSC 1.46.1

File1:

#include <iostream>

using std::cout;

int sum(int, int);

int main(){
    cout<< sum(2,3)<< "\n";
    return 0;
}

File2:

int sum(int a, int b){
return a+b;
}

Upvotes: 1

Views: 2028

Answers (1)

Sunchock
Sunchock

Reputation: 388

As say in comments you try to compile /home/misha/proga/c++again*.cpp who not exists because the compiler try to compile all files in proga folder who begins with c++again and ends with .cpp

Be sure to have the / character between your folder's name and your sources files names at the compilation time.

Upvotes: 1

Related Questions