The short anwser is "Yes, you can." But, what do you want to do when you click on the icon? How are you planning on providing input? Where is the output going? You could write a command-line tool that can be run from the Terminal, and you can build an macOS application based on the command line tool, but, how to do it is all in the details of what you want to happen.
The following should work.
Compile the project.
Then, in the file list on the left of XCode, you will get a Products folder, with your app inside.
Option drag this file to the desktop
You'll get a copy there that you can double click or copy to another Mac.