I'm using this code

g++ $(FILE_NAME) -o $(FILE_NAME).exe

to run a cpp from notepad. What I had expected to run was g++ FILE_NAME.cpp -o FILE_NAME.exe But g++ FILE_NAME.cpp -o FILE_NAME.cpp.exe is what I got.

So how do I include only the file name (without the extension) so that this code works? Is there some code to access the file name (without the extension)?

1 Answer 1


The environment variable $(NAME_PART) should just return the filename without file extension.

So your code would look like this;

g++ $(NAME_PART) -o $(NAME_PART).exe

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .