Unresolved <iostream> in Eclipse, Ubuntu - c++

Yes, it's this question again...
Somehow, I cannot get this issue resolved. Believe it or not, I have experience with Eclipse but only for Java development. I have programmed in C++ using vi but not with Eclipse.
I have installed:
Ubuntu 12.04
Eclipse 3.7.2
GCC 4.6.3
Eclipse CDT 8.0.2
I created an empty Makefile project and selected the Linux GNU Toolchain:
I get the standard Unresolved inclusion <iostream> error, and I have some references to various "include" directories in the project:
I did notice that, while my "Paths and Symbols" setting for GNU C contains various paths, the same setting for GNU C++ is empty:
Also, I have the "GNU Elf Parser" under my C/C++ build settings:
What am I doing wrong here?
Cheers
Edit:
Here's an updated photo of my a project's build path that is working correctly:

The reason is that Eclipse simply cannot import a proper header. C++ iostream header in Ubuntu can be found:
$: sudo find / -name iostream
/home/beniamin/QtSDK/Madde/toolchains/arm-2009q3-67-arm-none-linux-gnueabi-x86_64-unknown-linux-gnu/arm-2009q3-67/arm-none-linux-gnueabi/include/c++/4.4.1/iostream
/home/beniamin/QtSDK/Madde/sysroots/harmattan_sysroot_10.2011.34-1_slim/usr/include/c++/4.4/iostream
/usr/share/gccxml-0.9/GCC/2.95/iostream
/usr/include/c++/4.6/iostream
/usr/include/boost/tr1/tr1/iostream
So basically, I suppose the one you are looking for is /usr/include/c++/4.6/iostream, so you should in some place include this directory.
Edit: You should also have installed g++, or simply install build-essential package, which is obligatory for building debian packages. Nevertheless, g++ should have been included in your Ubuntu installation anyway.

Yes, I have found that using
$: sudo find / -name iostream
and adding the includes file in the includes path and then it success.

Related

configure MinGW with Eclipse CDT

I have searched a lot about this and read most of the available answers for similar problem but I still couldn't solve it. Therefore, any help will be helpful.
I am using Eclipse Mars(Latest version after Luna) on Windows 7
MinGW is installed in "C:\Program Files (x86)\CodeBlocks\MinGW\bin".
Environment variable "Path" contains "C:\Program Files (x86)\CodeBlocks\MinGW\bin;..."
Preferences -> C/C++ -> Build -> Settings -> Discovery->CDT GCC Built-in Compiler Settings : command to get compiler specs
${COMMAND} ${FLAGS} -E -P -v -dD "${INPUTS}"
manually doing gcc -E -P -v -dD in cmd from any directory gives
.
.
Target: mingw32
.
.
Errors:
Program g++/gcc not found in PATH
I make a C++ project, add a file with hello world program in it.
I get errors "unresolved inclusion " and 'printf' could not be resolved.
comment if any other details required
It sounds like you're doing everything correctly.
TWO SUGGESTIONS:
Take a look at this link, and see if you missed anything regarding the MinGW/GCC install:
https://www3.ntu.edu.sg/home/ehchua/programming/howto/EclipseCpp_HowTo.html
Otherwise, consider deleting (or simply renaming) your current Eclipse and installing the CDT (Eclipse for C/C++ Developers) version instead:
http://www.eclipse.org/downloads/
For whatever it's worth, here are a couple of screenshots from my property settings (I'm able to create and successfully build a new C project):
I think your problem is simply because of MinGW path include white spaces in it. just reinstalling MinGW on Root directory "c:\MinGW"will solve your problem.
install MinGW with basic setup packages select "mingw-developer-toolkit, mingw32-base, mingw32-gcc-g++, msys-base". complete installation.
restart your pc. then check your eclipse settings.
I hope your problem is already solved.
I also faced such problems,you need to set environment variable, In path add your MinGW location, if you haven't downloaded MinGW go here for downloading MinGW:
http://sourceforge.net/projects/mingw/files/latest/download?source=files
Simple solution is:
For more and detailed information to fix your problem, it worked for me!
Visit here:
http://www.multigesture.net/articles/how-to-install-mingw-msys-and-eclipse-on-windows/

"g++" not found in PATH [mac/Eclipse/XCODE installed/CDT downloaded]

I get this error when I try to build a c++ project, however I can run cpp apps in Xcode, I've downloaded CDT for Eclipse, so the compiler must be installed.
echo $PATH:
/opt/local/bin:/opt/local/sbin:/usr/bin:/bin:/usr/sbin:/sbin:/usr/local/bin
I'm using Mac, I've found posts saying download gcc or Xcode, or solutions for Windows, it's very frustrating that I can't find the answer for such an easy problem, so please… How can I set the PATH variable for my cpp projects in Eclipse?
This question should help. It looks like you need to install XCode command line tools separately to use compilers and build systems outside of XCode (e.g. on the command line or in Eclipse).

Building C++ not working in OSX 10.9

Update:
I solved the problem in the end by reinstalling command line tools, as shown in this link.
Sorry for the trouble!
Initial question
I have just upgraded to OSX Mavericks and I cannot make the compiler work anymore.
I've been using gcc48 from macports with vim/sb2 and everything was working just fine. Now any library that I include gives tons of errors. I am not very experienced and I do not know what to do, or what to search for. I just want it to work like before. Here is what is says when compiling a basic "hello world" program:
In file included from /opt/local/include/gcc48/c++/bits/postypes.h:40:0,
from /opt/local/include/gcc48/c++/iosfwd:40,
from /opt/local/include/gcc48/c++/ios:38,
from /opt/local/include/gcc48/c++/ostream:38,
from /opt/local/include/gcc48/c++/iostream:39,
from ceva.cpp:1:
/opt/local/include/gcc48/c++/cwchar:44:19: fatal error: wchar.h: No such file or directory
#include <wchar.h>
If you need any information, tell me and I will provide it to you. Thank you for your patience!
[Added 2019 - Mojave/Catalina] XCode 10 has removed the placement of headers in /usr/include, even with the command line tools. If you want headers, and you're on you should be able to install a transitional package, which is available on Mojave. This package is not present on the Catalina. The headers are within the SDK for the appropriate release.
XCode 5/Mavericks have changed the defaults for where headers are located.
On prior versions of Mac OS X / XCode you would have found headers in /usr/include.
When you built gcc on the older release it picked up the headers from that location, and looks for them there now when you try to build code.
The problem is that the files are not there; they're somewhere under /Applications/Xcode.app/Contents/Developer.
You could futz about with a spec file to get it working consistently again, but the sanest thing to do is rebuild gcc.
As has been mentioned as well, you can install the command line tools using xcode-select --install, which will reinstall the developer tools, including the headers in /usr/include.
I tend to reinstall things like gcc when I upgrade my operating system as I encounter other errors due to changes in the environment. This is just a habit I've formed. It may not be the best habit, but it's saved me pain on numerous occasions.
[added 2017] As an addendum, if you install the command line tools, then the headers will be placed in /usr/include as well. The command to install the command line tools is xcode-select --install - this will allow you to use most compilers without having to specify the location of the headers manually.
This is how I got it working on Mac osx Mavericks:
Open terminal
type --> xcode-select --install
A pop-up windows will apear asking you about install tools
choose install tools
wait install to finish
Here is a manual method for updating XCode on OS X Mavericks:
Go into the developers site http://developer.apple.com
Then go to Downloads for Apple developers and there is a command line tools installer for Mavericks — here's the link (but you'll need a developers account for the link to work) http://developer.apple.com/downloads/index.action?q=xcode
I'm using MacOs Sierra 10.12.4, got the same problem.
I solved it by using:
/usr/bin/gcc
For me the fix was to uninstall old broken gcc:
brew uninstall gcc#5
I noticed paths like /usr/local/Cellar/gcc#5 in build output, while gcc#8 was also installed and is the one that was supposed to be used.

Qt 5.1.1 compiler setup on Ubuntu

First of all, I should point out that I've never used linux before.
I have a clean install of 64bit ubuntu, I downloaded Qt 5.1.1 for linux 64 bit from http://qt-project.org/downloads, ran the .run file, installed it and gcc which is included in that download, opened Qt Creator, made a new project and tried to compile it. It wont compile and I keep getting this error message
:-1: error: Qt Creator needs a compiler set up to build. Configure a compiler in the kit options.
I added a gcc compiler, but what do I need to put for the compiler path, platform codegen flags, platform linker flags and ABI?
You don't have to input the path of your compiler because gcc and g++ paths are available in the $PATH enovironment variable. So just use "gcc" and "g++" and that should work. Just make sure you restart Qt Creator after the installation of g++.
One more thing. You need a compiled version of Qt installed on your computer. So also install Qt libraries with
sudo apt-get install qt4-dev-tools
If you want to use the new version of the library you have to add it to $PATH. You can do this in the terminal with
export PATH=/path/to/Qt/qtbase:$PATH
And then run Qt Creator from the same terminal, in which you did the last command.
Good luck!
You will have to install the dependencies as well. I got it working when I followed the steps in the following link.
Try this:
http://wiki.qt.io/Building_Qt_5_from_Git

Boost "no such file or directory"

I'm trying to set up my Code::Blocks work environment on a new computer and I'm having some problems. It's been a long time since I first did this, and now when I open my major project Boost is causing me problems.
I'm fairly new to C++ still and fixing this type of problem is something I have limited experience with.
When I open my project and try to compile it, I get this error:
fatal error: boost/algorithm/string.hpp: No such file or directory|
At this part of one of my header files:
#include <boost/algorithm/string.hpp>
I placed the Boost v1.51.0 library at C:\boost since that is where I'd had it on my other computer. My project is set to search that directory for additional includes but it doesn't seem to be finding the files?
My project used an older version of Boost previously but I doubt that's an issue.
I'm not sure how difficult it is to debug this problem with this limited information so if there's anything else I can provide please let me know.
I'm using Code::Blocks, and have just set up minGW and Visual C++ 2010.
In Ubuntu use
sudo apt-get install libboost-dev
Ensure that you have installed boost-devel package
In Centos execute as root:
yum install boost-devel
then
root#centos6 /]# find / -name boost
/usr/include/boost
/usr/lib64/boost
[root#centos6 /]#