windows 10 环境下 occQt 编译

准备工作

1、下载 occQt ,地址:https://github.com/eryar/occQt

2、下载 opencascade 7.4.0 ,地址:https://dev.opencascade.org/release/previous#node-29988

3、下载 occ 依赖三方库:ffmpeg、freeimage、freetype、tcltk,地址:https://dev.opencascade.org/resources/download/3rd-party-components

4、下载 cmake ,安装之,地址:https://cmake.org/download

5、下载 Qt5.x ,安装之,地址:https://download.qt.io/official_releases/qt/5.12/5.12.12

6、下载 Virtual Studio 2017 ,安装之,地址:https://msdn.itellyou.cn

编译opencascade-7.4.0

1、在D盘根目录,新建如下目录结构:

2、参考官方文档编译之,地址:https://dev.opencascade.org/doc/overview/html/build_upgrade__building_occt.html

生成VS项目:

编译VS项目:

用VS打开 D:\occt-bin\OCCT.sln 文件,并生成解决方案

 3、使用 Qt Creator 打开occQt 项目,并修改 occQt.pro 文件:

  • 增加opengl依赖: QT += core gui opengl
  • 修改CASROOT变量为:CASROOT = D:/occt-bin
  • 将所有 $$(CASROOT) 项替换为 $$CASROOT
  • 增加 win32-msvc ,对应的 compiler 为 vc14

修改后的文件如下: 

#-------------------------------------------------
#
# Project created by QtCreator 2013-08-18T15:52:09
#
#-------------------------------------------------

QT       += core gui opengl

greaterThan(QT_MAJOR_VERSION, 4): QT += widgets

TARGET = occQt
TEMPLATE = app

SOURCES += main.cpp \
    occQt.cpp       \
    occView.cpp

CONFIG += c++11

HEADERS  += \
    occQt.h \
    occView.h

FORMS    += \
    occQt.ui

RESOURCES += \
    occqt.qrc

CASROOT = D:/occt-bin
    
win32 {
    DEFINES +=  \
        WNT
    INCLUDEPATH +=  \
        $$CASROOT/inc

    win32-msvc2010 {
        compiler=vc10
    }

    win32-msvc2012 {
        compiler=vc11
    }

    win32-msvc2013 {
        compiler=vc12
    }

    win32-msvc2015 {
        compiler=vc14
    }

    win32-msvc {
        compiler=vc14
    }

    # Determine 32 / 64 bit and debug / release build
    !contains(QMAKE_TARGET.arch, x86_64) {
        CONFIG(debug, debug|release) {
            message("Debug 32 build")
            LIBS += -L$$CASROOT/win32/$$compiler/libd
        }
        else {
            message("Release 32 build")
            LIBS += -L$$CASROOT/win32/$$compiler/lib
        }
    }
    else {
        CONFIG(debug, debug|release) {
            message("Debug 64 build")
            LIBS += -L$$CASROOT/win64/$$compiler/libd
        }
        else {
            message("Release 64 build")
            LIBS += -L$$CASROOT/win64/$$compiler/lib
        }
    }
}

linux-g++ {
    INCLUDEPATH +=  \
        $$CASROOT/include/opencascade

    LIBS +=         \
        -L$$CASROOT/lib
}

LIBS +=         \
    -lTKernel   \
    -lTKMath    \
    -lTKG3d     \
    -lTKBRep    \
    -lTKGeomBase\
    -lTKGeomAlgo\
    -lTKTopAlgo \
    -lTKPrim    \
    -lTKBO      \
    -lTKBool    \
    -lTKOffset  \
    -lTKService \
    -lTKV3d     \
    -lTKOpenGl  \
    -lTKFillet

执行构建即可。

4、添加依赖dll到环境变量:

C:\Program Files (x86)\Microsoft Visual Studio\2017\Community\VC\Tools\MSVC\14.16.27023\bin\Hostx64\x64
D:\3rdparty\freetype-2.5.5-vc14-64\bin
D:\occt-bin\win64\vc14\bind
C:\Qt\Qt5.12.12\5.12.12\msvc2017_64\bin

注意,调试代码时,需安装 Debugging Tools ,否则进程会 crash,安装过程如下:

 其他

posted @ 2022-09-26 12:10  david123102  阅读(766)  评论(0编辑  收藏  举报