Compilation problem after OCC5.2 on Linux

Hi,

I get the following compilation error after installing OCC5.2 on Linux.

In file included from /usr/local/CAS5.2/inc/gp.hxx:26,
from incad/algos/convert/CasConvert.cpp:17:
/usr/local/CAS5.2/inc/Standard_Real.hxx: In function `Standard_Integer RealSize ()':
/usr/local/CAS5.2/inc/Standard_Real.hxx:162: `CHAR_BIT' undeclared (first use this function)
/usr/local/CAS5.2/inc/Standard_Real.hxx:162: (Each undeclared identifier is reported only once for each function it appears in.)
In file included from /usr/local/CAS5.2/inc/Standard_Address.hxx:20,
from /usr/local/CAS5.2/inc/Standard.hxx:28,
from /usr/local/CAS5.2/inc/gp.hxx:72,
from incad/algos/convert/CasConvert.cpp:17:
/usr/local/CAS5.2/inc/Standard_Integer.hxx: In function `Standard_Integer IntegerFirst ()':
/usr/local/CAS5.2/inc/Standard_Integer.hxx:129: `INT_MIN' undeclared (first use this function)
/usr/local/CAS5.2/inc/Standard_Integer.hxx: In function `Standard_Integer IntegerLast ()':
/usr/local/CAS5.2/inc/Standard_Integer.hxx:135: `INT_MAX' undeclared (first use this function)
In file included from /usr/local/CAS5.2/inc/Standard_OutOfRange.hxx:33,
from /usr/local/CAS5.2/inc/TCollection_Array1.lxx:1,
from /usr/local/CAS5.2/inc/TColgp_Array1OfPnt.hxx:135,
from incad/algos/convert/CasConvert.cpp:31:
/usr/local/CAS5.2/inc/Standard_SStream.hxx: At top level:
/usr/local/CAS5.2/inc/Standard_SStream.hxx:36: parse error before `{'
/usr/local/CAS5.2/inc/Standard_SStream.hxx:40: parse error before `&'
/usr/local/CAS5.2/inc/Standard_SStream.hxx:41: destructors must be member functions
/usr/local/CAS5.2/inc/Standard_SStream.hxx:42: parse error before `}'
In file included from /usr/local/CAS5.2/inc/Standard_DomainError.hxx:38,
from /usr/local/CAS5.2/inc/Standard_RangeError.hxx:38,
from /usr/local/CAS5.2/inc/Standard_OutOfRange.hxx:38,
from /usr/local/CAS5.2/inc/TCollection_Array1.lxx:1,
from /usr/local/CAS5.2/inc/TColgp_Array1OfPnt.hxx:135,
from incad/algos/convert/CasConvert.cpp:31:
/usr/local/CAS5.2/inc/Standard_Failure.hxx:78: `aReason' was not declared in this scope
/usr/local/CAS5.2/inc/Standard_Failure.hxx:78: invalid data member initiailization

C R Johnson's picture

You are compiling your program not using all of the same pre-processor macro definitions that were used in building OCC itself.

For example, the CHAR_BIT error is because niether of the pre-processor macro definitions expected my Standard.hxx , HAVE_LIMITS or HAVE_LIMITS_H are definied for your compiliation.

One of these macros was defined for compiling OCC but neither are defined for your program.

Probably for a modern Linux distribution, -DHAVE_LIMITS could be added to your compile line, and will probably get past that particular error.

The best solution for this is to use GNU autoconf/automake/configure to build your own program. If you do this you can just add this stuff from the OCC configure.in to your program's configure.in file:
dnl Checks for header files.

AC_HEADER_STDC
AC_LANG([C])
AC_MSG_CHECKING([ for C header files ])
AC_CHECK_HEADERS(dlfcn.h dl.h ieeefp.h time.h sys/time.h pwd.h)
AC_CHECK_HEADERS(sys/statvfs.h sys/vfs.h sys/param.h osfcn.h netdb.h)
AC_CHECK_HEADERS(sys/ioctl.h net/if.h sys/systeminfo.h sys/utsname.h)
AC_CHECK_HEADERS(sysent.h unistd.h sys/unistd.h sys/socket.h)
AC_CHECK_HEADERS(ndir.h sys/ndir.h sys/dir.h signal.h sys/signal.h)
AC_CHECK_HEADERS(sigfpe.h floatingpoint.h sys/machsig.h sys/siginfo.h)
AC_CHECK_HEADERS(malloc.h strings.h sys/stat.h sys/sem.h sys/ipc.h)
AC_CHECK_HEADERS(sys/times.h dirent.h getopt.h sys/vnode.h)


AC_LANG([C++])
AC_MSG_CHECKING([ for C++ header files ])
AC_CHECK_HEADERS(istream ostream istream fstream ios iomanip iostream )
AC_CHECK_HEADERS(stream.h strstream.h istream.h ostream.h fstream.h stdlib.h ios.h iostream.h)
AC_CHECK_HEADERS(iomanip.h limits.h values.h float.h)
AC_CHECK_HEADERS(siginfo.h bits/sigset.h bstring.h sys/types.h sys/select.h)
AC_CHECK_HEADERS(X11/extensions/transovl.h X11/extensions/readdisplay.h)
AC_CHECK_HEADERS(X11/extensions/multibuf.h)
AC_CHECK_HEADERS(sys/filio.h sys/mman.h libc.h)

Then you will have all the macros OCC is expecting defined for your project too.

S.Senthil Kumar's picture

Hi,

I still have problem.

I am using following flags:
CXX Flags :
-D_REENTRANT -D_GNU_SOURCE

CAS Flags :
-DLIN -DLININTEL -DNO_CXX_EXCEPTION -funsigned-char -O3 -DNo_Exception -Wall -x c++ -DCAS5 -Wno-deprecated

INCLUDES Flags :
-I/usr/local/jdk1.4/include -I/usr/local/jdk1.4/include/linux -I/usr/local/CAS5.2/inc

When I include -DHAVE_LIMITS first error goes and I get into following error:

In file included from /usr/local/CAS5.2/inc/Standard_OutOfRange.hxx:33,
from /usr/local/CAS5.2/inc/TCollection_Array1.lxx:1,
from /usr/local/CAS5.2/inc/TColgp_Array1OfPnt.hxx:135,
from incad/algos/convert/CasConvert.cpp:31:
/usr/local/CAS5.2/inc/Standard_SStream.hxx:36: parse error before `{' token
/usr/local/CAS5.2/inc/Standard_SStream.hxx:40: parse error before `&' token
/usr/local/CAS5.2/inc/Standard_SStream.hxx:41: destructors must be member
functions
/usr/local/CAS5.2/inc/Standard_SStream.hxx:42: parse error before `}' token
In file included from /usr/local/CAS5.2/inc/Standard_DomainError.hxx:38,
from /usr/local/CAS5.2/inc/Standard_RangeError.hxx:38,
from /usr/local/CAS5.2/inc/Standard_OutOfRange.hxx:38,
from /usr/local/CAS5.2/inc/TCollection_Array1.lxx:1,
from /usr/local/CAS5.2/inc/TColgp_Array1OfPnt.hxx:135,
from incad/algos/convert/CasConvert.cpp:31:
/usr/local/CAS5.2/inc/Standard_Failure.hxx:78: `aReason' was not declared in
this scope
/usr/local/CAS5.2/inc/Standard_Failure.hxx:78: invalid data member
initialization
/usr/local/CAS5.2/inc/Standard_Failure.hxx:78: (use `=' to initialize static
data members)
/usr/local/CAS5.2/inc/Standard_Failure.hxx:78: variable or field `Raise'
declared void
/usr/local/CAS5.2/inc/Standard_Failure.hxx:78: declaration of `int
Standard_Failure::Raise'
/usr/local/CAS5.2/inc/Standard_Failure.hxx:77: conflicts with previous
declaration `static void Standard_Failure::Raise(char* = )'
In file included from /usr/local/CAS5.2/inc/Standard_RangeError.hxx:38,
from /usr/local/CAS5.2/inc/Standard_OutOfRange.hxx:38,
from /usr/local/CAS5.2/inc/TCollection_Array1.lxx:1,
from /usr/local/CAS5.2/inc/TColgp_Array1OfPnt.hxx:135,
from incad/algos/convert/CasConvert.cpp:31:
/usr/local/CAS5.2/inc/Standard_DomainError.hxx:65: `aReason' was not declared
in this scope
/usr/local/CAS5.2/inc/Standard_DomainError.hxx:65: invalid data member
initialization
/usr/local/CAS5.2/inc/Standard_DomainError.hxx:65: variable or field `Raise'
declared void
/usr/local/CAS5.2/inc/Standard_DomainError.hxx:65: declaration of `int
Standard_DomainError::Raise'
/usr/local/CAS5.2/inc/Standard_DomainError.hxx:64: conflicts with previous
declaration `static void Standard_DomainError::Raise(char* = )'
In file included from /usr/local/CAS5.2/inc/Standard_OutOfRange.hxx:38,
from /usr/local/CAS5.2/inc/TCollection_Array1.lxx:1,
from /usr/local/CAS5.2/inc/TColgp_Array1OfPnt.hxx:135,
from incad/algos/convert/CasConvert.cpp:31:
/usr/local/CAS5.2/inc/Standard_RangeError.hxx:65: `aReason' was not declared in
this scope
/usr/local/CAS5.2/inc/Standard_RangeError.hxx:65: invalid data member
initialization
/usr/local/CAS5.2/inc/Standard_RangeError.hxx:65: variable or field `Raise'
declared void
/usr/local/CAS5.2/inc/Standard_RangeError.hxx:65: declaration of `int
Standard_RangeError::Raise'
/usr/local/CAS5.2/inc/Standard_RangeError.hxx:64: conflicts with previous
declaration `static void Standard_RangeError::Raise(char* = )'
In file included from /usr/local/CAS5.2/inc/TCollection_Array1.lxx:1,
from /usr/local/CAS5.2/inc/TColgp_Array1OfPnt.hxx:135,
from incad/algos/convert/CasConvert.cpp:31:
/usr/local/CAS5.2/inc/Standard_OutOfRange.hxx:65: `aReason' was not declared in
this scope
/usr/local/CAS5.2/inc/Standard_OutOfRange.hxx:65: invalid data member
initialization
/usr/local/CAS5.2/inc/Standard_OutOfRange.hxx:65: variable or field `Raise'

Regards
Senthil Kumar

gunslinger's picture

hi,
i have the very same problem,
did u solve it? How?

Thx! the G.

Vaclav Smilauer's picture

Two ways, not sure which is the right one (depends on OCC compilation settings?). 1. #define USE_STL_STREAM, #include or 2. #include [deprecated]

Afterwards, DO NOT FORGET "using namespace std;" (OCC does not care about std); finally, you can #include

#include