Open Cascade 5.2 C++ compilation issues

I get the following errors while trying to compile the Visual C++ 6.0 project, referencing Open Cascade 5.2 classes.

Please kindly advise if you have come across similar issues.

Kind regards,

Mark

Files:
"Standard_Stream.hxx"
"Standard_OStream.hxx"

Preprocessor definitions:
HAVE_IOSTREAM_H, HAVE_IOMANIP_H, HAVE_FSTREAM_H

C:\OCC\ROS\INC\Standard.hxx(94) : error C2872: 'ostream' : ambiguous symbol
C:\OCC\ROS\INC\Standard.hxx(96) : error C2872: 'ostream' : ambiguous symbol
C:\OCC\ROS\INC\MMgt_StorageManager.hxx(69) : error C2872: 'ostream' : ambiguous symbol
C:\OCC\ROS\INC\MMgt_StorageManager.lxx(28) : error C2872: 'ostream' : ambiguous symbol
C:\OCC\ROS\INC\MMgt_StorageManager.hxx(114) : error C2872: 'ostream' : ambiguous symbol
C:\OCC\ROS\INC\Standard_Storable.hxx(76) : error C2872: 'ostream' : ambiguous symbol
C:\OCC\ROS\INC\Standard_Storable.hxx(121) : error C2872: 'ostream' : ambiguous symbol
C:\OCC\ROS\INC\Standard_Transient_proto.hxx(52) : error C2872: 'ostream' : ambiguous symbol
C:\OCC\ROS\INC\Handle_Standard_Transient.hxx(92) : error C2872: 'ostream' : ambiguous symbol
C:\OCC\ROS\INC\Handle_Standard_Transient.hxx(96) : error C2872: 'ostream' : ambiguous symbol
C:\OCC\ROS\INC\Handle_Standard_Transient.hxx(203) : error C2872: 'ostream' : ambiguous symbol
C:\OCC\ROS\INC\Standard_SStream.hxx(40) : error C2872: 'ostream' : ambiguous symbol
C:\OCC\ROS\INC\Standard_Type.hxx(85) : error C2872: 'ostream' : ambiguous symbol
C:\OCC\ROS\INC\Standard_Type.hxx(101) : error C2872: 'ostream' : ambiguous symbol
C:\OCC\ROS\INC\Standard_Type.hxx(102) : error C2872: 'ostream' : ambiguous symbol
C:\OCC\ROS\INC\Standard_Type.hxx(103) : error C2872: 'ostream' : ambiguous symbol
C:\OCC\ROS\INC\Standard_Type.lxx(13) : error C2872: 'ostream' : ambiguous symbol
C:\OCC\ROS\INC\Standard_Type.lxx(13) : error C2872: 'ostream' : ambiguous symbol
C:\OCC\ROS\INC\Standard_Type.hxx(157) : error C2872: 'ostream' : ambiguous symbol
C:\OCC\ROS\INC\Standard_Failure.hxx(68) : error C2872: 'ostream' : ambiguous symbol
C:\OCC\ROS\INC\Standard_Failure.hxx(69) : error C2872: 'ostream' : ambiguous symbol
C:\OCC\ROS\INC\Standard_Failure.lxx(9) : error C2872: 'ostream' : ambiguous symbol
C:\OCC\ROS\INC\Standard_Failure.lxx(9) : error C2872: 'ostream' : ambiguous sym

Rob Bachrach's picture

If you look at the OCC stream header files, you will see that PC
compiles (with WNT defined as it should be) include the new
style stream header files: "#include "

If your code references the old style stream header files:
"#include ", this leads to the ambiguous symbol.
The only solution I found was to include the new style header
files in my old code as well. In some cases (as I use an older
compiler on UNIX), this meant including my header files in
"#ifdef...#endif" blocks based on WNT.

tasora's picture

Yes, I had the same problem.
You can fix this simply using, in your source code, the
new #include instead of the old-style
#include Then, everything should
compile without problems.
Just in case: switching from iostream.h to
iostream, in my custom makefile I had to link also
"C:\Programmi\Microsoft Visual Studio\VC98\Lib\libcp.lib"
"C:\Programmi\Microsoft Visual Studio\VC98\Lib\libcpmt.lib"
"C:\Programmi\Microsoft Visual Studio\VC98\Lib\msvcprt.lib"
otherwise I had some unresolved symbols during link process.

best regards

Philippe CARRET's picture

One source of inspiration for solving compilation errors are OCC MFC samples. Look what are the difference in source code from occ4.0 to occ5.1 or 5.2 when you have a problem and in ten minutes you generally get the solution !

Instead of ostream ostr;

You can use :

Standard_SStream ostr; // in sample Viewer 3d
ostr << Standard_Failure::Caught() << endl;