1752577 Members
4650 Online
108788 Solutions
New Discussion юеВ

cc compilation error.

 
yhlim
Frequent Visitor

cc compilation error.

Hi,

I am very new to HP-UX and having compilation problem for cc/aCC

I was trying to compile MYSQL 5.1.72 on HP-UX 11.31 with cc/aCC 06.12, but it failed compile with

following errors on "chared.c"

"chartype.h", line 57: error #2035: #error directive: wchar_t must store ISO
10646 characters
#error wchar_t must store ISO 10646 characters
^

"chartype.h", line 195: error #2020: identifier "mbstate_t" is undefined
protected ssize_t ct_encode_char(char *, size_t, Char, mbstate_t *);

 

the system command for this compilation is 

 cc -DHAVE_CONFIG_H -I. -I../../include -I../../include -I../../include     +DD64 -DHPUX11  -DSNPRINTF_RETURN_TRUNC -DHAVE_BROKEN_PREAD -DHAVE_BROKEN_GETPASS -DNO_FCNTL_NONBLOCK -DDO_NOT_REMOVE_THREAD_WRAPPERS -DHAVE_BROKEN_PTHREAD_COND_TIMEDWAIT -DHAVE_BROKEN_INLINE -DUNIV_MUST_NOT_INLINE -DUNIV_HPUX -DUNIV_MUST_NOT_INLINE -DUNIV_HPUX -c chared.c

 

To resolve this error, I have added /opt/aCC/include to compile option, then now I pass the first compilation error but get 100 errors of type undefined for wchar_t, size_t, wint_t, etc and could not open source file error for any header files under include such as #include <include/stdio.h>

 

Is there any way to resolve this problem?

 

6 REPLIES 6
Steven Schweda
Honored Contributor

Re: cc compilation error.

> I was trying to compile MYSQL 5.1.72 on HP-UX 11.31 with cc/aCC 06.12,
> [...]

   I've never touched MySQL (any version), and I don't have cc/aCC
(other than the bundled compiler), so I know nothing, but...

   First:

      uname -a

> To resolve this error, I have added /opt/aCC/include to compile
> option, [...]

   I've never seen a compiler which needed help to find its own standard
header files.  Does it work at all, or was there a problem with the
compiler installation?  Can you compile a simple program (with a
standard "#include <>" directive)?  For example:

rux# cat hm.c
#include <stdio.h>
main() { printf( "Hi, mom!\n"); }

rux# cc hm.c

rux# ./a.out
Hi, mom!

   If the compiler can find its own header files in such a simple case,
then it should be able to do it in a more complex case.  Unless, of
course, it's getting bad command options.

   After you "added /opt/aCC/include to compile option", what was the
actual compiler command?

> [...] then now I pass the first compilation error but get 100 errors
> of type undefined for wchar_t, size_t, wint_t, etc [...]

   That sounds as if you're still not getting the required header files
(where those types should be defined).

> [...] and could not open source file error for any header files under
> include such as #include <include/stdio.h>

   And that might be the real problem.  You wrote that part of your
original compiler command was:

      -I. -I../../include -I../../include -I../../include

   Three "-I../../include" options are probably not much better than
one.  What was the current directory for that command?  Where is the
(MySQL) "include" directory?  (I assume that there is one.)  Knowing
nothing, I'd expect "../../include" to lead to it.  If it doesn't, then
you would seem to need more/better "-I" options.

   With some compilers, a "-I" option with no directory (plain "-I", not
"-I<dir>") will prevent the compiler from finding its own standard
header files.  I don't see that here, but, with my weak psychic powers,
I can't see everything you did.

   In other words, stop worrying about the details of the compiler
errors/warnings, and try to learn what's preventing the compiler from
finding all the right header files.

> Is there any way to resolve this problem?

   Probably, but you may need to provide more information about exactly
what you did.

Dennis Handly
Acclaimed Contributor

Re: cc compilation error.

> chartype.h", line 57: error #2035: #error directive: wchar_t must store ISO 10646 character

 

You need to look at the #if before that line to see what it doesn't like.

 

> I have added /opt/aCC/include


Do NOT include C++ headers in a C compilation!

 

>With some compilers, a "-I" option with no directory

 

No such option with aC++.  A -l must have a path.

yhlim
Frequent Visitor

Re: cc compilation error.

Thanks for the reply.

 

First, yes I am able to compile and run a single program with standard include directive.

 

Secondly, the actual compiler command aftere I added /opt/aCC/include is like this:

cc -DHAVE_CONFIG_H -I. -I../../include -I../../include -I../../include -I/opt/aCC/include     +DD64 -DHPUX11  -DSNPRINTF_RETURN_TRUNC -DHAVE_BROKEN_PREAD -DHAVE_BROKEN_GETPASS -DNO_FCNTL_NONBLOCK -DDO_NOT_REMOVE_THREAD_WRAPPERS -DHAVE_BROKEN_PTHREAD_COND_TIMEDWAIT -DHAVE_BROKEN_INLINE -DUNIV_MUST_NOT_INLINE -DUNIV_HPUX -DUNIV_MUST_NOT_INLINE -DUNIV_HPUX -c chared.c

 

Before I added /opt/aCC/include to compiler command, compiler throws error at following logics of user defined header file

#ifndef __STDC_ISO_10646__
/* In many places it is assumed that the first 127 code points are ASCII
* compatible, so ensure wchar_t indeed does ISO 10646 and not some other
* funky encoding that could break us in weird and wonderful ways. */
#error wchar_t must store ISO 10646 characters
#endif

 

after I added /opt/aCC/include path to compile option, compiler was able to find __STDC_ISO_10646__ but 

 

throws errors that I mentioned at original post.

 

Moreover, those three "-I../../include" options are added by MySQL automake from Makefile.am. 

 

As I explore file sytem to find out the location of standard header files, I have found two different include path with different directory architecture.

 

1. /opt/aCC/include

this directory has some C Standard header files(*.h) as well as c++  standard header files(without .h)

 

2. /usr/include (such directory that I'm assuming to be default include path for cc/aCC)

this directory has all C Standard header files that are located in /opt/aCC/include and more. In addition, this directory has sub directories such as sys, io, net, aCC and etc for c++ standard header files.

 

In conclusion, /opt/aCC/include has some of C Standard header files from /usr/include and C++ Standard header in same directroy.  However,  when I open C++ Standard header file such as cwchar in /opt/aCC/incude, it has preprocessor directives such as #include <include/stdio.h>. it looks strange to me because in /opt/aCC/include, cwchar and stdio.h are located at same directory, but cwchar inludes header file under include which does not exist in /opt/aCC/include. I assume this is the reasons for all those 100 of compilation errors.

 

To resolve this, I tried to include /usr/include in compile option (which I shouldn't have done it becuase /usr/include seems to be the default include path). But as soon as I compiled it, compiler throws exactly same errors as original compile command (generated by MySQL configuration). compiler was not able to find stddef.h file in /usr/include while there is stddef.h exists!

 

It looks like compiler is not able to find header files due to some reasons that I couldn't find

 

and I have no idea why /opt/aCC/include has c++ header files in same directory as C header files while c++ header files are looking for C header files in subdirectory.

 

I hope I have explained enough for you to understand.

Dennis Handly
Acclaimed Contributor

Re: cc compilation error.

> cc/aCC 06.12

 

This is obsolete and not supported.  The latest is at least A.06.28.

 

>Before I added /opt/aCC/include to compiler command, compiler throws error

 

As I said, you can NOT add that include path.  You must go back to your original command and solve that problem and not cause even more.  That's the path for the obsolete aCC -AP version.

 

> /opt/aCC/include this directory has some C Standard header files(*.h) as well as C++  standard header files

 

That's why you must not include it.

 

> /usr/include (such directory that I'm assuming to be default include path for cc/aCC)

 

Yes, these are the system C include files.  Most have been C++ified.

 

> I have no idea why /opt/aCC/include has C++ header files in same directory as C header files

 

That's the trick to put the C Standard names into the std namespace.

On 11.31 I don't see any definitions of __STDC_ISO_10646__.  I do see the include guards __STDC_ISO646_H and _ISO646_INCLUDED.  But these are for <iso646.h>.

So you could add -D__STDC_ISO_10646__ and see how far you get.

I.e. a wchar_t is 4 bytes, plenty big enough.

yhlim
Frequent Visitor

Re: cc compilation error.

Thank you for your reply.

In case you needed, here is version information for both aCC and cc 

- aCC: HP C/aC++ B3910B A.06.12 [Nov 03 2006]

- cc: HP C/aC++ B3910B A.06.12 [Nov 03 2006]

After adding -D__STDC_ISO_10646__ in compile option, I was able to pass first error which is 

"

"chartype.h", line 57: error #2035: #error directive: wchar_t must store ISO
10646 characters
#error wchar_t must store ISO 10646 characters
^

"

However, second error, "chartype.h", line 195: error #2020: identifier "mbstate_t" is undefined
protected ssize_t ct_encode_char(char *, size_t, Char, mbstate_t *);, still arose.

I assume that the error occurs becasue compiler could not find proper header filed in its path and that was the reason that I was messing up with all include pathes.

 

As of now, original compile command created by mysql configure is as follow:

cc -DHAVE_CONFIG_H -I. -I../../include -I../../include -I../../include     +DD64 -D__STDC_ISO_10646__   -DHPUX11  -DSNPRINTF_RETURN_TRUNC -DHAVE_BROKEN_PREAD -DHAVE_BROKEN_GETPASS -DNO_FCNTL_NONBLOCK -DDO_NOT_REMOVE_THREAD_WRAPPERS -DHAVE_BROKEN_PTHREAD_COND_TIMEDWAIT -DHAVE_BROKEN_INLINE -DUNIV_MUST_NOT_INLINE -DUNIV_HPUX -DUNIV_MUST_NOT_INLINE -DUNIV_HPUX -c chared.c

 

those repetitive -I../../include were automatically generated by configure and CFLAGS and CXXFLAGS that I use for configure is as follow:

CC=cc CXX=aCC CFLAGS="+DD64 -D__STDC_ISO_10646__" CXXFLAGS="+DD64 -D__STDC_ISO_10646__"

 

it would be pleausre if you could give me more help on this.

 

thank you

 

 

Dennis Handly
Acclaimed Contributor

Re: cc compilation error for mbstate_t

>I assume that the error occurs because compiler could not find proper header.

 

It occurs because you didn't tell it to use C99.  Compile with c99 driver.