Code::Blocks, and C++ Compiler problem. cant compile a header - c++

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?

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.

Related

Digital Mars Compiler (Code::Blocks) unable to open file 'iostream'

I'm starting to code in Code::Blocks and I need a compiler, I installed Digital Mars at C:/dm and selected it in Code:Blocks. The sc.ini of C:/dm/bin looks like this:
[Version]
version=7.51 Build 020
[Environment]
PATH=%PATH%;"%#P%\..\bin"
BIN="%#P%\..\bin"
INCLUDE="%#P%\..\stlport\stlport";"%#P%\..\include";"%#P%\..\mfc\include"
;%INCLUDE%
;INCLUDE="%#P%\..\include";"%#P%\..\mfc\include";%INCLUDE%
LIB="%#P%\..\lib";"%#P%\..\mfc\lib";%LIB%
HELP="%#P%\..\help"
but when compiling I always get this error:
||=== Build: Debug in Serevr (compiler: Digital Mars Compiler) ===|
||unable to open input file 'iostream'|
||=== Build failed: 1 error(s), 0 warning(s) (0 minute(s), 0 second(s)) ===|
I looked at other posts but none helped! does anyone know how to fix this?
I suppose the file has been edited by you. BIN and INCLUDE will most likely not work if on the same line - insert a newline before INCLUDE:
BIN="%#P%\..\bin"
INCLUDE="%#P%\..\stlport\stlport";"%#P%\..\include";"%#P%\..\mfc\include";%INCLUDE%
;INCLUDE="%#P%\..\include";"%#P%\..\mfc\include";%INCLUDE%`
and try again.
Also, did you download and install the STLport? As the iostream header comes from there for DM. Check also the stlport include, the "%#P%\..\stlport\stlport" entry seems somewhat dubious - depending where you installed it, it could be only "%#P%\..\stlport" (i.e. check if the iostream header is really in the C:\DM\stlport\stlport or just in C:\DM\stlport or maybe even in C:\DM\stlport\include or somewhere alike).
Besides, the Digital Mars compiler could be somewhat tricky in my experience (e.g. not supported by CMake AFAIK), you might want to try the MinGW (GCC) compiler, which is more up to date and likely better supported by various tools.
(or the MS Visual Studio Express, which is native on Windows and comes with the IDE)

Problems installing/understanding c++ libraries( novice programmer)

I have just started learning programming, and I am facing troubles adding libraries ( Other than STD libraries) in my programs.
I use codeblocks IDE and I wanted to add a library CImg from the internet.
After reading many threads I have done the following steps however I still get an error loading one of the examples provided CImg people
Downloaded Cimg folder which has a Cimg.h file along with other example files.
Unzip the folder to E drive.
open code blocks>compiler settings(gnu gcc compiler)>search libraries
under search libraries I have compiler tab and linker tab where I have added the path of the downloaded folder.
next when I open an example provided by the developer, build and run it.
The cimg.h file open up and I get the following error:
||=== Build file: "no target" in "no project" (compiler: unknown) ===|
E:\programming\cpp programming\CImg-2.0.0_pre012317\CImg.h||In function 'int cimg_library::cimg::fseek(FILE*, INT_PTR, int)':|
E:\programming\cpp programming\CImg-2.0.0_pre012317\CImg.h|5617|error: '_fseeki64' was not declared in this scope|
E:\programming\cpp programming\CImg-2.0.0_pre012317\CImg.h||In function 'INT_PTR cimg_library::cimg::ftell(FILE*)':|
E:\programming\cpp programming\CImg-2.0.0_pre012317\CImg.h|5626|error: '_ftelli64' was not declared in this scope|
||=== Build failed: 2 error(s), 0 warning(s) (0 minute(s), 10 second(s)) ===|
Please help me out, Also kindly explain to me what I am doing as I have no idea.
EDIT: As pointed out to me in the comments I have changed my compiler to TDM-GCC MinGW 64 bit compiler.
But now I get a different type of error, is it because I havent installed the compiler properly because I can run hello world using this compiler.
the error that i get is :
||=== Build: Debug in hello (compiler: GNU GCC Compiler) ===|
obj\Debug\main.o||In function cimg_library::CImgDisplay::paint()':|
E:\programming\cpp programming\hello\..\CImg-2.0.0_pre012317\CImg.h|9696|undefined reference to__imp_SetDIBitsToDevice'|
||error: ld returned 1 exit status|
||=== Build failed: 2 error(s), 0 warning(s) (0 minute(s), 0 second(s)) ===|
Finally I have found out what were my mistakes and how to correct them.
I was using a 32 bit compiler, So I switched to one for 64 bits.
After that I had not linked gdi32 library. So when I went to linker settings and added gdi32 to linked libraries evrything started to work.
Thank you for helping me out.

While Compiling "strlcpy.h" is not found

I'm trying to compile C++ Code using g++ and using the CERN ROOT Framework. I've got the folowing error message, while compiling.
In file included from /usr/include/root/TObject.h:31:0,
from /usr/include/root/TNamed.h:26,
from /usr/include/root/TDirectory.h:25,
from /usr/include/root/TDirectoryFile.h:25,
from /usr/include/root/TFile.h:25,
from neutralino_root.cpp:13:
/usr/include/root/Rtypes.h:36:68: fatal error: strlcpy.h: No such file or directory
#include <strlcpy.h> // part of string.h on systems that have it
^
compilation terminated.
Has anyone an idea, why "strlcpy.h" is not found?
Thanks for help,
Simon

'class std::map<std::basic_string<char>, Gui>' has no member named 'emplace'

Hi Guy's looking for some help and can't understand the problem. I'm following this tutorial https://www.binpress.com/tutorial/creating-a-city-building-game-with-sfml-part-8-gui-system/130, I'm using CodeBlocks 13.12 and SFML 2.1 but when I try to compile the code I get this
||=== Build: Debug in Test (compiler: GNU GCC Compiler) ===|
C:\Users\James\Desktop\Summer Repeats 2015\Games Dev 2\Test\src\Game_State_Start.cpp||In constructor 'GameStateStart::GameStateStart(Game*)':|
C:\Users\James\Desktop\Summer Repeats 2015\Games Dev 2\Test\src\Game_State_Start.cpp|100|error: 'class std::map<std::basic_string<char>, Gui>' has no member named 'emplace'|
||=== Build failed: 1 error(s), 0 warning(s) (0 minute(s), 1 second(s)) ===|
This is the line of code giving me this error.
this->guiSystem.emplace("menu", Gui(sf::Vector2f(192, 32), 4, false, game->stylesheets.at("button"),
{ std::make_pair("Load Game", "load_game") }));
I have CodeBlocks set for C++11 and change SFML to SFML-2.3.1-windows-gcc-4.9.2-mingw-32-bit because I found here saying I have to use g++ 4.8.0 or higher on this page std::map emplace gcc 4.8.2, but still getting the same error, also the website give's me the code to download even though I'm trying to follow it myself , I checked the code, importing into a new project and that didn't work either, So no idea whats wrong. Any help or a point in the right direction would be most appreciated.
Normally I would post this in a comment but I don't have enough rep.
Start a new project and compile and run this code:
#include <iostream>
#include <ostream>
int main()
{
std::cout << __cplusplus << std::endl;
}
If the result printed out is 199711, then it means you're not compiling using the -std=c++11 option. If the result printed out is 201101 then it means you're using an outdated version of the standard library.
Found the solution. I had originally installed codeblocks-13.12mingw-setup, I uninstalled this and installed codeblocks-13.12mingw-setup-TDM-GCC-481. It works now. Thanks for everybody's help.

Building GLEW with MSYS: X11 not found

When trying to make GLEW with MSYS, I'm getting the following error:
In file included from src/glew.c:37:0:
include/GL/glxew.h:97:22: fatal error: X11/Xlib.h: No such file or directory
#include <X11/Xlib.h>
compilation terminated.
make: *** [tmp/mingw/default/shared/glew.o] Error 1
Why?
MSYS does not have X11. It's *M*inimal SYStem for a reason. You want Cygwin.
Or if you want to keep things Win32 native without Cygwin, take a look at Xming.