Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/1010code/wine-mingw-linux-cpp
https://github.com/1010code/wine-mingw-linux-cpp
Last synced: 5 days ago
JSON representation
- Host: GitHub
- URL: https://github.com/1010code/wine-mingw-linux-cpp
- Owner: 1010code
- Created: 2024-09-09T11:38:27.000Z (5 months ago)
- Default Branch: main
- Last Pushed: 2024-10-31T05:40:39.000Z (4 months ago)
- Last Synced: 2024-10-31T06:23:22.115Z (4 months ago)
- Language: CMake
- Size: 1.95 KB
- Stars: 0
- Watchers: 1
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
# [教學] 在 Linux 下執行 MinGW 編譯的 C++ .exe 檔案
## 編譯
這是一份用C++撰寫的main主程式,此專案架構包刮Google單元測試。以下透過 Mingw toolchain 編譯,使得可以在Linux系統中編譯 Windows Mingw的執行檔。```sh
# 配置項目
cmake -S . -B build -DCMAKE_TOOLCHAIN_FILE=toolchain-mingw64.cmake
# 建構項目
cmake --build build
```編譯結果後會在該資料夾下產生`build`資料夾,兩份執行檔分別會在。
- build/bin/main.exe
- build/test/unit_test.exe## 如何在 Linux 下執行 MinGW 編譯的 C++ .exe 檔案
可以參考以下[文章](https://andy6804tw.github.io/2024/08/31/wine-mingw-linux-cpp/)在Linux系統下安裝wine模擬 Windows 環境來執行這些檔案。安裝成功後即可執行:
```sh
# 執行主程式
wine build/bin/main.exe```
執行結果:
```
hello world!
``````sh
# 執行單元測試
wine build/test/unit_test.exe
```執行結果:
```
[0;32m[==========] [mRunning 1 test from 1 test suite.
[0;32m[----------] [mGlobal test environment set-up.
[0;32m[----------] [m1 test from PublicSum
[0;32m[ RUN ] [mPublicSum.test1
[0;32m[ OK ] [mPublicSum.test1 (0 ms)
[0;32m[----------] [m1 test from PublicSum (9 ms total)[0;32m[----------] [mGlobal test environment tear-down
[0;32m[==========] [m1 test from 1 test suite ran. (39 ms total)
[0;32m[ PASSED ] [m1 test.
```