public inbox for gcc-help@gcc.gnu.org
 help / color / mirror / Atom feed
* Problems getting g++ to run
@ 2003-03-05 23:04 Karl Gangle
  2003-03-05 23:30 ` glibc irritations Bernd Prager
                   ` (2 more replies)
  0 siblings, 3 replies; 4+ messages in thread
From: Karl Gangle @ 2003-03-05 23:04 UTC (permalink / raw)
  To: gcc-help


Hi,

I am trying to compile a c++ program using g++ in Linux.  The program is

#include <iostream>
#include <string>

int main() {

  string s1( "string1" );

  cout << s1 << endl;

  return 1;
}


The compiler errors indicate that string, cout, endl, and s1 are not
defined.  I think the problem is that the include files are not found.  So,
what needs to be done for g++ to find the include file?  What environment
variables along with there value need to be set?
What needs to be done to set library environment variable values?

If there are any other things that need to be done to get g++ to work please
let me know.

Thank you.

Karl Gangle

^ permalink raw reply	[flat|nested] 4+ messages in thread

* glibc irritations
  2003-03-05 23:04 Problems getting g++ to run Karl Gangle
@ 2003-03-05 23:30 ` Bernd Prager
  2003-03-05 23:33 ` Problems getting g++ to run Oscar Fuentes
  2003-03-06  0:00 ` LLeweLLyn Reese
  2 siblings, 0 replies; 4+ messages in thread
From: Bernd Prager @ 2003-03-05 23:30 UTC (permalink / raw)
  To: gcc-help

Hi everybody,
I'm having troubles with compiling cups-1.1.18 on RedHat 8.1
which kernel 2.4.20 and gcc 3.2.2 and I hope I'm not to much OT since
the problem seems to be related to glibc.
But I found only one glibc-related mailing list which is completely
spammed. So I hope to find help in this group.

I get the error messages:
...
Making all in backend...
Compiling betest.c...
Linking betest...
/lib/libc.so.6: undefined reference to
`_dl_lookup_versioned_symbol_skip@GLIBC_PRIVATE'
/lib/libc.so.6: undefined reference to `_rtld_global@GLIBC_PRIVATE'
/lib/libc.so.6: undefined reference to
`_dl_lookup_versioned_symbol@GLIBC_PRIVATE'
/lib/libc.so.6: undefined reference to `_dl_start_profile@GLIBC_PRIVATE'
/lib/libc.so.6: undefined reference to
`_dl_check_map_versions@GLIBC_PRIVATE'
/lib/libc.so.6: undefined reference to `__libc_enable_secure@GLIBC_PRIVATE'
/lib/libc.so.6: undefined reference to `_dl_get_origin@GLIBC_PRIVATE'
/lib/libc.so.6: undefined reference to `_dl_dst_substitute@GLIBC_PRIVATE'
/lib/libc.so.6: undefined reference to `_dl_debug_state@GLIBC_PRIVATE
...

I found some references on the web where other guys seem to be the same
difficulties
but without a real solutions. The basic advice is "reinstall your system"
what would
be kind of rough for me.
I did some research on my system and encountered that I have several links
to libc:

 /lib/libc.so.6 -> libc-2.2.93.so
 /usr/lib/i686/libc.so.6 -> libc-2.2.93.so
 /usr/lib/libc.so.6 -> libc-2.2.4.so
 /var/ftp/lib/libc.so.6 -> libc-2.2.93.so

and for whatever reasons one of them point to an older libc version.

I tried to correct that by doing a 'ln -sf /lib/libc-2.2.93.so
/usr/lib/libc.so.6'
and that seems to work but after an 'ldconfig' the link point back to the
old
version.

Now I'm too scared to temper to much with my glibc. I did ones crash my
entire
system by deleting a libc version.

Now I have basically two question:

A) Is it possible or likely that this link causes my compiler/linker
failures.
B) How do I correct that without jeopardizing my entire system.

Thanks a lot for any help,
-- Bernd

--
"Everything that can be invented has been invented. "
  - Charles H. Duell, Commissioner, U.S. Office of Patents, 1899


^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: Problems getting g++ to run
  2003-03-05 23:04 Problems getting g++ to run Karl Gangle
  2003-03-05 23:30 ` glibc irritations Bernd Prager
@ 2003-03-05 23:33 ` Oscar Fuentes
  2003-03-06  0:00 ` LLeweLLyn Reese
  2 siblings, 0 replies; 4+ messages in thread
From: Oscar Fuentes @ 2003-03-05 23:33 UTC (permalink / raw)
  To: gcc-help

"Karl Gangle" <kgangle72@attbi.com> writes:

> Hi,
> 
> I am trying to compile a c++ program using g++ in Linux.  The program is
> 
> #include <iostream>
> #include <string>
> 
> int main() {
> 
>   string s1( "string1" );
> 
>   cout << s1 << endl;
> 
>   return 1;
> }
> 
> 
> The compiler errors indicate that string, cout, endl, and s1 are not
> defined.

And, indeed, they are not. All those identifiers are inside std
namespace, like all other C++ Standard Library names, so just prepend
them with std::

#include <iostream>
#include <string>

int main() {

  std::string s1( "string1" );

  std::cout << s1 << std::endl;

  return 1;
}

If you don't want to type lots of std::'s, you can use this too,
although is considered a bad practice by lots of gurus:

#include <iostream>
#include <string>

using namespace std;

int main() {

  string s1( "string1" );

  cout << s1 << endl;

  return 1;
}

[snip]

-- 
Oscar

^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: Problems getting g++ to run
  2003-03-05 23:04 Problems getting g++ to run Karl Gangle
  2003-03-05 23:30 ` glibc irritations Bernd Prager
  2003-03-05 23:33 ` Problems getting g++ to run Oscar Fuentes
@ 2003-03-06  0:00 ` LLeweLLyn Reese
  2 siblings, 0 replies; 4+ messages in thread
From: LLeweLLyn Reese @ 2003-03-06  0:00 UTC (permalink / raw)
  To: Karl Gangle; +Cc: gcc-help

"Karl Gangle" <kgangle72@attbi.com> writes:

> Hi,
> 
> I am trying to compile a c++ program using g++ in Linux.  The program is
> 
> #include <iostream>
> #include <string>

using std::cout;
using std::endl;
using std::string;

> 
> int main() {
> 
>   string s1( "string1" );
> 
>   cout << s1 << endl;
> 
>   return 1;
> }
> 
> 
> The compiler errors indicate that string, cout, endl, and s1 are not
> defined.

They are not part of standard C++. You are looking for std::cout,
    and std::string, std::endl.

> I think the problem is that the include files are not found.  So,
> what needs to be done for g++ to find the include file?  What environment
> variables along with there value need to be set?
> What needs to be done to set library environment variable values?
> 
> If there are any other things that need to be done to get g++ to work please
> let me know.

Now I wish gcc 3.x would say something akin to: 'cout' not
    defined. (Perhaps you need a using directive such as 'using std::cout'
    or explicit qualification?). Of course that kind of warning would
    require each unrecognized name to be looked up a second time ...

^ permalink raw reply	[flat|nested] 4+ messages in thread

end of thread, other threads:[~2003-03-06  0:00 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2003-03-05 23:04 Problems getting g++ to run Karl Gangle
2003-03-05 23:30 ` glibc irritations Bernd Prager
2003-03-05 23:33 ` Problems getting g++ to run Oscar Fuentes
2003-03-06  0:00 ` LLeweLLyn Reese

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).