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)?


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

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.