Issue
I'm on Windows 10 using MinGW and I have a bit of trouble with the setup. I learned C some years ago and I wanted to check if I remembered how to write some classic data structures, so I opened a project on repl.it and started. Now I moved to VSCode, I installed the C/C++ extension and the Code Runner extension. This last one does not seem to be able to compile multiple files, though.
This is the project structure:
main.c
item.c
item.h
|
BST
----BST.c
BST.h
btnode.c
btnode.h
When I click the "play" button of Code Runner in main.c, it gives "undefined reference" to all the functions coming from other modules (I'm correctly importing them). So I tried to compile it myself with gcc -o main main.c item.c BST/BST.c BST/btnode.c
. This generates main.exe, but when I try open it it does not run, I even tried to run this simple program but the CLI does not appear when I double click:
#include <stdio.h>
#include <stdlib.h>
int main(void) {
printf("Test\n");
return 0;
}
What am I doing wrong? Could you guys explain or point out some tutorials?
Solution
I solved it, the compile was ok, I just needed to add getchar()
at the end in order to keep the console open until the user presses a button.
Answered By - Essay97