1

First execution of a freshly compiled program is very slow, next executions are fast enough, I suspect it is related to the mac trying to verify the binary, but I'd rather avoid this process as I compile files very frequently and I know (at least from files compiled by myself) that they are not harmful.

The most common scenario for me is as follow:

  • Write small program in c++ (let's say simple hello world a.cpp)
  • Compile (g++ -std=c++11 a.cpp -o sol)
  • Execute it for first time ./sol (takes in the order of 5 seconds)
  • Execute it again ./sol (gives output instantly as expected)

I already saw few related questions, however I was unable to solve the problem:

  • You imply that MacOS extended attribute com.apple.quarantine is set on your executable ./sol, well is it? Post us the result of ls -l@ ./sol. If it's 100% your own code or you trust it 100%, you can manually remove the extattr with xattr -d com.apple.quarantine ./sol. Then recheck with ls -l@ that it's gone. Does that solve it? Perhaps your compile directory or parent diectory has com.apple.quarantine extattr set, if so you need to remove it there, it's sticky and will keep reattaching itself to your executable. – smci Jan 02 '23 at 00:12
  • Also in general for troubleshooting MacOS and g++ behavior, it's useful to tell us what exact versions both of MacOS and g++ you have. Also tell us if you overlaid an install of say MacOS version Y over MacOS X. – smci Jan 02 '23 at 00:12

0 Answers0