For all issues regarding the Forums use, please, refer to the Forum Rules.

Our Solutions

Need professional assistance?
Consider our:

Support Offerings

 

Need to speed up your development?
Have a look at our:

Samples & Tools

 

Need some functionality extending standard OCCT capabilities?
Check out our:

Adv. Components

Related pages

undefined reference

Jonas Greif's picture
Forums: 

Hello Guys, 

im new to OCC and its been quite a while ive programmed in C/C++. Im working on Windows with Code::Blocks.

Im planning to write a short routine which loads two step files, translates them into occ shapes, applies a boolean operation, and writes the translated result as a step file.

At the moment i receive some undefined reference errors like these :

'undefined reference to 'STEPControl_Reader::STEPControl_Reader()'

'undefined reference to 'XSControl_Reader::ReadFile(char const*)'

ect

Ive set the right directory for compiling, but i supect (as i read) that i have to explicitly link some librarys, but im not sure which or if its another error ive made

 My code looks like this so far :

#include <limits.h>

// Reader/Writer
#include <TopoDS_Shape.hxx>
#include <STEPControl_Reader.hxx>
#include <BRepTools.hxx>
//#include <STEPControl.hxx>
#include <STEPControl_Writer.hxx>
#include <BRep_Builder.hxx>

// Boolean
#include <BRepBuilderAPI_Command.hxx>
#include <BRepBuilderAPI_MakeShape.hxx>
#include <BRepAlgoAPI_Cut.hxx>

int main(int argc, char *argv[])
{
    // Read
    STEPControl_Reader reader1;
    reader1.ReadFile("shape_A.stp");
    reader1.TransferRoots();
    TopoDS_Shape shape_A = reader1.OneShape();

    STEPControl_Reader reader2;
    reader2.ReadFile("shape_B.stp");
    reader2.TransferRoots();
    TopoDS_Shape shape_B = reader2.OneShape();

    // Cut
    TopoDS_Shape shape_cut = BRepAlgoAPI_Cut(shape_A, shape_B);

    // Write

    STEPControl_Writer writer;
    IFSelect_ReturnStatus stat1 = writer.Transfer(shape_cut,STEPControl_ManifoldSolidBrep);
    IFSelect_ReturnStatus stat2 = writer.Write("shape_cut.stp");

}