我正在尝试编译一个 OpenCascade 程序。
这是程序的链接: https://www.opencascade.com/content/unable-convert-step-file-stl-file (这是一个错误的程序,但它是一个开始)
我应该将所有库、库路径和包含路径链接到 gcc(-L、-l、-I 标志)。我已经安装了 OpenCascade,这里是安装的文件夹。
您看到的这些文件夹中的大多数都有一个 bin、include 和 lib 文件夹。
我是否必须将所有这些链接到编译器才能编译程序?
这些是程序使用的唯一包括:
#include "STEPControl_Reader.hxx"
#include <TopoDS_Shape.hxx>
#include <StlAPI_Writer.hxx>
编辑:“ TopoDS_Shape.hxx
”和“ StAPI_Writer.hxx
”位于此路径中C:\OpenCASCADE-7.4.0-vc14-64\opencascade-7.4.0\inc
。
' STEPControl_Reader.hxx
' 也存在于同一目录中,我不知道为什么原始作者将它放在他的本地目录中。
编辑 2:我也阅读了这个论坛主题: https ://forum.freecadweb.org/viewtopic.php?t=15993 但它对我一点帮助都没有。他使用的是linux,include和lib目录的结构不一样。
编译尝试后编辑:
我
win64\vc14\bin
把%PATH%
我弄清楚了这
-I
部分,因为所有三个头文件都在一个目录中。(C:\OpenCASCADE-7.4.0-vc14-64\opencascade-7.4.0\inc
)对于我使用的导入库的位置
C:\OpenCASCADE-7.4.0-vc14-64\opencascade-7.4.0\win64\vc14\lib
。我想我不需要重命名它 gcc\lib 对吗?我自己没有构建 OCCT,我从他们的网站下载了二进制文件。二进制文件的名称是opencascade-7.4.0-vc14-64
. 所以我想我没事吧?我正在使用 gcc。我从在线文档中找出了三个头文件的库名称。
STEPControl_Reader
使用TKSTEP
,TopoDS_Shape
使用TKBRep
,StlAPI_Writer
使用TKSTL
。
因此,我发出了这个命令:
gcc -I C:\OpenCASCADE-7.4.0-vc14-64\opencascade-7.4.0\inc -L C:\OpenCASCADE-7.4.0-vc14-64\opencascade-7.4.0\win64\vc14\lib -l TKSTEP -l TKBRep -l TKSTL testCode.c
这就是我得到的:
In file included from C:\OpenCASCADE-7.4.0-vc14-64\opencascade-7.4.0\inc/Standar
d_Integer.hxx:18,
from C:\OpenCASCADE-7.4.0-vc14-64\opencascade-7.4.0\inc/Standar
d_Address.hxx:18,
from C:\OpenCASCADE-7.4.0-vc14-64\opencascade-7.4.0\inc/Standar
d.hxx:21,
from C:\OpenCASCADE-7.4.0-vc14-64\opencascade-7.4.0\inc/STEPCon
trol_Reader.hxx:20,
from testCode.c:2:
C:\OpenCASCADE-7.4.0-vc14-64\opencascade-7.4.0\inc/Standard_Std.hxx:20:10: fatal
error: type_traits: No such file or directory
#include <type_traits>
^~~~~~~~~~~~~
compilation terminated.
编译实验 2:
C:\Users\User1\Desktop\OPENCAS>g++ -I C:\OpenCASCADE-7.4.0-vc14-64\opencascade-7
.4.0\inc -L C:\OpenCASCADE-7.4.0-vc14-64\opencascade-7.4.0\win64\vc14\lib -l TKS
TEP -l TKBRep -l TKSTL testCode.cpp
testCode.cpp: In function 'Standard_Integer main(int, char**)':
testCode.cpp:26:3: error: 'cout' was not declared in this scope
cout << argv[2] << endl;
^~~~
testCode.cpp:26:3: note: suggested alternative:
In file included from C:\OpenCASCADE-7.4.0-vc14-64\opencascade-7.4.0\inc/Standar
d_Stream.hxx:20,
from C:\OpenCASCADE-7.4.0-vc14-64\opencascade-7.4.0\inc/Standar
d_OStream.hxx:19,
from C:\OpenCASCADE-7.4.0-vc14-64\opencascade-7.4.0\inc/Standar
d_ExtCharacter.hxx:28,
from C:\OpenCASCADE-7.4.0-vc14-64\opencascade-7.4.0\inc/Standar
d_PrimitiveTypes.hxx:27,
from C:\OpenCASCADE-7.4.0-vc14-64\opencascade-7.4.0\inc/Standar
d_Transient.hxx:20,
from C:\OpenCASCADE-7.4.0-vc14-64\opencascade-7.4.0\inc/Standar
d.hxx:91,
from C:\OpenCASCADE-7.4.0-vc14-64\opencascade-7.4.0\inc/STEPCon
trol_Reader.hxx:20,
from testCode.cpp:2:
C:/Program Files/mingw-w64/x86_64-8.1.0-posix-seh-rt_v6-rev0/mingw64/lib/gcc/x86
_64-w64-mingw32/8.1.0/include/c++/iostream:61:18: note: 'std::cout'
extern ostream cout; /// Linked to standard output
^~~~
testCode.cpp:26:22: error: 'endl' was not declared in this scope
cout << argv[2] << endl;
^~~~
testCode.cpp:26:22: note: suggested alternative:
In file included from C:/Program Files/mingw-w64/x86_64-8.1.0-posix-seh-rt_v6-re
v0/mingw64/lib/gcc/x86_64-w64-mingw32/8.1.0/include/c++/iostream:39,
from C:\OpenCASCADE-7.4.0-vc14-64\opencascade-7.4.0\inc/Standar
d_Stream.hxx:20,
from C:\OpenCASCADE-7.4.0-vc14-64\opencascade-7.4.0\inc/Standar
d_OStream.hxx:19,
from C:\OpenCASCADE-7.4.0-vc14-64\opencascade-7.4.0\inc/Standar
d_ExtCharacter.hxx:28,
from C:\OpenCASCADE-7.4.0-vc14-64\opencascade-7.4.0\inc/Standar
d_PrimitiveTypes.hxx:27,
from C:\OpenCASCADE-7.4.0-vc14-64\opencascade-7.4.0\inc/Standar
d_Transient.hxx:20,
from C:\OpenCASCADE-7.4.0-vc14-64\opencascade-7.4.0\inc/Standar
d.hxx:91,
from C:\OpenCASCADE-7.4.0-vc14-64\opencascade-7.4.0\inc/STEPCon
trol_Reader.hxx:20,
from testCode.cpp:2:
C:/Program Files/mingw-w64/x86_64-8.1.0-posix-seh-rt_v6-rev0/mingw64/lib/gcc/x86
_64-w64-mingw32/8.1.0/include/c++/ostream:590:5: note: 'std::endl'
endl(basic_ostream<_CharT, _Traits>& __os)
编译实验 3(将 and 更改cout
为endl
andstd::cout
之后std::endl
)
C:\Users\User1\Desktop\OPENCAS>g++ -I C:\OpenCASCADE-7.4.0-vc14-64\opencascade-7
.4.0\inc -L C:\OpenCASCADE-7.4.0-vc14-64\opencascade-7.4.0\win64\vc14\lib -l TKS
TEP -l TKBRep -l TKSTL testCode.cpp
C:\Users\User1\AppData\Local\Temp\ccCCS9c3.o:testCode.cpp:(.text+0x27): undefine
d reference to `STEPControl_Reader::STEPControl_Reader()'
C:\Users\User1\AppData\Local\Temp\ccCCS9c3.o:testCode.cpp:(.text+0x3a): undefine
d reference to `XSControl_Reader::ReadFile(char const*)'
C:\Users\User1\AppData\Local\Temp\ccCCS9c3.o:testCode.cpp:(.text+0x49): undefine
d reference to `STEPControl_Reader::NbRootsForTransfer()'
C:\Users\User1\AppData\Local\Temp\ccCCS9c3.o:testCode.cpp:(.text+0x58): undefine
d reference to `XSControl_Reader::TransferRoots()'
C:\Users\User1\AppData\Local\Temp\ccCCS9c3.o:testCode.cpp:(.text+0x6b): undefine
d reference to `XSControl_Reader::OneShape() const'
C:\Users\User1\AppData\Local\Temp\ccCCS9c3.o:testCode.cpp:(.text+0x77): undefine
d reference to `StlAPI_Writer::StlAPI_Writer()'
C:\Users\User1\AppData\Local\Temp\ccCCS9c3.o:testCode.cpp:(.text+0xa0): undefine
d reference to `StlAPI_Writer::Write(TopoDS_Shape const&, char const*)'
C:\Users\User1\AppData\Local\Temp\ccCCS9c3.o:testCode.cpp:(.text$_ZN24NCollectio
n_BaseSequencedlEPv[_ZN24NCollection_BaseSequencedlEPv]+0x11): undefined referen
ce to `Standard::Free(void*)'
C:\Users\User1\AppData\Local\Temp\ccCCS9c3.o:testCode.cpp:(.text$_ZN11opencascad
e6handleI25NCollection_BaseAllocatorE8EndScopeEv[_ZN11opencascade6handleI25NColl
ection_BaseAllocatorE8EndScopeEv]+0x23): undefined reference to `Standard_Transi
ent::DecrementRefCounter() const'
C:\Users\User1\AppData\Local\Temp\ccCCS9c3.o:testCode.cpp:(.text$_ZN11opencascad
e6handleI30TopLoc_SListNodeOfItemLocationE8EndScopeEv[_ZN11opencascade6handleI30
TopLoc_SListNodeOfItemLocationE8EndScopeEv]+0x23): undefined reference to `Stand
ard_Transient::DecrementRefCounter() const'
C:\Users\User1\AppData\Local\Temp\ccCCS9c3.o:testCode.cpp:(.text$_ZN11opencascad
e6handleI13TopoDS_TShapeE8EndScopeEv[_ZN11opencascade6handleI13TopoDS_TShapeE8En
dScopeEv]+0x23): undefined reference to `Standard_Transient::DecrementRefCounter
() const'
C:\Users\User1\AppData\Local\Temp\ccCCS9c3.o:testCode.cpp:(.text$_ZN20NCollectio
n_SequenceIN11opencascade6handleI18Standard_TransientEEE5ClearERKNS1_I25NCollect
ion_BaseAllocatorEE[_ZN20NCollection_SequenceIN11opencascade6handleI18Standard_T
ransientEEE5ClearERKNS1_I25NCollection_BaseAllocatorEE]+0x1f): undefined referen
ce to `NCollection_BaseSequence::ClearSeq(void (*)(NCollection_SeqNode*, opencas
cade::handle<NCollection_BaseAllocator>&))'
C:\Users\User1\AppData\Local\Temp\ccCCS9c3.o:testCode.cpp:(.text$_ZN11opencascad
e6handleI21XSControl_WorkSessionE8EndScopeEv[_ZN11opencascade6handleI21XSControl
_WorkSessionE8EndScopeEv]+0x23): undefined reference to `Standard_Transient::Dec
rementRefCounter() const'
C:\Users\User1\AppData\Local\Temp\ccCCS9c3.o:testCode.cpp:(.text$_ZN20NCollectio
n_SequenceI12TopoDS_ShapeE5ClearERKN11opencascade6handleI25NCollection_BaseAlloc
atorEE[_ZN20NCollection_SequenceI12TopoDS_ShapeE5ClearERKN11opencascade6handleI2
5NCollection_BaseAllocatorEE]+0x1f): undefined reference to `NCollection_BaseSeq
uence::ClearSeq(void (*)(NCollection_SeqNode*, opencascade::handle<NCollection_B
aseAllocator>&))'
C:\Users\User1\AppData\Local\Temp\ccCCS9c3.o:testCode.cpp:(.text$_ZN11opencascad
e6handleI25NCollection_BaseAllocatorE10BeginScopeEv[_ZN11opencascade6handleI25NC
ollection_BaseAllocatorE10BeginScopeEv]+0x23): undefined reference to `Standard_
Transient::IncrementRefCounter() const'
C:\Users\User1\AppData\Local\Temp\ccCCS9c3.o:testCode.cpp:(.text$_ZN11opencascad
e6handleI18Standard_TransientE8EndScopeEv[_ZN11opencascade6handleI18Standard_Tra
nsientE8EndScopeEv]+0x23): undefined reference to `Standard_Transient::Decrement
RefCounter() const'
C:\Users\User1\AppData\Local\Temp\ccCCS9c3.o:testCode.cpp:(.rdata$.refptr._ZTV18
STEPControl_Reader[.refptr._ZTV18STEPControl_Reader]+0x0): undefined reference t
o `vtable for STEPControl_Reader'
C:\Users\User1\AppData\Local\Temp\ccCCS9c3.o:testCode.cpp:(.rdata$.refptr._ZTV16
XSControl_Reader[.refptr._ZTV16XSControl_Reader]+0x0): undefined reference to `v
table for XSControl_Reader'
collect2.exe: error: ld returned 1 exit status