title: How to use <windows.h> on Ubuntu
body: <p>I have a C++ project that uses <code>&lt;windows.h&gt;</code> on windows. Now I need to run the program on Ubuntu. But I don't know how to make changes to the following codes that are related to the <code>&lt;windows.h&gt;</code>. For example, what are the equivalent of these functions on Ubuntu:</p>
  <ol>
  <li>GetStdHandle</li>
  <li>STD_OUTPUT_HANDLE</li>
  <li>INVALID_HANDLE_VALUE</li>
  <li>CONSOLE_CURSOR_INFO</li>
  <li>SetConsoleCursorInfo</li>
  <li>GetConsoleCursorInfo</li>
  <li>SetConsoleMode</li>
  <li>GetConsoleMode</li>
  <li>ENABLE_VIRTUAL_TERMINAL_PROCESSING</li>
  </ol>
  <p>Here is my <code>.h</code> file:</p>
  <pre><code>#ifndef CONSOLE_OUTPUT_COMMON_H
  #define CONSOLE_OUTPUT_COMMON_H
  
  
  #include &lt;string&gt;
  //#include &lt;stdio.h&gt;
  #include &lt;iostream&gt;
  #define _WINSOCKAPI_
  #include &lt;windows.h&gt;
  
  namespace ConsoleOutputCommon {
      void clrLine();
      void moveCursorTopLeft();
      void replaceLine(std::string s);
      void clrScreen();
      void prepareWindowsConsole();
      void clrRemainingScreen();
  }
  
  #endif // !CONSOLE_OUTPUT_COMMON_H
  </code></pre>
  <p>Here is my <code>.cpp</code> file:</p>
  <pre><code>#include &quot;ms_windows_console_output_common_20200819.h&quot;
  
  
  void ConsoleOutputCommon::clrLine() {
      printf(&quot;\x1B[2K&quot;);
  }
  
  void ConsoleOutputCommon::moveCursorTopLeft() {
      printf(&quot;\x1B[1;1H&quot;);
  }
  
  void ConsoleOutputCommon::replaceLine(std::string s) {
      printf(&quot;\x1B[2K&quot;);
      std::cout &lt;&lt; s;
  }
  
  void ConsoleOutputCommon::clrRemainingScreen() {
      printf(&quot;\x1B[J&quot;);
  }
  
  void ConsoleOutputCommon::clrScreen() {
      printf(&quot;\033[2J&quot;);
  }
  
  void ConsoleOutputCommon::prepareWindowsConsole() {
      // Set output mode to handle virtual terminal sequences
      DWORD error;
      HANDLE hOut = GetStdHandle(STD_OUTPUT_HANDLE);
      if (hOut == INVALID_HANDLE_VALUE)
      {
          error = GetLastError();
      }
  
      CONSOLE_CURSOR_INFO     cursorInfo;
      GetConsoleCursorInfo(hOut, &amp;cursorInfo);
      cursorInfo.bVisible = false;                // hide the cursor
      SetConsoleCursorInfo(hOut, &amp;cursorInfo);
  
      DWORD dwMode = 0;
      if (!GetConsoleMode(hOut, &amp;dwMode))
      {
          error = GetLastError();
      }
  
      dwMode |= ENABLE_VIRTUAL_TERMINAL_PROCESSING;
      if (!SetConsoleMode(hOut, dwMode))
      {
          error = GetLastError();
      }
      ConsoleOutputCommon::clrScreen();
  }
  </code></pre>
  <p>Since I am not familiar with ubuntu, I appreciate it if you could guide me on how to fix this. When I run the program I receive the following error:
  <a href="https://i.stack.imgur.com/ZRmRe.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/ZRmRe.png" alt="enter image description here" /></a></p>
  <p>Thank you.</p>