Why is the main() function of my program named "test" not getting called?

Viewed 69

I'm running C++ on Ubuntu 20.04/g++ 11.1.0 and it seems the program simply isn't being run when I call on the executable. Here is what I am doing:

Code:

/* newtest.cpp */
#include <iostream>

int main() {
   std::cout<< "this works" << std::endl;
   return 0;
}

Compilation:

$ g++ -o test newtest.cpp

Execution:

$ test

And nothing is printed; the program compiles and runs without errors. When I compile it with the -g flag and run it using the GDB debugger it works, but not under normal execution. Older programs on my machine are able to print to the console fine. Any thoughts on why this is happening?

0 Answers
Related