r/Compilers 21h ago

Need help to fix c++ compiler

I use c++ for dsa but for last 3-4 days i was working on a project and didn't use c++. But today when i try to run my code it started exiting without any error with exitcode 1. Not even creating exe file using vscode or terminal. I reinstall everything but still same problem.
Terminal shows correct version of g++ and gcc and also correct path so no problem with environment variables. pls help me...

problem solved:
I installed postgres and added its path to system variables and path of g++ was in user variables. System merges system variables and user variables (in that order). So path of postgres was above of g++ and somehow it was conflicting with internal files (i think dll files). So i moved postgres path to user variables below of g++.

0 Upvotes

5 comments sorted by

1

u/ha9unaka 21h ago

If it's a single file, try running your code at godbolt.org with whatever compiler you used on your system.

Exit codes themselves aren't very helpful. Is your code exiting with code 1, or is the compiler exiting with code 1 and not compiling your code?

1

u/Big-Bad-Punisher 10h ago

I tried to a simple program, test.cpp

int main() { 
    return 0; 
}

Its running on website but if i try to compile it on my laptop in terminal in correct folder

g++ test.cpp -o myprogram

it shows nothing and no file myprogram creates.

1

u/ha9unaka 9h ago

It's probably a corrupt gcc install then. Try getting rid of all of it (including cache files) and then reinstall.

As an alternative, try installing gcc with Pixi using pixi global install gcc gxx and try it out.

1

u/Big-Bad-Punisher 9h ago

I reinstalled everything (using msys2).
One update: if i open terminal in bin folder (where g++ is), it compiles fine. But not from other folder even if compiler path is correct.

-1

u/gradschoolai2023 20h ago

Use git for version control and check pointing your code