
Tue, 12/01/2015 - 20:12
I'm trying to read an IGES file with the following code:
#include <IGESControl_Controller.hxx>
#include <IGESControl_Reader.hxx>
#include <IFSelect_ReturnStatus.hxx>
#include <TopTools_HSequenceOfShape.hxx>
#include <TColStd_HSequenceOfTransient.hxx>
#include <TopoDS_Shape.hxx>
#include <Interface_Static.hxx>
....
Handle(TopTools_HSequenceOfShape) aSequence;
IGESControl_Controller::Init();
Interface_Static::SetIVal("read.surfacecurve.mode", -3);
IGESControl_Reader aReader;
IFSelect_ReturnStatus status = aReader.ReadFile( filePath.c_str() );
if(status == IFSelect_RetDone){
aSequence = new TopTools_HSequenceOfShape();
aReader.SetReadVisible(Standard_True);
aReader.TransferRoots();
TopoDS_Shape aShape = aReader.OneShape();
aSequence->Append( aShape );
}
....
Building with:
sudo g++ -o importer -I./gen-cpp -I/usr/local/include/thrift/ -I/usr/local/include/oce -lTKIGES -lTKXSBase -lTKBRep -lTKernel gen-cpp/Importer_Server.cpp gen-cpp/geometriesimporter_constants.cpp gen-cpp/Importer.cpp gen-cpp/geometriesimporter_types.cpp -lthrift
I get a whole lot off errors (In Spanish, sorry)
jesus@ubuntuthrift:/var/www/html/fileopen$ ./compile.sh
/tmp/ccjvBN6C.o: En la función `Standard_Transient::operator new(unsigned long)': Importer_Server.cpp:(.text._ZN18Standard_TransientnwEm[_ZN18Standard_TransientnwEm]+0x14): referencia a `Standard::Allocate(unsigned long)' sin definir
/tmp/ccjvBN6C.o: En la función `Standard_Transient::operator delete(void*)': Importer_Server.cpp:(.text._ZN18Standard_TransientdlEPv[_ZN18Standard_TransientdlEPv]+0x14): referencia a `Standard::Free(void*)' sin definir
/tmp/ccjvBN6C.o: En la función `Standard_Transient::Standard_Transient()': Importer_Server.cpp:(.text._ZN18Standard_TransientC2Ev[_ZN18Standard_TransientC5Ev]+0xf): referencia a `vtable for Standard_Transient' sin definir
/tmp/ccjvBN6C.o: En la función `Handle_Standard_Transient::~Handle_Standard_Transient()': Importer_Server.cpp:(.text._ZN25Handle_Standard_TransientD2Ev[_ZN25Handle_Standard_TransientD5Ev]+0x14): referencia a `Handle_Standard_Transient::EndScope()' sin definir
/tmp/ccjvBN6C.o: En la función `TColStd_SequenceOfTransient::~TColStd_SequenceOfTransient()': Importer_Server.cpp:(.text._ZN27TColStd_SequenceOfTransientD2Ev[_ZN27TColStd_SequenceOfTransientD5Ev]+0x14): referencia a `TColStd_SequenceOfTransient::Clear()' sin definir
/tmp/ccjvBN6C.o: En la función `TopTools_SequenceOfShape::~TopTools_SequenceOfShape()': Importer_Server.cpp:(.text._ZN24TopTools_SequenceOfShapeD2Ev[_ZN24TopTools_SequenceOfShapeD5Ev]+0x14): referencia a `TopTools_SequenceOfShape::Clear()' sin definir
/tmp/ccjvBN6C.o: En la función `TopTools_SequenceOfShape::TopTools_SequenceOfShape()': Importer_Server.cpp:(.text._ZN24TopTools_SequenceOfShapeC2Ev[_ZN24TopTools_SequenceOfShapeC5Ev]+0x14): referencia a `TCollection_BaseSequence::TCollection_BaseSequence()' sin definir
/tmp/ccjvBN6C.o: En la función `XSControl_Reader::operator delete(void*)': Importer_Server.cpp:(.text._ZN16XSControl_ReaderdlEPv[_ZN16XSControl_ReaderdlEPv]+0x14): referencia a `Standard::Free(void*)' sin definir
/tmp/ccjvBN6C.o: En la función `XSControl_Reader::~XSControl_Reader()': Importer_Server.cpp:(.text._ZN16XSControl_ReaderD2Ev[_ZN16XSControl_ReaderD5Ev]+0x14): referencia a `vtable for XSControl_Reader' sin definir
/tmp/ccjvBN6C.o: En la función `IGESControl_Reader::operator delete(void*)':
Importer_Server.cpp:(.text._ZN18IGESControl_ReaderdlEPv[_ZN18IGESControl_ReaderdlEPv]+0x14): referencia a `Standard::Free(void*)' sin definir
/tmp/ccjvBN6C.o: En la función `Handle_TopTools_HSequenceOfShape::operator=(TopTools_HSequenceOfShape const*)':
Importer_Server.cpp:(.text._ZN32Handle_TopTools_HSequenceOfShapeaSEPK25TopTools_HSequenceOfShape[_ZN32Handle_TopTools_HSequenceOfShapeaSEPK25TopTools_HSequenceOfShape]+0x1f): referencia a `Handle_Standard_Transient::Assign(Standard_Transient const*)' sin definir
/tmp/ccjvBN6C.o: En la función `MMgt_TShared::MMgt_TShared()': Importer_Server.cpp:(.text._ZN12MMgt_TSharedC2Ev[_ZN12MMgt_TSharedC5Ev]+0x1f): referencia a `vtable for MMgt_TShared' sin definir
/tmp/ccjvBN6C.o: En la función `MMgt_TShared::~MMgt_TShared()': Importer_Server.cpp:(.text._ZN12MMgt_TSharedD2Ev[_ZN12MMgt_TSharedD5Ev]+0x13): referencia a `vtable for MMgt_TShared' sin definir
Importer_Server.cpp:(.text._ZN12MMgt_TSharedD2Ev[_ZN12MMgt_TSharedD5Ev]+0x1f): referencia a `Standard_Transient::~Standard_Transient()' sin definir
/tmp/ccjvBN6C.o: En la función `TopTools_HSequenceOfShape::TopTools_HSequenceOfShape()': Importer_Server.cpp:(.text._ZN25TopTools_HSequenceOfShapeC2Ev[_ZN25TopTools_HSequenceOfShapeC5Ev]+0x20): referencia a `vtable for TopTools_HSequenceOfShape' sin definir
/tmp/ccjvBN6C.o: En la función `TopLoc_SListOfItemLocation::~TopLoc_SListOfItemLocation()': Importer_Server.cpp:(.text._ZN26TopLoc_SListOfItemLocationD2Ev[_ZN26TopLoc_SListOfItemLocationD5Ev]+0x15): referencia a `TopLoc_SListOfItemLocation::Clear()' sin definir
/tmp/ccjvBN6C.o: En la función `ImporterHandler::openFile(std::string const&)': Importer_Server.cpp:(.text._ZN15ImporterHandler8openFileERKSs[_ZN15ImporterHandler8openFileERKSs]+0xad): referencia a `IGESControl_Controller::Init()' sin definir
Importer_Server.cpp:(.text._ZN15ImporterHandler8openFileERKSs[_ZN15ImporterHandler8openFileERKSs]+0xbc): referencia a `Interface_Static::SetIVal(char const*, int)' sin definir
Importer_Server.cpp:(.text._ZN15ImporterHandler8openFileERKSs[_ZN15ImporterHandler8openFileERKSs]+0xcb): referencia a `IGESControl_Reader::IGESControl_Reader()' sin definir
Importer_Server.cpp:(.text._ZN15ImporterHandler8openFileERKSs[_ZN15ImporterHandler8openFileERKSs]+0xef): referencia a `XSControl_Reader::ReadFile(char const*)' sin definir
Importer_Server.cpp:(.text._ZN15ImporterHandler8openFileERKSs[_ZN15ImporterHandler8openFileERKSs]+0x14c): referencia a `XSControl_Reader::TransferRoots()' sin definir
Importer_Server.cpp:(.text._ZN15ImporterHandler8openFileERKSs[_ZN15ImporterHandler8openFileERKSs]+0x165): referencia a `XSControl_Reader::OneShape() const' sin definir
Importer_Server.cpp:(.text._ZN15ImporterHandler8openFileERKSs[_ZN15ImporterHandler8openFileERKSs]+0x186): referencia a `TopTools_HSequenceOfShape::Append(TopoDS_Shape const&)' sin definir
/tmp/ccjvBN6C.o: En la función `IGESControl_Reader::~IGESControl_Reader()': Importer_Server.cpp:(.text._ZN18IGESControl_ReaderD2Ev[_ZN18IGESControl_ReaderD5Ev]+0x13): referencia a `vtable for IGESControl_Reader' sin definir
collect2: error: ld returned 1 exit status
What am I MISSING?? Can you please help???
Wed, 12/02/2015 - 00:03
Hello Jesus,
I am not sure what the gen-cpp parts are doing in the command line, so I just focus on the first part of the command, maybe it helps.
I copied your code in a test.cpp and tried to compile with the first part of your command:
g++ -o importer -I/usr/include/oce -lTKIGES -lTKXSBase -lTKBRep -lTKernel test.cpp
This does not work, because the order of arguments is wrong.
If we try this, it still doesn't work:
g++ test.cpp -I/usr/include/oce -lTKIGES -lTKXSBase -lTKBRep -lTKernel -o importer
because we miss TKMath library from the list of libraries:
Finally, what should work:
g++ test.cpp -I/usr/include/oce -lTKIGES -lTKXSBase -lTKBRep -lTKernel -lTKMath -o importer
I hope this helps.
László
Wed, 12/02/2015 - 11:20
I appreciate your help László, but your change didn't make no difference... still the same errors
The gen-cpp part makes reference to a sub-directory where the files to compile are located.
The complete code is just an Apache Thrift example to try to create a C++ server that makes shape calculations for a PHP client. I didn't post the whole code because it might be outside the focus of OpenCascade and it works fine if I don't make use of OpenCascade functionality.
I'm aware that I'm completely new to OpenCascade and a PHP developer trying to code C++.... but I think I'm missing something related just to OpenCascade
Wed, 12/02/2015 - 12:15
Hello Jesus,
sorry to hear that it still doesn't work. Can you post the command that you now used for compiling, and also the error message?
László
Wed, 12/02/2015 - 12:29
Thank you László !! you made me think of the command and the order of the parameters again... and looks like I solved it with:
g++ gen-cpp/Importer_Server.cpp gen-cpp/geometriesimporter_constants.cpp gen-cpp/Importer.cpp gen-cpp/geometriesimporter_types.cpp -I./gen-cpp -I/usr/local/include/thrift/ -I/usr/local/include/oce -lTKBRep -lTKIGES -lTKXSBase -lTKernel -lTKMath -lthrift -o importer
Now, it would be great if you could help me translate this into a makefile.... I know this doesn't have to do with OpenCascade... but it surely would help me much
Anyway! Again! Thank you!
Wed, 12/02/2015 - 17:22
Hey Jesus,
glad to hear that it works. Usually I do not deal with makefiles directly, but use a makefile generator (CMAKE) instead. I would really suggest that you have a look in something like that, even if your project is small. I think it really pays off in the long run.
László
Wed, 12/02/2015 - 19:10
Thanks a lot. I'll give it try.
By the way... reading the IGES file throws a string to stdout: Total number of loaded entities : 3703.
Do you have any idea how to disable output to console??...
Sorry if I'm overloading you with stupid questions... just can't find proper documentation or examples
I figured out that this next line should do it, but it doesnt.
Message::DefaultMessenger()->AddPrinter(new Message_PrinterOStream("OCCSampleRun.log", Standard_False));
Thu, 12/03/2015 - 09:38
Try to add this in your code, before you perform reading the IGES file.
const Handle_Message_Messenger occMessenger = Message::DefaultMessenger();
occMessenger->RemovePrinters(STANDARD_TYPE(Message_PrinterOStream));
But remember that if you disable the "cout" messenger once in your application, it will remain disabled until you explicitly add it again. I guess this messenger system follows some kind of a singleton pattern, so the lifetime of it would be the lifetime of the application.
László
Thu, 12/03/2015 - 11:23
That did it.
Thank you! You rock Lázsló!