Gentoo Forums
Gentoo Forums
Gentoo Forums
Quick Search: in
wierd C++ errors in Kdevelop
View unanswered posts
View posts from last 24 hours

 
Reply to topic    Gentoo Forums Forum Index Duplicate Threads
View previous topic :: View next topic  
Author Message
Devrethman
Tux's lil' helper
Tux's lil' helper


Joined: 29 Jan 2005
Posts: 141
Location: Phoenix, AZ

PostPosted: Wed Jul 06, 2005 12:41 am    Post subject: wierd C++ errors in Kdevelop Reply with quote

I'm trying to learn C++, and ever since i started using linux to do ti in, i have been getting really wierd errors, i don't know if it's a linux thing, or a GCC thing or a kdevelop thing or an amd64 thing or a whatever thing, but it's getting really annoying and i am thinking about going back to windows because of it. so, on to the wierd errors.

this is what shows up in the "messages" dialog in Kdevelop when i try to build my program.

Code:
cd '/home/unclefuzzums/CPP/hello/debug' && WANT_AUTOCONF_2_5="1" WANT_AUTOMAKE_1_6="1" gmake -k
compiling hello.cpp (g++)
/usr/lib/gcc/x86_64-pc-linux-gnu/3.4.3/include/g++-v3/x86_64-pc-linux-gnu/bits/c++config.h:57: error: expected unqualified-id before "namespace"
/usr/lib/gcc/x86_64-pc-linux-gnu/3.4.3/include/g++-v3/x86_64-pc-linux-gnu/bits/c++config.h:57: error: expected `,' or `;' before "namespace"
/usr/lib/gcc/x86_64-pc-linux-gnu/3.4.3/include/g++-v3/x86_64-pc-linux-gnu/bits/c++config.h:61: error: expected namespace-name before ';' token
/usr/lib/gcc/x86_64-pc-linux-gnu/3.4.3/include/g++-v3/x86_64-pc-linux-gnu/bits/c++config.h:61: error: `<type error>' is not a namespace
*** Exited with status: 2 ***


i have no idea what c++config.h is, does or anything like that. i didn't include it in any of my source files, so i don't know why it's even trying to compile it.
excuse my ignorance if this is something trivial, but i'm a total n00b to programming. and thanks in advance for any help
_________________
Signature is out for lunch. Feel free to talk to its empty desk.
Back to top
View user's profile Send private message
Halcy0n
Developer
Developer


Joined: 17 Sep 2003
Posts: 1682
Location: Freehold, NJ

PostPosted: Wed Jul 06, 2005 2:24 am    Post subject: Reply with quote

It'd probably help if you gave us your code (in code tags), if its short, or just cut it down to a small reproducable case.
_________________
Mark Loeser
http://www.halcy0n.com
Back to top
View user's profile Send private message
mieasa
n00b
n00b


Joined: 13 Feb 2005
Posts: 10

PostPosted: Mon Jul 11, 2005 3:05 am    Post subject: wierd C++ errors in Kdevelop Reply with quote

I am also new to linux, learning C++ and getting strange error messaages when I compile my following test program using gcc test.cpp command.

#include <iostream.h>

int main()
{

std::cout << "This is a test program";

return 0;

}

Error messages:

bash-2.05b$ gcc test.cpp
In file included from /usr/lib/gcc/x86_64-pc-linux-gnu/3.4.2/include/g++-v3/backward/iostream.h:31, from test.cpp:1:
/usr/lib/gcc/x86_64-pc-linux-gnu/3.4.2/include/g++-v3/backward/backward_warning.h:32:2: warning: #warning This file includes at least one deprecated or antiquated header. Please consider using one of the 32 headers found in section 17.4.1.2 of the C++ standard. Examples include substituting the <X> header for the <X.h> header for C++ includes, or <iostream> instead of the deprecated header <iostream.h>. To disable thiswarning use -Wno-deprecated.
/tmp/cchuBv8M.o(.text+0x19): In function `std::__verify_grouping(char const*, unsigned long, std::basic_string<char, std::char_traits<char>,std::allocator<char> > const&)':
: undefined reference to `std::basic_string<char, std::char_traits<char>, std::allocator<char> >::size() const'
/tmp/cchuBv8M.o(.text+0x70): In function `std::__verify_grouping(char const*, unsigned long, std::basic_string<char, std::char_traits<char>,std::allocator<char> > const&)':
: undefined reference to `std::basic_string<char, std::char_traits<char>, std::allocator<char> >::operator[](unsigned long) const'
/tmp/cchuBv8M.o(.text+0xb3): In function `std::__verify_grouping(char const*, unsigned long, std::basic_string<char, std::char_traits<char>,std::allocator<char> > const&)':
: undefined reference to `std::basic_string<char, std::char_traits<char>, std::allocator<char> >::operator[](unsigned long) const'
/tmp/cchuBv8M.o(.text+0xe3): In function `std::__verify_grouping(char const*, unsigned long, std::basic_string<char, std::char_traits<char>,std::allocator<char> > const&)':
: undefined reference to `std::basic_string<char, std::char_traits<char>, std::allocator<char> >::operator[](unsigned long) const'
/tmp/cchuBv8M.o(.text+0x124): In function `main':
: undefined reference to `std::cout'
/tmp/cchuBv8M.o(.text+0x129): In function `main':
: undefined reference to `std::basic_ostream<char, std::char_traits<char> >& std::operator<< <std::char_traits<char> >(std::basic_ostream<char, std::char_traits<char> >&, char const*)'
/tmp/cchuBv8M.o(.text+0x157): In function `__static_initialization_and_destruction_0(int, int)':
: undefined reference to `std::ios_base::Init::Init()'
/tmp/cchuBv8M.o(.text+0x184): In function `__tcf_0':
: undefined reference to `std::ios_base::Init::~Init()'
/tmp/cchuBv8M.o(.eh_frame+0x11): undefined reference to `__gxx_personality_v0'
collect2: ld returned 1 exit status

I am wondering that am I missing any files to include. Please someone help me.
Back to top
View user's profile Send private message
aja
l33t
l33t


Joined: 26 Aug 2002
Posts: 705
Location: Edmonton, Canada

PostPosted: Mon Jul 11, 2005 3:29 am    Post subject: Re: wierd C++ errors in Kdevelop Reply with quote

If you want to compile C++, you have to use g++, not gcc. Is that what you are doing?

mieasa wrote:

#include <iostream.h>


Should be
Code:
 #include <iostream>

That's what your first warning was about. That may also resolve some of your other problems which appear to be namespace related.

Minor other issues, that are somewhat taste-dependant, are:

[1] Get in the habit of specifying void instead of using an empty arg-list [int main(void)]. You also might want to get used to using the other valid signature: int main (int argc, char** argv) - which is used for accepting command-line args.

[2] Especially in Linux, you should be in the habit of always terminating cout insertions with a std::flush or a std::endl (the latter if you want a newline). [std::cout << "bleah" << std::flush;] This helps prevent problems with buffered I/O.
Back to top
View user's profile Send private message
aja
l33t
l33t


Joined: 26 Aug 2002
Posts: 705
Location: Edmonton, Canada

PostPosted: Mon Jul 11, 2005 3:32 am    Post subject: Reply with quote

Just noticed that you are using kdevelop. As a sanity check against misconfigurations (or extraneous code and libraries) from kdevelop, how does:

Code:

g++ -g -Wall -pedantic main.cpp -o testprog


Work? Does it compile? What output? Substitute your filename for main.cpp.
Back to top
View user's profile Send private message
Halcy0n
Developer
Developer


Joined: 17 Sep 2003
Posts: 1682
Location: Freehold, NJ

PostPosted: Mon Jul 11, 2005 3:34 am    Post subject: Re: wierd C++ errors in Kdevelop Reply with quote

aja wrote:
[1] Get in the habit of specifying void instead of using an empty arg-list [int main(void)].

Unnecessary. An empty declaration list is the same as specifying "void" as the only parameter. This is definitely a taste thing. Just wanted to point that out :)
_________________
Mark Loeser
http://www.halcy0n.com
Back to top
View user's profile Send private message
routerguy
Guru
Guru


Joined: 07 Feb 2004
Posts: 462

PostPosted: Mon Jul 11, 2005 3:39 am    Post subject: Reply with quote

Well, the void thing is the "proper" way to do it according to the ISO standard, but since that was added after ANSI C, gcc doesn't really care.
Back to top
View user's profile Send private message
aja
l33t
l33t


Joined: 26 Aug 2002
Posts: 705
Location: Edmonton, Canada

PostPosted: Mon Jul 11, 2005 3:46 am    Post subject: Re: wierd C++ errors in Kdevelop Reply with quote

Halcy0n wrote:

Unnecessary. An empty declaration list is the same as specifying "void" as the only parameter. This is definitely a taste thing. Just wanted to point that out :)


That'd be why I said "somewhat taste-dependant". :-)

Yes, the spec specifies that an empty arg-list defaults to void, but I believe (especially with beginners) that you should always be explicit in source-code, rather than accepting defaults from the spec (especially since defaults are always the most mutable areas of a spec). A case in point is the C default that said if you don't specify a return type (like void), it would default to int (which burned a lot of newbs).

Of course, I don't specify one for destructors, for obvious reasons... :-)

But, you're entirely correct that it's not a strict requirement of the spec, and that it is a matter of taste.
Back to top
View user's profile Send private message
dmitchell
Veteran
Veteran


Joined: 17 May 2003
Posts: 1159
Location: Austin, Texas

PostPosted: Mon Jul 11, 2005 11:48 am    Post subject: Re: wierd C++ errors in Kdevelop Reply with quote

Bjarne Stroustrup wrote:
C with Classes introduced the notation f(void) for a function f that takes no arguments as a contrast to f() that in C declares a function that can take any number of arguments of any type without any type check. My users soon convinced me, however, that the f(void) notation wasn't elegant, and that having functions declared f() accept arguments wasn't intuitive. Consequently, the result of the experiment was to have f() mean a function f that takes no arguments, as any novice would expect. It took support from both Doug McIlroy and Dennis Ritchie for me to build up the courage to make this break from C. Only after they used the word abomination about f(void) did I dare give f() the obvious meaning.

Do with that what you will. Also see item 29.4 of C++ FAQ Lite, Should I use f(void) or f()?
_________________
Your argument is invalid.
Back to top
View user's profile Send private message
mieasa
n00b
n00b


Joined: 13 Feb 2005
Posts: 10

PostPosted: Mon Jul 11, 2005 11:53 am    Post subject: Reply with quote

g++ command with the given options works fine. I don't see any warnings or errors. Now I can proceed with C++ learning. Thanks for your support and help.
Back to top
View user's profile Send private message
aja
l33t
l33t


Joined: 26 Aug 2002
Posts: 705
Location: Edmonton, Canada

PostPosted: Mon Jul 11, 2005 5:46 pm    Post subject: Reply with quote

miesa: Glad to hear it.

danmitchell: Those are some pretty good references. :-) Maybe I'll have to modify my stance on that - I hadn't realized it indicated the old C programmer in me coming out, although I think "abomination" is going a bit far.

Halcy0n: Mmm. Maybe I should have just left your comment alone.
Back to top
View user's profile Send private message
desultory
Administrator
Administrator


Joined: 04 Nov 2005
Posts: 9218

PostPosted: Fri Nov 02, 2007 3:59 am    Post subject: Reply with quote

Moved from Portage & Programming to Duplicate Threads, refer to topic "Libtool.m4 and ltmain.sh Problems". This problem has been reported in the KDE bug tracking system, where it has been marked as an invalid bug, though it is also mentioned in the kdevelop FAQ.
Back to top
View user's profile Send private message
Display posts from previous:   
Reply to topic    Gentoo Forums Forum Index Duplicate Threads All times are GMT
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum