-1

I compile my C++ code with cl. Then when I try to run it, it hangs for ~10 seconds, then runs. But this only happens on the first run after the compilation process. The subsequent calls run without any problems. But if I compile the code again, then the first run still hangs for a bit.

I have VS 2017 installed and call "VC\Auxiliary\Build\vcvarsall.bat" to use cl. I'm using command line to compile and run my code. And this is where all the problems occur. If I code and compile in Visual Studio, there's no stalling problem. It only happens when I use command line and I don't know why.

#include <stdio.h>

int main()
{
    printf("Testing\n");
    return 0;
}

Compilation code

cl main.cpp
  • Please show how you run your code. –  Jun 27 '19 at 20:29
  • Do you have any Antivirus software that could be verifying that the file is safe to run? – user4581301 Jun 27 '19 at 20:31
  • I just call `main.exe` to run the program. I have Avira as antivirus software. But I'm not sure if it's the source of the problem. Because I use it for years and this problem has been around for a few months. – Yalcin Ozveren Jun 27 '19 at 20:37
  • A tip for communicating with people on Stack Overflow: You need to "ping" individuals in order to answer them in comments. Otherwise they won't get a notification. You do it like this - @YalcinOzveren - by using the @ character with the screen name. To add missing information to the original question use the [edit] link - comments tend to get removed... – Cindy Meister Jun 27 '19 at 20:42
  • Since the lag is noticeable, fire up a monitor like [Process Explorer](https://learn.microsoft.com/en-us/sysinternals/downloads/process-explorer) then rebuild and run the program to see if the monitor can help spot the baddie. – user4581301 Jun 27 '19 at 21:19
  • Disconnect your computer from the Internet, disable the virus scanner, and see if the problem continues. Heuristic scanners are known to flag unknown programs. –  Jun 28 '19 at 00:56

1 Answers1

0

It seems that the issue is related to antivirus software. I uninstalled Avira and the problem is gone. Now I'm using Avast. It hangs the program, too but only for about 1 second. So it's not a big deal.

  • If you do all, or most, of your development in a "Work" directory, you can likely set that directory to be ignored by the AV scanner. Don't do this with a common directory, like your account's Documents folder in Windows, or if you are worried about targeted attacks. – user4581301 Jun 28 '19 at 17:46
  • @user4581301 That's what I did. I excluded the folder which contains all the code from AV scanner and everything's fine. – Yalcin Ozveren Jun 28 '19 at 18:22