0

im having problem when compiling C++ source code. that code is a keylogger. at first, i save with .cpp, and try to compile it from terminal using this command

g++ test.cpp

and then the terminal showed me this messages

test.cpp:1:10: fatal error: conio.h: No such file or directory
#include <conio.h>
         ^~~~~~~~~
compilation terminated.

and this message

test.cpp:2:10: fatal error: windows.h: No such file or directory
#include <windows.h>
         ^~~~~~~~~~~
compilation terminated.

to fix this, i tried to use a C++ IDE, code::blocks. installed from terminal, and the copy that keylogger source code to code:::blocks. but the IDE shows this message

||=== Build file: Debug in Belajar CPP (compiler: GNU GCC Compiler) ===|
/home/lucky/test.cpp|1|fatal error: conio.h: No such file or directory|
||=== Build failed: 1 error(s), 0 warning(s) (0 minute(s), 0 second(s)) ===|

I just don't know how to fix this and how to search the solutions online. because I'm new in using Linux-Mint. Can someone help me to fix this?

JaMiT
  • 14,422
  • 4
  • 15
  • 31
  • `windows.h` You won't have this header on linux. Unless perhaps you are cross compiling with mingw. – drescherjm Feb 01 '20 at 02:43
  • `conio.h` is for DOS. Maybe Turbo c++ – drescherjm Feb 01 '20 at 02:44
  • i dont know what you mean:( – beruntungbesar29 Feb 01 '20 at 02:45
  • 1
    It means you probably can't build what you want. – drescherjm Feb 01 '20 at 02:45
  • so what i have to do – beruntungbesar29 Feb 01 '20 at 02:46
  • 1
    Build it on windows or find a keylogger for whatever platform you're using. That's pretty much it. I'd say port the code, but I'm guessing that's perhaps beyond your current wheelhouse. – WhozCraig Feb 01 '20 at 02:47
  • what is DOS stands for? – beruntungbesar29 Feb 01 '20 at 02:47
  • [https://en.wikipedia.org/wiki/DOS](https://en.wikipedia.org/wiki/DOS) – drescherjm Feb 01 '20 at 02:48
  • Does this answer your question? [g++ conio.h: no such file or directory](https://stackoverflow.com/questions/6565924/g-conio-h-no-such-file-or-directory) – JaMiT Feb 01 '20 at 02:49
  • thanks drescherjm, but it makes me more confused – beruntungbesar29 Feb 01 '20 at 02:50
  • The simplest answer is there is no way that you will get that working on your linux mint computer when in linux. – drescherjm Feb 01 '20 at 02:51
  • 1
    As for *"how to search the solutions online"*, I put "conio.h No such file or directory" in Stack Overflow's search box. – JaMiT Feb 01 '20 at 02:52
  • okay, now im trying to use dev++ on windows to compile and run that code – beruntungbesar29 Feb 01 '20 at 02:54
  • @JaMiT : There is more than one conio.h - the one in the link you included is Borland's. Microsoft compilers also have a conio.h which is much less capable than Borland's but is the one supported by MinGW which I guess is what he is now using after moving to DevC++. https://learn.microsoft.com/en-us/previous-versions/visualstudio/visual-studio-6.0/aa272068%28v%3dvs.60%29 – Clifford Feb 15 '20 at 04:36
  • @beruntungbesar29 : Why would you not use Code::Blocks on Windows too? Ultimately both Code::Blocks and DevC++ use the MinGW toolchain on Windows (by default), but it seems odd that you would not choose the IDE you were already familiar with. Or use Microsoft's free Visual Studio tools (Express or Community editions) for a far more functional IDE and an excellent debugger. – Clifford Feb 15 '20 at 04:40
  • A keylogger is necessarily platform specific, and this code is targeted at Windows (as should be obvious from the windows.h system API header) – Clifford Feb 15 '20 at 04:45
  • Given the likely uses of a keylogger, it is probably best that you remain incompetent in this area. – Clifford Feb 15 '20 at 04:50

1 Answers1

0

First of all, conio.h and windows.h these headers are not supported on linux console.

Alternative is to use NCurses library. It does all the Console realted stuff you could want and is part of the Linux Standard Base ( i.e. available in every distro ).

Include 'ncurses.h' instead.

I hope this will resolve your issue.

Clifford
  • 88,407
  • 13
  • 85
  • 165
Siddhant
  • 626
  • 1
  • 7
  • 20
  • It won't resolve his Windows API dependency though. It appears not to be his own code and being a "keylogger", will be necessarily platform specific. – Clifford Feb 15 '20 at 04:48