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:
com.apple.quarantineis set on your executable./sol, well is it? Post us the result ofls -l@ ./sol. If it's 100% your own code or you trust it 100%, you can manually remove the extattr withxattr -d com.apple.quarantine ./sol. Then recheck withls -l@that it's gone. Does that solve it? Perhaps your compile directory or parent diectory hascom.apple.quarantineextattr 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