OCC+ QT+VS 环境配置
在VS中创建QtWidget项目
将env.bat和msvc.bat拷贝到与项目名.sln同级目录下
修改msvc.bat
@echo off Setlocal EnableDelayedExpansion rem Setup environment rem 配置相应参数,%3默认是release 可手动修改为debug call "%~dp0env.bat" vc141 win64 %3 rem Define path to project filerem 修改项目名称set "PRJFILE=QtWidgetsApplication1.sln" rem Launch Visual Studio - either professional (devenv) or Express, as availableif exist "%DevEnvDir%\devenv.exe" ( start "" "%DevEnvDir%\devenv.exe" "%PRJFILE%") else if exist "%DevEnvDir%\%VisualStudioExpressName%.exe" ( start "" "%DevEnvDir%\%VisualStudioExpressName%.exe" "%PRJFILE%") else ( echo Error: Could not find MS Visual Studio ^(%VCFMT%^) echo Check relevant environment variable ^(e.g. VS100COMNTOOLS for vc10^))
修改env.bat
rem 定义变量,指向occ安装路径 SET "OCC_PATH=F:\OpenCASCADE-7.4.0-vc14-64\opencascade-7.4.0" rem 使用变量 call "%OCC_PATH%\env.bat" %1 %2 %3 set "BIN_DIR=win%ARCH%\%VCVER%\bind"set "LIB_DIR=win%ARCH%\%VCVER%\libd"if ["%CASDEB%"] == [""] ( set "BIN_DIR=win%ARCH%\%VCVER%\bin" set "LIB_DIR=win%ARCH%\%VCVER%\lib")set "PATH=%~dp0%LIB_DIR%;%~dp0%BIN_DIR%;%PATH%"
这一步可能会失败,失败的话将echo %OCC_PATH%\env.bat
加到call下面,结尾用pause
确认是否成功:项目属性>c/c++>附加包含目录>宏 里面有大量以CSF为前缀的宏,这些宏其实对应的就是各种OCC的路径,之后直接引用宏即可,不必再去写路径
添加属性表。设置属性表的属性
附加包含目录:
$(CSF_OCCTIncludePath)
附加库目录:
$(CSF_OCCTLibPath)
附加依赖项:将路径opencascade-7.4.0\win64\vc14\lib下的lib文件全部加入
OCC+QT Create环境配置
使用qt创建一个工程
QT Create也有类似于VS属性表的一个文件***.pri,创建一个该文件,并设置OCC路径,并引用下面的LIB库
#OCC路径设置OCCPath = F:\OpenCASCADE-7.4.0-vc14-64\opencascade-7.4.0 OCCIncludePath = $$OCCPath/inc win32:CONFIG(release,debug|release):OCCLibPath = $$OCCPath\win64\vc14\lib else:CONFIG(debug,debug|release):OCCLibPath = $$OCCPath\win64\vc14\libd INCLUDEPATH += $$OCCIncludePath win32:LIBS+= -L$$OCCLibPath -lTKBin win32:LIBS+= -L$$OCCLibPath -lTKBinL win32:LIBS+= -L$$OCCLibPath -lTKBinTObj win32:LIBS+= -L$$OCCLibPath -lTKBinXCAF win32:LIBS+= -L$$OCCLibPath -lTKBO win32:LIBS+= -L$$OCCLibPath -lTKBool win32:LIBS+= -L$$OCCLibPath -lTKBRep win32:LIBS+= -L$$OCCLibPath -lTKCAF win32:LIBS+= -L$$OCCLibPath -lTKCDF win32:LIBS+= -L$$OCCLibPath -lTKD3DHost win32:LIBS+= -L$$OCCLibPath -lTKDCAF win32:LIBS+= -L$$OCCLibPath -lTKDFBrowser win32:LIBS+= -L$$OCCLibPath -lTKDraw win32:LIBS+= -L$$OCCLibPath -lTKernel win32:LIBS+= -L$$OCCLibPath -lTKFeat win32:LIBS+= -L$$OCCLibPath -lTKFillet win32:LIBS+= -L$$OCCLibPath -lTKG2d win32:LIBS+= -L$$OCCLibPath -lTKG3d win32:LIBS+= -L$$OCCLibPath -lTKGeomAlgo win32:LIBS+= -L$$OCCLibPath -lTKGeomBase win32:LIBS+= -L$$OCCLibPath -lTKHLR win32:LIBS+= -L$$OCCLibPath -lTKIGES win32:LIBS+= -L$$OCCLibPath -lTKIVtk win32:LIBS+= -L$$OCCLibPath -lTKIVtkDraw win32:LIBS+= -L$$OCCLibPath -lTKLCAF win32:LIBS+= -L$$OCCLibPath -lTKMath win32:LIBS+= -L$$OCCLibPath -lTKMesh win32:LIBS+= -L$$OCCLibPath -lTKMeshVS win32:LIBS+= -L$$OCCLibPath -lTKOffset win32:LIBS+= -L$$OCCLibPath -lTKOpenGl win32:LIBS+= -L$$OCCLibPath -lTKPrim win32:LIBS+= -L$$OCCLibPath -lTKQADraw win32:LIBS+= -L$$OCCLibPath -lTKRWMesh win32:LIBS+= -L$$OCCLibPath -lTKService win32:LIBS+= -L$$OCCLibPath -lTKShapeView win32:LIBS+= -L$$OCCLibPath -lTKShHealing win32:LIBS+= -L$$OCCLibPath -lTKStd win32:LIBS+= -L$$OCCLibPath -lTKStdL win32:LIBS+= -L$$OCCLibPath -lTKSTEP win32:LIBS+= -L$$OCCLibPath -lTKSTEP209 win32:LIBS+= -L$$OCCLibPath -lTKSTEPAttr win32:LIBS+= -L$$OCCLibPath -lTKSTEPBase win32:LIBS+= -L$$OCCLibPath -lTKSTL win32:LIBS+= -L$$OCCLibPath -lTKTInspector win32:LIBS+= -L$$OCCLibPath -lTKTInspectorAPI win32:LIBS+= -L$$OCCLibPath -lTKTObj win32:LIBS+= -L$$OCCLibPath -lTKTObjDRAW win32:LIBS+= -L$$OCCLibPath -lTKToolsDraw win32:LIBS+= -L$$OCCLibPath -lTKTopAlgo win32:LIBS+= -L$$OCCLibPath -lTKTopTest win32:LIBS+= -L$$OCCLibPath -lTKTreeModel win32:LIBS+= -L$$OCCLibPath -lTKV3d win32:LIBS+= -L$$OCCLibPath -lTKVCAF win32:LIBS+= -L$$OCCLibPath -lTKView win32:LIBS+= -L$$OCCLibPath -lTKViewerTest win32:LIBS+= -L$$OCCLibPath -lTKVInspector win32:LIBS+= -L$$OCCLibPath -lTKVRML win32:LIBS+= -L$$OCCLibPath -lTKXCAF win32:LIBS+= -L$$OCCLibPath -lTKXDEDRAW win32:LIBS+= -L$$OCCLibPath -lTKXDEIGES win32:LIBS+= -L$$OCCLibPath -lTKXDESTEP win32:LIBS+= -L$$OCCLibPath -lTKXMesh win32:LIBS+= -L$$OCCLibPath -lTKXml win32:LIBS+= -L$$OCCLibPath -lTKXmlL win32:LIBS+= -L$$OCCLibPath -lTKXmlTObj win32:LIBS+= -L$$OCCLibPath -lTKXmlXCAF win32:LIBS+= -L$$OCCLibPath -lTKXSBase win32:LIBS+= -L$$OCCLibPath -lTKXSDRAW
在*.pro文件中增加
RESOURCES += *.pri
将env.bat拷贝到与项目名.sln同级目录下,env.bat设置与上一章节VS+Qt设置相同
新建qt.bat
@echo off Setlocal EnableDelayedExpansion rem Setup environment rem 配置相应参数,%3默认是release 可手动修改为debug call "%~dp0env.bat" vc141 win64 %3 rem 修改项目名称 call "%~dp0ProjectName.pro"