* AIX and tolower()
@ 2002-06-01 7:08 GCS
2002-06-09 16:24 ` David Edelsohn
0 siblings, 1 reply; 4+ messages in thread
From: GCS @ 2002-06-01 7:08 UTC (permalink / raw)
To: gcc-help
Hi!
I have gcc 3.0.1 on AIX 5.1. When I compile a program, the linking phase
gives:
ld: 0711-345 Use the -bloadmap or -bnoquiet option to obtain more information.
ld: 0711-317 ERROR: Undefined symbol: ._Z7toloweri
Previously I had to copy libgcc.a from /usr/local/lib to /lib, otherwise it
was not found. Where is the code for tolower()?
Ofcourse -lgcc is used.
Thanks in advance,
GCS
^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: AIX and tolower()
2002-06-01 7:08 AIX and tolower() GCS
@ 2002-06-09 16:24 ` David Edelsohn
0 siblings, 0 replies; 4+ messages in thread
From: David Edelsohn @ 2002-06-09 16:24 UTC (permalink / raw)
To: GCS; +Cc: gcc-help
>>>>> GCS writes:
GCS> Where is the code for tolower()?
libstdc++ defines tolower methods for some classes of objects and
AIX libc defines tolower(). Is tolower() declared correctly in the
appropriate scope?
David
^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: AIX and tolower()
2002-06-09 23:15 GCS
@ 2002-06-10 7:38 ` David Edelsohn
0 siblings, 0 replies; 4+ messages in thread
From: David Edelsohn @ 2002-06-10 7:38 UTC (permalink / raw)
To: GCS; +Cc: gcc-help
>>>>> GCS writes:
GCS> I think it is correct. Details are coming:
GCS> the file begins with #include <ctype.h> which holds the definition for tolower
GCS> as 'extern int tolower(int)'. Later, the source has a
GCS> #if defined AIX
GCS> #define abc() tolower()
GCS> #endif
GCS> etc.
GCS> Then it is used in a loop:
GCS> for(i=0;i<strlen(string);i++)
GCS> string[i]=abc(string[i]);
GCS> Do you see any bad thing in the above usage?
Your example does not appear to use any C++ objects. If "string"
is a C-like string and you want to invoke a function in the C library, you
need to declare the function extern "C"
extern "C" int tolower(int);
If you write the program with the appropriate C++ objects which
can access ctype, then tolower is already provided as a method on that
object.
GCS> Btw, the linker gets libstdc++ to link with. I could not force libc, as -lc and
GCS> -l/lib/libc.a gave me an error.
GCC always links with the system libc automatically, unless you
tell it not to. g++ always links with libstdc++ automatically.
The compiler is mangling the invocation of tolower in your
original example because you told it tolower was a C++ function. This is
not a G++ or libstdc++ problem, it is a C++ programming question. When
you tell the compiler the correct information, the program will link
correctly.
David
^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: AIX and tolower()
@ 2002-06-09 23:15 GCS
2002-06-10 7:38 ` David Edelsohn
0 siblings, 1 reply; 4+ messages in thread
From: GCS @ 2002-06-09 23:15 UTC (permalink / raw)
To: David Edelsohn; +Cc: gcc-help
[-- Attachment #1: Type: text/plain, Size: 1251 bytes --]
Hi David,
> GCS> Where is the code for tolower()?
> libstdc++ defines tolower methods for some classes of objects and
> AIX libc defines tolower(). Is tolower() declared correctly in the
> appropriate scope?
I think it is correct. Details are coming:
the file begins with #include <ctype.h> which holds the definition for tolower
as 'extern int tolower(int)'. Later, the source has a
#if defined AIX
#define abc() tolower()
#endif
etc.
Then it is used in a loop:
for(i=0;i<strlen(string);i++)
string[i]=abc(string[i]);
Do you see any bad thing in the above usage?
Btw, the linker gets libstdc++ to link with. I could not force libc, as -lc and
-l/lib/libc.a gave me an error.
The latter said -l /lib/libc.a (notice the space separator even if I do not put
any between the two in the command line) could not be found. All I can
think of that ld does not follow symlinks; at least /lib/libc.a is a symlink
on my system, and I had a previous lib problem which was solved when
I have copied the lib from /usr/local/lib to /lib.
Would it be a solution if I do something like
#define tolower(c) ((c)-('A'-'a')) ?
My AIX is 5.1, and gcc is 3.0.1.
Thanks in advance if you have any idea for this problem,
GCS
^ permalink raw reply [flat|nested] 4+ messages in thread
end of thread, other threads:[~2002-06-10 14:38 UTC | newest]
Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2002-06-01 7:08 AIX and tolower() GCS
2002-06-09 16:24 ` David Edelsohn
2002-06-09 23:15 GCS
2002-06-10 7:38 ` David Edelsohn
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).