View previous topic :: View next topic |
Author |
Message |
Tigid n00b
Joined: 12 Aug 2007 Posts: 19
|
Posted: Thu Sep 13, 2007 3:29 pm Post subject: Gcc problems [SOLVED] |
|
|
I tried to emerge gcc-3 yesterday to compile qemu, but it didn't succeed. I think that's the reason of the problem.
Now, I see there are some things wrong with gcc. When I compile a simple *.cpp, I get lots of errors, because it can't find iostream and other include files.
This is what I get if I try to compile just an usual program:
Code: | ./main.cpp:2:20: iostream: No such file or directory
./main.cpp:5:19: cstring: No such file or directory
/main.cpp: In function `void openFile()':
./main.cpp:34: error: `cout' was not declared in this scope
./main.cpp:34: error: `endl' was not declared in this scope
./main.cpp:40: error: `cerr' was not declared in this scope
./main.cpp: In function `int main(int, char*)':
./main.cpp:55: error: `cerr' was not declared in this scope
./main.cpp:55: error: `endl' was not declared in this scope
./main.cpp:70: error: `cerr' was not declared in this scope
./main.cpp:70: error: `endl' was not declared in this scope
./main.cpp:74: error: `cout' was not declared in this scope
./main.cpp:74: error: `endl' was not declared in this scope
./main.cpp:89: error: `cerr' was not declared in this scope
./main.cpp:89: error: `endl' was not declared in this scope
./main.cpp:93: error: `cout' was not declared in this scope
./main.cpp:93: error: `endl' was not declared in this scope
(And so on...)
|
I've done a slocate iostream, and this is the output:
Code: | /usr/lib64/gcc/x86_64-pc-linux-gnu/4.1.2/include/g++-v4/iostream
/usr/lib64/gcc/x86_64-pc-linux-gnu/4.1.2/include/g++-v4/backward/iostream.h
/usr/lib64/fpc/2.2.0/units/x86_64-linux/fcl-base/iostream.o
/usr/lib64/fpc/2.2.0/units/x86_64-linux/fcl-base/iostream.ppu
/usr/portage/sci-mathematics/geomview/files/geomview-1.8.1-stdiostream.diff
/usr/portage/app-misc/aldo/files/aldo-0.0.11-iostream.diff |
And when I type in this command, I get this output:
Code: | frans@SkyBox ~/projecten/cpp/0004-t2k $ gcc-config -X
/usr/lib/gcc/x86_64-pc-linux-gnu/4.1.2:/usr/lib/gcc/x86_64-pc-linux-gnu/4.1.2/32/include/g++-v4 |
So, I guess the files are on my hard disk. How could I tell gcc where these files are? _________________ "Story in a game is like a story in a porn movie. It's expected to be there, but it's not that important." - John Carmack
Last edited by Tigid on Sun Sep 16, 2007 8:19 pm; edited 2 times in total |
|
Back to top |
|
|
mrybczyn n00b
Joined: 09 Nov 2003 Posts: 26
|
Posted: Thu Sep 13, 2007 3:46 pm Post subject: |
|
|
what does
display?
Make sure its set to 4.1.2, and do a re-boot to be sure all sessions are updated... gcc-config can be a pain sometimes
You could try re-installing gcc from a binary package, or from the stage3 tarball in the worst case, to get a working compiler setup. |
|
Back to top |
|
|
Tigid n00b
Joined: 12 Aug 2007 Posts: 19
|
Posted: Thu Sep 13, 2007 3:55 pm Post subject: |
|
|
Code: | frans@SkyBox ~ $ gcc-config -l
[1] x86_64-pc-linux-gnu-4.1.2 * |
I think this is ok? _________________ "Story in a game is like a story in a porn movie. It's expected to be there, but it's not that important." - John Carmack |
|
Back to top |
|
|
didl Retired Dev
Joined: 09 Sep 2003 Posts: 1106 Location: Pittsburgh, PA
|
Posted: Thu Sep 13, 2007 3:56 pm Post subject: |
|
|
What is the command line you use to comile your simple *.cpp?
Make sure to use g++ not gcc (since it is C++ code). |
|
Back to top |
|
|
Tigid n00b
Joined: 12 Aug 2007 Posts: 19
|
Posted: Thu Sep 13, 2007 4:23 pm Post subject: |
|
|
Code: | frans@SkyBox ~/projecten/cpp/0004-t2k $ g++ ./main.cpp -o t2k
./main.cpp:2:20: iostream: No such file or directory
./main.cpp:5:19: cstring: No such file or directory
./main.cpp: In function `void openFile()':
./main.cpp:34: error: `cout' was not declared in this scope
./main.cpp:34: error: `endl' was not declared in this scope
./main.cpp:40: error: `cerr' was not declared in this scope
./main.cpp: In function `int main(int, char*)':
./main.cpp:55: error: `cerr' was not declared in this scope
./main.cpp:55: error: `endl' was not declared in this scope
./main.cpp:70: error: `cerr' was not declared in this scope
./main.cpp:70: error: `endl' was not declared in this scope
./main.cpp:74: error: `cout' was not declared in this scope
./main.cpp:74: error: `endl' was not declared in this scope
./main.cpp:89: error: `cerr' was not declared in this scope
./main.cpp:89: error: `endl' was not declared in this scope
./main.cpp:93: error: `cout' was not declared in this scope
./main.cpp:93: error: `endl' was not declared in this scope
./main.cpp:105: error: `cerr' was not declared in this scope
./main.cpp:105: error: `endl' was not declared in this scope
./main.cpp:109: error: `cout' was not declared in this scope
./main.cpp:109: error: `endl' was not declared in this scope
./main.cpp:122: error: `cerr' was not declared in this scope
./main.cpp:122: error: `endl' was not declared in this scope
./main.cpp:126: error: `cout' was not declared in this scope
./main.cpp:126: error: `endl' was not declared in this scope
./main.cpp:138: error: `cerr' was not declared in this scope
./main.cpp:138: error: `endl' was not declared in this scope
./main.cpp:142: error: `cout' was not declared in this scope
./main.cpp:142: error: `endl' was not declared in this scope
./main.cpp:154: error: `cerr' was not declared in this scope
./main.cpp:154: error: `endl' was not declared in this scope
./main.cpp:158: error: `cout' was not declared in this scope
./main.cpp:158: error: `endl' was not declared in this scope
./main.cpp: In function `int parseQuestions()':
./main.cpp:185: error: `cerr' was not declared in this scope
./main.cpp:185: error: `endl' was not declared in this scope
./main.cpp:189: error: `cout' was not declared in this scope
./main.cpp:189: error: `endl' was not declared in this scope
./main.cpp:198: error: `cerr' was not declared in this scope
./main.cpp:198: error: `endl' was not declared in this scope
./main.cpp:202: error: `cout' was not declared in this scope
./main.cpp:202: error: `endl' was not declared in this scope
./main.cpp:210: error: `cerr' was not declared in this scope
./main.cpp:210: error: `endl' was not declared in this scope
./main.cpp:214: error: `cout' was not declared in this scope
./main.cpp:214: error: `endl' was not declared in this scope
./main.cpp:218: error: `cout' was not declared in this scope
./main.cpp:218: error: `endl' was not declared in this scope
./main.cpp:226: error: `cout' was not declared in this scope
./main.cpp:226: error: `endl' was not declared in this scope
./main.cpp:230: error: `cout' was not declared in this scope
./main.cpp:230: error: `endl' was not declared in this scope
./main.cpp:238: error: `cout' was not declared in this scope
./main.cpp:238: error: `endl' was not declared in this scope
./main.cpp:242: error: `cout' was not declared in this scope
./main.cpp:242: error: `endl' was not declared in this scope
./main.cpp:246: error: `cout' was not declared in this scope
./main.cpp:246: error: `endl' was not declared in this scope
./main.cpp:254: error: `cout' was not declared in this scope
./main.cpp:254: error: `endl' was not declared in this scope
./main.cpp:258: error: `cout' was not declared in this scope
./main.cpp:258: error: `endl' was not declared in this scope
./main.cpp:262: error: `cout' was not declared in this scope
./main.cpp:262: error: `endl' was not declared in this scope
./main.cpp:270: error: `cout' was not declared in this scope
./main.cpp:270: error: `endl' was not declared in this scope
./main.cpp:274: error: `cout' was not declared in this scope
./main.cpp:274: error: `endl' was not declared in this scope
./main.cpp:278: error: `cout' was not declared in this scope
./main.cpp:278: error: `endl' was not declared in this scope
./main.cpp:286: error: `cout' was not declared in this scope
./main.cpp:286: error: `endl' was not declared in this scope
./main.cpp:290: error: `cout' was not declared in this scope
./main.cpp:290: error: `endl' was not declared in this scope
./main.cpp:298: error: `cout' was not declared in this scope
./main.cpp:298: error: `endl' was not declared in this scope
./main.cpp:302: error: `cout' was not declared in this scope
./main.cpp:302: error: `endl' was not declared in this scope
./main.cpp:310: error: `cout' was not declared in this scope
./main.cpp:310: error: `endl' was not declared in this scope
./main.cpp:314: error: `cout' was not declared in this scope
./main.cpp:314: error: `endl' was not declared in this scope
./main.cpp:325: error: `cout' was not declared in this scope
./main.cpp:325: error: `endl' was not declared in this scope
frans@SkyBox ~/projecten/cpp/0004-t2k $ |
This is the full output. _________________ "Story in a game is like a story in a porn movie. It's expected to be there, but it's not that important." - John Carmack |
|
Back to top |
|
|
Tigid n00b
Joined: 12 Aug 2007 Posts: 19
|
Posted: Thu Sep 13, 2007 4:41 pm Post subject: |
|
|
Can I unemerge gcc, and emerge it again?
Or do I have compile problems with compiling without compiler? (lol) _________________ "Story in a game is like a story in a porn movie. It's expected to be there, but it's not that important." - John Carmack |
|
Back to top |
|
|
mrybczyn n00b
Joined: 09 Nov 2003 Posts: 26
|
Posted: Thu Sep 13, 2007 5:20 pm Post subject: |
|
|
If you lose your only compiler, you won't be able to compile.
Hence, re-emerge from a binary package, or from the stage-3 tarball (tricky). |
|
Back to top |
|
|
didl Retired Dev
Joined: 09 Sep 2003 Posts: 1106 Location: Pittsburgh, PA
|
Posted: Thu Sep 13, 2007 5:29 pm Post subject: |
|
|
Could you please post a minimal (!) version of your main.cpp
that still exhibits this problem so we can have a look! |
|
Back to top |
|
|
Tigid n00b
Joined: 12 Aug 2007 Posts: 19
|
Posted: Thu Sep 13, 2007 6:50 pm Post subject: |
|
|
didl wrote: | Could you please post a minimal (!) version of your main.cpp
that still exhibits this problem so we can have a look! |
I'm sorry, i could not post that code, but I got the same problem with just a minimal hello world-program.
Code: | //main.cpp
#include <iostream>
using namespace std;
int main()
{
cout << "Hello World" << endl;
return 0;
} |
Code: | g++ ./main.cpp -o main
./main.cpp:1:20: iostream: No such file or directory
./main.cpp: In function `int main()':
./main.cpp:6: error: `cout' was not declared in this scope
./main.cpp:6: error: `endl' was not declared in this scope |
_________________ "Story in a game is like a story in a porn movie. It's expected to be there, but it's not that important." - John Carmack |
|
Back to top |
|
|
Tigid n00b
Joined: 12 Aug 2007 Posts: 19
|
Posted: Thu Sep 13, 2007 8:24 pm Post subject: |
|
|
mrybczyn wrote: | If you lose your only compiler, you won't be able to compile.
Hence, re-emerge from a binary package, or from the stage-3 tarball (tricky). |
Where could i get an AMD-64 binary package? _________________ "Story in a game is like a story in a porn movie. It's expected to be there, but it's not that important." - John Carmack |
|
Back to top |
|
|
mrybczyn n00b
Joined: 09 Nov 2003 Posts: 26
|
Posted: Thu Sep 13, 2007 9:58 pm Post subject: |
|
|
Unfortunately I don't know of any binary package repositories. You could make a binary package yourself on a livecd or vmware image using emerge. Or on another PC. Or ask a friend to send you theirs over the net... You could figure out just the files that are missing from your include directory and extract those from the gentoo_x86_64-stage3.tar.gz
Cheers,
Mitch |
|
Back to top |
|
|
didl Retired Dev
Joined: 09 Sep 2003 Posts: 1106 Location: Pittsburgh, PA
|
Posted: Fri Sep 14, 2007 1:09 pm Post subject: |
|
|
g++ doesn't seem to find the header files. Are you sure
you did a
Code: |
source /etc/profile
|
after setting your compiler via gcc-config? |
|
Back to top |
|
|
warrens Apprentice
Joined: 04 Jan 2005 Posts: 239 Location: Don't Tread On Me!
|
Posted: Fri Sep 14, 2007 2:02 pm Post subject: |
|
|
Edit: nevermind _________________ The BIGGER the GOVERNMENT, the smaller the citizen.
DON'T TREAD ON ME!!!
My Bias #1
The best government is the government that governs least. |
|
Back to top |
|
|
Tigid n00b
Joined: 12 Aug 2007 Posts: 19
|
Posted: Fri Sep 14, 2007 6:40 pm Post subject: |
|
|
didl wrote: | g++ doesn't seem to find the header files. Are you sure
you did a
Code: |
source /etc/profile
|
after setting your compiler via gcc-config? |
I did not change my compiler, it didn't work (because i could not get it installed). But when I am at home i'll give this a try.
I tried it, and have the same problem. I'm going to download the stage-3 tarball. Maybe it works... _________________ "Story in a game is like a story in a porn movie. It's expected to be there, but it's not that important." - John Carmack |
|
Back to top |
|
|
Tigid n00b
Joined: 12 Aug 2007 Posts: 19
|
Posted: Fri Sep 14, 2007 7:53 pm Post subject: |
|
|
The tarball is downloaded. Can i just untar it to / ? _________________ "Story in a game is like a story in a porn movie. It's expected to be there, but it's not that important." - John Carmack |
|
Back to top |
|
|
Tigid n00b
Joined: 12 Aug 2007 Posts: 19
|
Posted: Sun Sep 16, 2007 5:03 pm Post subject: |
|
|
Can I unpack the stage 3 to / without using the gentoo cd? (i already have the iso, but don't have any empty cd ) _________________ "Story in a game is like a story in a porn movie. It's expected to be there, but it's not that important." - John Carmack |
|
Back to top |
|
|
Tigid n00b
Joined: 12 Aug 2007 Posts: 19
|
Posted: Sun Sep 16, 2007 8:18 pm Post subject: |
|
|
(sorry for the quadpost )
I wanted to check which files needed to be replaced, and did a whereis g++. I found out there was an executable called g++ in another directory. That one works right. But when I use the command g++ it does not work.
I have now solved the problem. I just made a soft link from /usr/bin/g++ to /usr/locala/bin/g++ .
Code: | ln -s /usr/bin/g++ /usr/local/bin/g++ |
Thanx for everyone who helped me _________________ "Story in a game is like a story in a porn movie. It's expected to be there, but it's not that important." - John Carmack |
|
Back to top |
|
|
|