(Windows) ncurses linking issues - c++

I'm really getting an headache here.
I'm trying to get ncurses running on my system, but the compiler returns this fatal error: "ncurses.h: no such file or directory".
Can anybody make some clarity inside of my head?
I swear I've been looking for an answer in the whole web for the last 2 hours, thank yall in advance <3
Here's what I did:
Installed following packages via MinGW Installation Manager (even though I didn't get the differences between these):
mingw32-ncurses (bin);
mingw32-libncurses (dev);
mingw32-libncurses (dll);
Made sure "C:\MinGW\bin" was included to my PATH environment variables (but I was already sure of that since I'm compiling with g++)
Included the path to "ncurses.h" file in my includepath in VSCode; I included "C:\MinGW\include\ncurses" for this specific case since that's there I found "ncurses.h" is EVEN IF there's also a "ncursesw" folder with the exact same headers (I don't know the difference)
I made sure to include -lncurses in my terminal when compiling (again, inside of /lib/ there are a couple files regarding ncurses (libncurses.a, libncurses.dll.a, libncurses.la and three copies named "libncursesw"), so once again I'm not sure what needs to be linked.
Just for clarity, here's my code:
#include <ncurses.h>
int main(){
initscr();
printw("Hello");
refresh();
getch();
endwin();
return 0;
}
and here's my compiling command:
g++ ncurses.cpp -lncurses -o test

Related

How can I get VSCode to find gmp.h after it has been successfully installed on Windows 10?

After installing and following the instructions for GMP (using mingw64 since I am on windows) and verifying the installation was correct using make check I tried running the following code in VSCode using the command g++ -g \path\file.cpp -lgmpxx -lgmp -o \path\file.exe:
#include <gmp.h>
#include <iostream>
using namespace std;
int main()
{
mpz_class a,b,c;
cout << "Hello World\n";
a = 1234;
b = "5678";
c = a+b;
return 0;
}
But get the error error: 'mpz_class' was not declared in this scope. So the include path in VSCode is incorrectly set up or the installation was messed up. I am wondering how to fix this: is this VSCode's includePath (compilerPath is not set up), an installation issue (I could not determine the default install location for windows systems since everything I found was for Linux), or is there something else I missed? I saw a flag for ./configure that was --enable-cxx but I wanted to ask before running make clean and retrying with that flag turned on since it takes forever.
I feel like this is something dead simple since I cannot find any help from googling.
Thank you for any help!
EDIT: I have tried running the code not in VSCode and it still has the same issue so I am not so sure it's VSCode.
I don't know anything about GMP, but you seem to include the wrong header.
#include <gmpxx.h> worked for me.

Xcode 11.1: iostream' file not found

I just updated my MacBook Pro to macOS Catalina 10.15, and tried to compile and run a C++ command line program, but I had a problem which didn’t exist on previous versions;
This is simply the code:
#include <iostream>
using namespace std;
int main()
{
cout << "Hello, World!\n";
return 0;
}
The code compiles and outputs the expected, but still the Xcode says:
fatal error: 'iostream' file not found
I tried changing the Build Settings/C++ Standard Library to libstdc++, but a warning says:
warning: include path for stdlibc++ headers not found; pass '-stdlib=libc++' on the command line to use the libc++ standard library instead
And the same iostream error still exists.
I'm compiling from the command line, and none of the answers listed here (or elsewhere) worked for me.
What does seem to work (so far) is to add the following to .profile or whatever script your terminal uses to start up: (zsh, csh, bash, etc.)
export C_INCLUDE_PATH=/Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.15.sdk/usr/include
export CPLUS_INCLUDE_PATH=/Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.15.sdk/usr/include
You will probably have to change MacOSX10.15.sdk whenever you upgrade your operating system.
C_INCLUDE_PATH and CPLUS_INCLUDE_PATH are options for the clang toolchain rather than MacOS environment, so hopefully this solution will work long-term, unlike xcode-select --install (which won't fix the include directories on an upgrade) or ln -s ... /usr/include (which is now forbidden by System Integrity Protection).
I had the same problem and used the following youtube video to fix it.
https://www.youtube.com/watch?v=hrPm7tWC-BI&feature=youtu.be
or you can follow this path. Make sure to include the quotation marks
Project - Build Settings - Search Paths - Headers Search Paths, and add the following path:
"/Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/include/c++/v1/"
So, I restarted my laptop and everything seems to be fine right now, thanks for those who tried to help.
libstdc++ is not OK for Xcode Build & Compile time,
libstdc++ is OK for iPhone Run Time
From answer recommended by #Alan Birtles
libstdc++ Support was removed from the iOS 12.0 Simulator runtime, but
it remains in the iOS 12.0 (device) runtime for binary compatibility
with shipping apps.
I encountered this when declaration in .hpp file.
#include <iostream>
#include <string>
OK with
#ifdef __cplusplus
#include <iostream>
#include <string>
// usage code
#endif
I tried a fresh Catalina install with Xcode. I copied and pasted your code into "test.cpp" and then ran:
clang++ test.cpp
in the same directory as the "test.cpp" file from Terminal. The result was an "a.out" file which when run:
./a.out
output the required "Hello, World!" result. Hopefully that is of some use (as a point of reference).

Compiling SDL2 Error in Terminal (Confused about how to include SDL2 library)

I'm learning SDL2 right now and I'm working in XCode for the most part as I code. However, I want to run my program in terminal to use valgrind, but whenever I try, I get this error:
fatal error: 'SDL2/SDL.h' file not found
I'm compiling in a really simple way as follows:
g++ Camera.cpp LTexture.cpp LTimer.cpp LWindow.cpp Player.cpp Tile.cpp TileMap.cpp main.cpp -o main
I know that I'm supposed to be including the SDL2 library somehow, but I'm unsure of how to do that. Right now, the framework is sitting in the folder /Library/Frameworks/SDL2.framework
Any help on this would be greatly appreciated. Thanks in advance.
Add
-I/Library/Frameworks/SDL2.frameworks/Headers
to your g++ command and change
'SDL2/SDL.h'
include to just
'SDL.h'
in your header/(s) since /Library/Frameworks/SDL2.frameworks/Headers doesn't contain an SDL2 folder (usually)
Now that you changed the #include "SDL2/SDL.h" to #include "SDL.h" you want to go open your Xcode project, select your target, go to build settings and add /Library/Frameworks/SDL2.frameworks/Headers to Header Search Paths in order to fix Xcode's 'Couldn't find 'SDL.h'' error message.
Update:
Another way would be linking (using ln) /Library/Frameworks/SDL2.frameworks/Headers to /usr/local/include/SDL2, add -I/usr/local/include/SDL2 to your g++ command
and leave the #include as is ('SDL2/SDL.h')

Why does "cout" keep giving me error C1083?

I was using Visual C++ 6.0 just now, and I keep getting this error:
fatal error C1083: Cannot open include file: 'streambuf': No such file or directory
My code is just a simple hello world program.
#include "stdafx.h"
#include <iostream>
using namespace std;
int main(int argc, char* argv[])
{
cout<<"Hello World.";
return 1;
}
Then I went and checked my INCLUDE folder and found a file called STREAMBF, but the compiler was looking for STREAMBUF. Notice that the file that is present is missing the U, between the B and the F. This was from a good copy of VC++6.0, directly from the actual CD, not a pirated copy. So there should be all the files needed. But it appears that a file is missing! Is this MS being stupid again, and yet making another big mistake, and forgetting to include an important file on their CDs? I'd hate to think that every single CD for VC++6.0 that was pressed that came out of MS factories had this problem. And I know that it is a missing file, not just a misnamed file, as renaming STREAMBF to STREAMBUF just led to more errors.
Anybody know where I can find a copy of the file STREAMBUF? Or am I just overlooking something here? Is this exact error a known problem with running old copies of VC++ on modern OS's like Windows 7? Is it possible that the only reason that it's looking for STREAMBUF is that this is a newer file associated with Win7, and that if it was running in a different environment (an older OS), it would actually be looking for the correct file, STREAMBF? Can somebody help me here?
Your installation is either broken, deprecated or interpretes your code in wrong way.
You should only use older compiles if you are trying to build project developed entirely for this version.
Try to compile same code with new compiler, if you want to use VS then you should look for Visual Studio Express 2013.
Your code does not have any errors.
Modify your program to, you should be able to see it okay.
#include <iostream.h>
using namespace std;
int main()
{
cout<<"Hello World.";
return 1;
}
However,
your compiler is pretty old. You need to an upgrade.
There are C++ compilers for Windows from Microsoft Express Visual Studios Link and Info VS2013 to
some other non-Microsoft like GCC for Windows.
If you don't have installation access there are some portable c++ compilers.
Finally there are some online compilers for simple test. web based online compilers.
For my win 10 installation of VC 6.0, I had the same problem ... fatal error C1083: Cannot open include file: 'streambuf': No such file or directory
Replacing with <iostream.h> does not solve the problem.
I have checked the header file installation folder (Program files\VS98\VC98\INCLUDE). For some (unknown) reason, some file names have been changed during installation. Restoring the original name has solved the problem, in my case, in example:
Turn STREAMBF into STREAMBUF, STDXCEPT into STDEXCEPT, XCEPTION into EXCEPTION, FCTIONAL into FUNCTIONAL.
Notice: other header file names might be wrong. I have listed above the file names wrong in my installation.
I hope this may help.

Need help in C++ with allegro library....?

I installed CodeBlocks 10.5 with minGW compiler. After setting environment variables for minGW I cheked gcc -v on cmd and it is working fine.
The problem is that, I have made a small program in CodeBlocks project the code is below
#include <iostream>
#include <allegro5/allegro.h>
using namespace std;
int main()
{
cout << "Hello world!" << endl;
return 0;
}
There is an error, the build log is:
Compiling: main.cpp
C:\Program Files\CodeBlocks\MinGW\bin\allegro_pract… error: allegro5/allegro.h: No such file or directory
Process terminated with status 1 (0 minutes, 0 seconds)
1 errors, 0 warnings
Directory structure for codeblocks is:
C:\Program Files\CodeBlocks
and for minGW:
C:\Program Files\CodeBlocks\mingw
and my project is:
C:\Program Files\CodeBlocks\bin\
i am confused about allegro library where to place it.. as I have not used any external library..
the library is placed now at:
C:\Program Files\CodeBlocks\mingw\allegro\
I am "Googling" for a long time but no tutorial seems to be working..
please give a valid solution.. and where to place allegro library..??
Do not try to "place" libraries in the "right place". Instead, tell the IDE where you put them explicitly. This is called setting the include path.
Code::Blocks should have some setting for include directories. You should point it to the place where Allegro lives.
Set up your IDE to look for Allegro:
(source: allegro.cc)
The complete tutorial is here:
http://wiki.allegro.cc/index.php?title=Windows,_Code::Blocks_10.05_and_Allegro_5
http://www.mingw.org/wiki/IncludePathHOWTO:
The actual search path, for any specific installation of MinGW may be determined, by running the compiler itself, with the "-v" option; typically, for a GCC-3.4.5 installation in c:/mingw:--
defaults appear to be:
c:/mingw/include/c++/3.4.5
c:/mingw/include/c++/3.4.5/mingw32
c:/mingw/include/c++/3.4.5/backward
c:/mingw/include
c:/mingw/lib/gcc/mingw32/3.4.5/include
I don't use mingw, so, read the link.