編譯 CoppeliaSim 4.3.0 rev12

CoppeliaSim 採用 C++ 與 Qt 編寫, 安裝系統則利用 QSetup 建立. 這裡希望編譯的是 CoppeliaSim 原始碼中的 CoppeliaSimLib 第 4.3.0 rev12 版, 是由 448 個 .cpp 編譯連結而成 coppeliaSim.dll, 檔案大小約為 9538 KB, 是 CoppeliaSim 套件中最重要的核心程式庫 .

config.pri

CoppeliaSim 自 4.2.0 版之後, 所使用的 Lua 從 5.1 升級為 5.3, 配合設定的 config.pri 也必須修改如下:

# location of boost headers:
    BOOST_INCLUDEPATH = "Y:/msys64_20210419/mingw64/include/boost"

# location of lua headers:
    LUA_INCLUDEPATH = "Y:/lua-5.3.5/src" 

# lua libraries to link:
    LUA_LIBS = "y:/lua-5.3.5/src/liblua.a" 

# qscintilla location:
    QSCINTILLA_DIR = "y:/QScintilla_gpl-2.11.2"

# qscintilla headers:
    QSCINTILLA_INCLUDEPATH = "$${QSCINTILLA_DIR}/include" "$${QSCINTILLA_DIR}/Qt4Qt5"

# qscintilla libraries to link:
    QSCINTILLA_LIBS = "$${QSCINTILLA_DIR}/libqscintilla2_qt5.dll.a" 

# Make sure if a config.pri is found one level above, that it will be used instead of this one:
    exists(../config.pri) { include(../config.pri) }

由上列 config.pri 設定檔案可以得知, 編譯 CoppeliaSimLib 之前, 必須要先編譯 lua-5.3.5 與 QScintilla_gpl-2.11.2, 分別取得對應的程式庫之後, 再編譯 CoppeliaSimLib.

編譯 Lua 5.3.5

Y:\lua-5.3.5>mingw32-make mingw

可以建立 y:/lua-5.3.5/src/liblua.a

編譯 QScintilla

Location: Y:\QScintilla_gpl-2.11.2

Compile:

cd Qt4Qt5

qmake -o Makefile qscintilla.pro

mingw32-make

to get libqscintilla2_qt5.dll.a under release directory

編譯 CoppeliaSimLib

config.pri 設定修改完成後, 執行 C:\acc_430_12\CoppeliaSimLib>qmake -o Makefile coppeliaSimLib.pro

接著執行 C:\acc_430_12\CoppeliaSimLib>mingw32-make -f Makefile.Release

編譯結束後, 可以在 Release 目錄中建立 coppeliaSim.dll, 這是 CoppeliaSim 的主要動態連結程式庫.

下載可攜編譯系統: compile_copsim_cd2022.7z (for @gm users only)

下載已經完成 CoppeliaSimLib 編譯的檔案: acc_430_12_compile_Lib.7z (for @gm users only) / 下載 acc_430_12_compile_Lib.7z for @nfu

下載啟動 coppeliasim.exe 所需的 dlls 檔案: dlls_for_coppeliasimlib_430_12.7z (for @gm users only) / 下載 dlls_for_coppeliasimlib_430_12.7z for @nfu

編譯 coppeliaSimClientApplication

coppeliaSimClientApplication 是呼叫 CoppeliaSimLib 動態連結程式庫的客戶端應用程式. 編譯時必須位於 programming 目錄中:

C:\acc_430_12\programming>git clone --recurse-submodules https://github.com/CoppeliaRobotics/coppeliaSimClientApplication.git
Cloning into 'coppeliaSimClientApplication'...
remote: Enumerating objects: 170, done.
remote: Counting objects: 100% (6/6), done.
remote: Compressing objects: 100% (5/5), done.
Receiving objects:  86% (145/170)sed 4 (delta 1), pack-reused 164eceiving objects:  82% (140/1
Receiving objects: 100% (170/170), 32.92 KiB | 2.99 MiB/s, done.
Resolving deltas: 100% (100/100), done.

C:\acc_430_12\programming>cd coppeliasimclientapplication

C:\acc_430_12\programming\coppeliaSimClientApplication>git checkout coppeliasim-v4.3.0-rev12
Note: switching to 'coppeliasim-v4.3.0-rev12'.

You are in 'detached HEAD' state. You can look around, make experimental
changes and commit them, and you can discard any commits you make in this
state without impacting any branches by switching back to a branch.

If you want to create a new branch to retain commits you create, you may
do so (now or later) by using -c with the switch command. Example:

  git switch -c 

Or undo this operation with:

  git switch -

Turn off this advice by setting config variable advice.detachedHead to false

HEAD is now at 306a6c1 updated copyright

C:\acc_430_12\programming\coppeliaSimClientApplication>

將 C:\acc_430_12\programming\coppeliaSimClientApplication\config.pri 修改為:

# lua libraries to link:
    LUA_LIBS = "y:/lua-5.3.5/src/liblua.a" 

# location of lua headers:
    LUA_INCLUDEPATH = "Y:/lua-5.3.5/src" 

exists(../config.pri) { include(../config.pri) }

而在建立 coppeliaSim.exe 之前, 需要再編輯 coppeliaSim_resource.rc 檔案, 下載 coppeliaSim.ico, 並且開啟 coppeliaSim.pro 中第 42 行 RC_ICONS += coppeliaSim.ico 設定, 以便將 coppeliaSim.ico 圖像編譯後放入 coppeliaSim.exe, coppeliaSim_resource.rc 設定內容如下:

#include 

IDI_ICON1   ICON    DISCARDABLE "C:/acc_430_12/programming/coppeliaSimClientApplication/coppeliaSim.ico"

VS_VERSION_INFO VERSIONINFO
    FILEVERSION 0,0,0,0
    PRODUCTVERSION 0,0,0,0
    FILEFLAGSMASK 0x3fL
#ifdef _DEBUG
    FILEFLAGS VS_FF_DEBUG
#else
    FILEFLAGS 0x0L
#endif
    FILEOS VOS__WINDOWS32
    FILETYPE VFT_DLL
    FILESUBTYPE 0x0L
    BEGIN
        BLOCK "StringFileInfo"
        BEGIN
            BLOCK "040904b0"
            BEGIN
                VALUE "CompanyName", "\0"
                VALUE "FileDescription", "\0"
                VALUE "FileVersion", "0.0.0.0\0"
                VALUE "LegalCopyright", "\0"
                VALUE "OriginalFilename", "coppeliaSim.exe\0"
                VALUE "ProductName", "coppeliaSim\0"
                VALUE "ProductVersion", "0.0.0.0\0"
            END
        END
        BLOCK "VarFileInfo"
        BEGIN
            VALUE "Translation", 0x0409, 1200
        END
    END
/* End of Version info */

接下來就可以利用 qmake 建立 Makefile.Release, 並利用 mingw32-make 建立 coppeliaSim.exe

C:\acc_430_12\programming\coppeliaSimClientApplication>qmake -o Makefile coppeliaSim.pro

C:\acc_430_12\programming\coppeliaSimClientApplication>mingw32-make -f Makefile.Release

可以在 release 目錄中取得 coppeliaSim.exe

編譯 simExtDynamics

C:\acc_430_12\programming\simExtDynamics\build>cmake .. -G "MinGW Makefiles" -DCMAKE_BUILD_TYPE=Release

再執行:

Y:\tmp\cop410\programming\simExtUI\build>mingw32-make