0

I am trying to compile test.c with "fonction_lire.h and fonction_lire.c" included. The problem is that I get this error during compilation : The terminal process failed to launch (exit code: -1). When I click on "debug anyway" I get this message : "launch: program mypath\test.exe does not exist.

The file test.exe is not created during compilation.

An other question is that when I work in a folder, should a ".vscode" extension with launch.json and task.json need be created for each project or just one time for all my projects in the folder ?

Here is the structure of my folder

fonction_lire.c :

#include <stdlib.h>
#include <stdio.h>
#include <string.h>
#include "fonction_lire.h"

....

fonction_lire.h :

#ifndef H_FILE
#define H_FILE

void viderBuffer();
int lire(char* chaine,int longueur);
long lireLong();
double lireDouble();

#endif

test.c :

#include <stdlib.h>
#include <stdio.h>
#include "fonction_lire.h"

int main(int argc, char *argv[])
{
    double poid = 0;

printf("Combien pesez vous ? ");
poid = lireDouble();
printf("Ah ! Vous pesez donc %f kg !\n\n", poid);

return 0;
}

Executing task: C/C++: gcc.exe build active file

Starting build... C:\msys64\mingw64\bin\gcc.exe -fdiagnostics-color=always -g "C:\Users\Matt7\OneDrive - student.helmo.be\Bureau\MyCApp\fonction_lire\test.c" -o "C:\Users\Matt7\OneDrive - student.helmo.be\Bureau\MyCApp\fonction_lire\test.exe" C:/msys64/mingw64/bin/../lib/gcc/x86_64-w64-mingw32/13.1.0/../../../../x86_64-w64-mingw32/bin/ld.exe: C:\Users\Matt7\AppData\Local\Temp\ccXChbyj.o: in function main': C:/Users/Matt7/OneDrive - student.helmo.be/Bureau/MyCApp/fonction_lire/test.c:10: undefined reference to lireDouble' collect2.exe: error: ld returned 1 exit status

Build finished with error(s).

  • The terminal process failed to launch (exit code: -1).
  • Terminal will be reused by tasks, press any key to close it.

I want to compile the test.c file without error. I also want to understand whether I need to create a ".vscode" folder for each project and how i can do this.

MatDef
  • 1
  • 1
  • 2
    VSCode is not a beginner-friendly product. Try working with another IDE, or no IDE. – n. m. could be an AI Aug 30 '23 at 12:34
  • 1
    Please copy-paste the *full* and *complete* build log into your question. As text. Also copy-paste the code itself. – Some programmer dude Aug 30 '23 at 12:36
  • You seem to be using the VSCode code-runner plugin, which ***only*** builds the current open tab in the editor. I recommend you read [this VSCode with MinGW in Windows documentation](https://code.visualstudio.com/docs/cpp/config-mingw) to learn how to create projects that can use multiple files. – Some programmer dude Aug 30 '23 at 14:55
  • @Someprogrammerdude not exactly: "_Executing task: C/C++: gcc.exe build active file_" But the effect of what you said is right. That's a builtin task from the C++ extension that builds the active file (only). – starball Aug 30 '23 at 18:56
  • Does this answer your question? [VS Code will not build c++ programs with multiple .ccp source files](https://stackoverflow.com/questions/47665886/vs-code-will-not-build-c-programs-with-multiple-ccp-source-files) – starball Aug 30 '23 at 19:02

0 Answers0