Beginner Question on compiling a simple code

Hi,

I am trying to write a real simple code with Open Cascade just to learn how to compile and link. Here is my code:

[croberts@cruncher ~/sample]$ cat MakeBox.C

#include "BRepPrimAPI_MakeBox.hxx"

#include"TopoDS_Solid.hxx"

void MakeBox(void)

{

Standard_Real dx=10.0;

Standard_Real dy=20.0;

Standard_Real dz=30.0;

TopoDS_Solid theBox = BRepPrimAPI_MakeBox(dx,dy,dz);

}

NOTE: Instead of quote marks I use the greater than and equal to signs around the include files ... but this mail poster thingy interprets the greater than or equal to signs in the post as HTML formats so I couldn't include them.

I then try to compile this code as follows (on an SGI machine running Red Hat Linux 6.2) and I get a parse error message. Any clues as to what I am doing wrong?

[croberts@cruncher ~/sample]$ g++ -I $CASROOT/inc MakeBox.C -lTKPrim -lTKBRep /home/croberts/Cascade/CAS3.1/inc/Standard_Integer.hxx: In function `Standard_Integer IntegerSize()': In file included from /home/croberts/Cascade/CAS3.1/inc/Standard_Address.hxx:20,

from /home/croberts/Cascade/CAS3.1/inc/Standard.hxx:19,

from /home/croberts/Cascade/CAS3.1/inc/Handle_TopoDS_TShape.hxx:23,

from /home/croberts/Cascade/CAS3.1/inc/TopoDS_Builder.hxx:19,

from /home/croberts/Cascade/CAS3.1/inc/TopoDS_Builder3D.hxx:19,

from /home/croberts/Cascade/CAS3.1/inc/BRep_Builder.hxx:19,

from /home/croberts/Cascade/CAS3.1/inc/BRepPrim_Builder.hxx:19,

from /home/croberts/Cascade/CAS3.1/inc/BRepPrim_GWedge.hxx:19,

from /home/croberts/Cascade/CAS3.1/inc/BRepPrim_Wedge.hxx:19,

from /home/croberts/Cascade/CAS3.1/inc/BRepPrimAPI_MakeBox.hxx:19,

from MakeBox.C:1: /home/croberts/Cascade/CAS3.1/inc/Standard_Integer.hxx:141: parse error before `)' /home/croberts/Cascade/CAS3.1/inc/Standard_Real.hxx: In function `Standard_Integer RealSize()': In file included from /home/croberts/Cascade/CAS3.1/inc/Standard_PrimitiveTypes.hxx:23,

from /home/croberts/Cascade/CAS3.1/inc/Handle_Standard_Transient.hxx:10,

from /home/croberts/Cascade/CAS3.1/inc/Handle_MMgt_TShared.hxx:27,

from /home/croberts/Cascade/CAS3.1/inc/Handle_TopoDS_TShape.hxx:27,

from /home/croberts/Cascade/CAS3.1/inc/TopoDS_Builder.hxx:19,

from /home/croberts/Cascade/CAS3.1/inc/TopoDS_Builder3D.hxx:19,

from /home/croberts/Cascade/CAS3.1/inc/BRep_Builder.hxx:19,

from /home/croberts/Cascade/CAS3.1/inc/BRepPrim_Builder.hxx:19,

from /home/croberts/Cascade/CAS3.1/inc/BRepPrim_GWedge.hxx:19,

from /home/croberts/Cascade/CAS3.1/inc/BRepPrim_Wedge.hxx:19,

from /home/croberts/Cascade/CAS3.1/inc/BRepPrimAPI_MakeBox.hxx:19,

from MakeBox.C:1: /home/croberts/Cascade/CAS3.1/inc/Standard_Real.hxx:156: parse error before `)'

SYSTEM INFO:

Linux cruncher.nas.nasa.gov 2.2.14-5.0 #1 Tue Mar 7 21:07:39 EST 2000 i686 unknown

Main memory size: 768 Mbytes

1 GenuineIntel Pentium III (Coppermine) processor

g++: ELF 32-bit LSB executable, Intel 80386, version 1, dynamically linked (uses shared libs), stripped

Francois Lauzon's picture

Hello Cathy, you should set the right option when compiling your application, to know which they are, you could have a look under your OpenCascade installation, to see which options where used to compile OpenCascade itself under a specific platform, for example: /CAS3.1/adm/Linux

I've look here, and your compilation line should look like this:

g++ -fPIC -DLIN -DLININTEL -DCSFDB -DNO_CXX_EXCEPTION -funsigned-char -Wall -DNDEBUG -DNo_Exception -I $CASROOT/inc MakeBox.C -lTKPrim -lTKBRep

I don't you if there are samples under Linux like there are under NT, but that could be a good starting point also.

Good Luck, Francois.