
Thu, 10/10/2019 - 09:46
Hi there,
I have trouble linking an simple code to the build libraries. Here is the code:
--------- demo_simple_02.cpp ----------
#include
#include
int main()
{
gp_Pnt p1 = gp_Pnt(0,0,0);
gp_Dir d1 = gp_Dir(0,0,1);
return 0;
}
----------
I compile with:
g++ -I ~/ooc/install/include/opencascade/ -L ~/ooc/install/lib/ -lTKBin -lTKBinL -lTKBinTObj -lTKBinXCAF -lTKBO -lTKBool -lTKBRep -lTKCAF -lTKCDF -lTKDCAF -lTKDraw -lTKernel -lTKFeat -lTKFillet -lTKG2d -lTKG3d -lTKGeomAlgo -lTKGeomBase -lTKHLR -lTKIGES -lTKLCAF -lTKMath -lTKMesh -lTKMeshVS -lTKOffset -lTKOpenGl -lTKPrim -lTKQADraw -lTKRWMesh -lTKService -lTKShHealing -lTKStd -lTKStdL -lTKSTEP209 -lTKSTEP -lTKSTEPAttr -lTKSTEPBase -lTKSTL -lTKTObj -lTKTObjDRAW -lTKTopAlgo -lTKTopTest -lTKV3d -lTKVCAF -lTKViewerTest -lTKVRML -lTKXCAF -lTKXDEDRAW -lTKXDEIGES -lTKXDESTEP -lTKXMesh -lTKXml -lTKXmlL -lTKXmlTObj -lTKXmlXCAF -lTKXSBase -lTKXSDRAW demo_simple_02.cpp
and the first two errors I get are:
/tmp/ccldpw9f.o: In function `Standard_Transient::operator delete(void*)':
demo_simple_02.cpp:(.text._ZN18Standard_TransientdlEPv[_ZN18Standard_TransientdlEPv]+0x14): undefined reference to `Standard::Free(void*)'
/tmp/ccldpw9f.o: In function `Standard_DomainError::Standard_DomainError(Standard_DomainError const&)':
demo_simple_02.cpp:(.text._ZN20Standard_DomainErrorC2ERKS_[_ZN20Standard_DomainErrorC5ERKS_]+0x1f): undefined reference to `Standard_Failure::Standard_Failure(Standard_Failure const&)'
g++ (Ubuntu 7.4.0-1ubuntu1~18.04.1) 7.4.0, cmake version 3.10.2.
One thing to note is that when I comment out gp_Dir d1 = gp_Dir(0,0,1); then this compiles.
Here is how I set things up: I used cmake to build the library. I started with not changeing anything there except the installation path. This produces shared libraries I am somewhat confident that the build was successful as the draw program worked. I saw the same errors as above. The I build static libraries. There I used
nm -gC *.a | grep Standard_Transient::Free
Adding an LD_LIBRARY_PATH did not help.
What provides Standard_Transient::Free and how do I add it to the build? If you need more information, let me know. I must be missing something obvious but I can not see it. If any one could point me in the right direction, that would be great. Thanks.
Thu, 10/10/2019 - 10:16
You should learn how your building toolchain works, including compilation, library linkage and library loading steps - currently they are missed up in your message.
g++ documentation describe your mistake here (your -lTKernel appears before your cpp - well, at least this is what I assume is the issue):
https://gcc.gnu.org/onlinedocs/gcc/Link-Options.html#Link-Options
You can avoid some low-level problems by using CMake or another building tools instead of calling g++ directly.
Thu, 10/10/2019 - 10:31
Thank you.