OpenCascade and Linux

I tried to compile a small program under Linux. But it does not work. What am I doing wrong ???

Here is my code:

#include "iostream.h"

#include "Standard_Macro.hxx"

#include "gp_Vec.hxx"

#include "Geom_ToroidalSurface.hxx"

#include "gp_Pnt.hxx"

#include "gp_Ax3.hxx"

#include "gp_Dir.hxx"

int main () {

double resScalarProd;

gp_Vec vect1(4,-3,5);

gp_Vec vect2(3,-5,-7);

resScalarProd = (vect1*vect2);

Standard_Real mag = vect2.Magnitude();



// Okay up to here.

// This gives an error with the compiler. Why ???

Handle(Geom_ToroidalSurface) f ;

f = new Geom_ToroidalSurface (gp_Ax3(gp_Pnt(0,0,0),gp_Dir(0,0,1)),350,80);

return 0; }

To compile I use( Under Linux):

g++ Ex1.cpp -I /home/kunzi/CAS3.0/inc/ -L /home/kunzi/CAS3.0/Linux/lib/ -DLIN -DCSFDB

This is the begining of the error I get:

/tmp/cc5oWcZu.o(.text+0x106): undefined reference to `Geom_ToroidalSurface::oper ator new(unsigned int)' /tmp/cc5oWcZu.o(.text+0x172): undefined reference to `gp_Ax3::gp_Ax3(gp_Pnt cons t &, gp_Dir const &)'

Could someone help me with that?

Thanks in advance.

Simon Kunzi

Yan's picture

Indirect and incomplete answer:

I send you a compilation line used under Linux to compile a source with g++ : Such a file can be found in /home/kunzi/CAS3.0/adm/Linux/BndLib.comp if you have downloaded the source files distribution.

Below is a variable environment CASROOT you can set like this (in csh):

>setenv CASROOT /home/kunzi/CAS3.0/
>/usr/bin/g++ -fPIC -DLIN -DLININTEL -DCSFDB -DNO_CXX_EXCEPTION -funsigned-char -Wall -DCSFDB -O3 -DNDEBUG -DNo_Exception -I${CASROOT}/src/BndLib -I${CASROOT}/drv/BndLib -I${CASROOT}/inc -c ${CASROOT}/src/BndLib/BndLib_Compute2d.cxx -o BndLib_Compute2d.o

Note: Option -c to only compile and -o to name the output file. No option -L is required.

To link and create an executable file see:


This file is used to create the executable file runned when you start the demo shell in directory /home/kunzi/CAS3.0/src/DrawResources.

If the problem persists probably an include file is missing.

s-kunzi's picture

Thanks for the prompt answer !

TTOPOLOGY.lnk and TTOPOLOGY.comp are good examples to see what one can use to compile his code.

Here is what I did wrong:

You don't need set CASROOT, but you DO NEED to set LD_LIBRARY_PATH to ...CAS3.0/Linux/lib

When you run the program, it will look for the OpenCascade libraries (lib*.so) in LD_LIBRARY_PATH.

To compile the program, the minimum you need is:

g++ Ex1.cpp -I/home/kunzi/CAS3.0/inc/ -L/home/kunzi/CAS3.0/Linux/lib/ -lTKG3d -DLIN

Does anyone know what the -DCSFDB option for the compiler is for ? I know it defines CSFDB, but what does it stand for ? Is there anything about these compiler options in the doc ?

Simon Kunzi