Version: Harbour 3.2.0dev (r2004201301)
Compiler: MinGW GNU C 8.2 (32-bit)
Platform: Windows 10 10.0
PCode version: 0.3
Fivewin version: 20.xx
Harbour 我沒有更新到最新版本,但是這版也是 2020.04 的,更最新的沒有什麼差別了!
Fivewin 更新到 20.xx
MinGW 我下載 tdm-gcc 9.2.0, download from: https://jmeubank.github.io/tdm-gcc/ ,但是測試結果有問題,解決過程中問題太多後來放棄.
後來重新執行 tdm-gcc-9.2.0.exe 重新下載,但是版本降為 tdm 建議的穩定版本 8.2.0,可能是 9.2.0 是開發版,問題比較多,至於後來 8.2.0 測試成功後,我並沒有回頭再去測試 9.2.0,實在是懶了,花太多時間不必要!
gcc 9.2.0 have many problem, so I change to gcc 8.2.0 !!
好了,開始講重點:
先切入 mingw32 目錄執行: mingwvars.bat 作環境變數設定,然後切入 harbour 3.2 做編譯,為了避免之前不同版本的 C Compiler 殘留問題,先 clean 一下: # win-make clean
然後開始編譯 harbour 3.2!! #win-make
編譯這段前間可以去喝咖啡做其他事情了!..... 因為時間要很久!
再來將 fwh20.xx for MinGW 的 lib 'FiveHG.lib' 複製為: 'libFiveHG.a'、'FiveHGC.lib' 複製為: 'libFiveHGC.a'
1. run mingw32 environmental variables: #mingwvars.bat
2. build harbour 3.2: #win-make clean, #win-make.exe
3. copy fwh 20.xx library: 'FiveHG.lib' to 'libFiveHG.a' and 'FiveHGC.lib' to 'libFiveHGC.a'
編譯好 harbour 就準備開始測試 fwh 20.xx 的 samples, 但是,結果往往不如人意的...
![Laughing :lol:](./images/smilies/icon_lol.gif)
切入 fwh 20.xx 的 samples: cd \fwh20xx\samples, 使用 buildg.bat 編譯範例,例如: testdlg.prg, #buildg.bat testdlg
:
:
:
結果可想而知,錯誤訊息一堆,只好慢慢修改 buildg.bat 內容,我反覆測試之後,將 fwh、harbour、mingw 的 lib 分門別類管理,修改後的 buildg.bat 長這個樣字:
switch to fivewin directory and run batch about buildg.bat to compiler testdlg.prg.
but occur many error message and let's to modify buildg.bat:
代碼: 選擇全部
rem @ECHO OFF
CLS
if A%1 == A GOTO :SINTAX
if NOT EXIST %1.prg GOTO :NOEXIST
ECHO Compiling...
rem if "%fwdir%" == "" set fwh=.\..
set fwdir=d:\fwh2002
set hrbdir=d:\hb32mg32
set hrbexe=%hrbdir%\bin\harbour.exe
set hrblib=%hrbdir%\lib
set ccdir=d:\mingw32
set path=%ccdir%\bin
%hrbexe% %1 /n /i%fwdir%\include;%hrbdir%\include /w /p %2 %3 > comp.log 2> warnings.log
IF ERRORLEVEL 1 GOTO COMPILEERROR
@type comp.log
@type warnings.log
%ccdir%\bin\gcc -c %1.c -o%1.o -I%hrbdir%\include -I%ccdir%\include -Wall
IF ERRORLEVEL 1 GOTO COMPILEERROR
if exist %1.rc %ccdir%\bin\windres -D__FLAT__ -DDIALOG=DIALOGEX -i%1.rc -o_%1.o
IF ERRORLEVEL 1 GOTO RESOURCESERROR
set fwfiles=-lfivehg -lfivehgc -lmysql
rem bcc 有的 import32、urlmon, mingw 沒有
set w32files=-lmingw32 -lgdiplus -lshell32 -liphlpapi -lmsimg32 -lwininet -lws2_32 -lpsapi -lodbc32 -lwinmm -lmpr -lcomctl32 -lcomdlg32 -lole32 -loleaut32 -luuid -lgdi32 -luser32 -lkernel32 -lopengl32 -lwinspool -lversion -loledlg -lstdc++
rem -ladvapi32 -lodbccp32 -lwsock32 -lrasapi32 -lmfcuia32 -lwin32k -lvfw32 -lmapi32 -limm32 -lgmon
rem %ccdir%\lib\crt2.o %ccdir%\lib\dllcrt2.o %ccdir%\lib\gcrt2.o %ccdir%\lib\gcrt1.o
set hbfiles=-lhbmainwin -lgtgui -lgtwin -lhbpcre -lhbrtl -lhbvm -lhbcpage -lhblang -lhbmacro -lhbcommon -lhbpp -lhbwin -lhbtip -lhbrdd -lrddntx -lrddcdx -lrddfpt -lhbsix -lxhb -lhbcplr -lhbziparc -lhbzlib -lhbzebra -lhbmzip -lminizip -lpng -lhbct -lhbxpp
rem -lhbsqlit3 -lgtwvt -lgtwvg -lhbuddall -lhbextern -lhbdebug -lhbhpdf -lgtcgi -lgtpca -lhbnulrdd -lhbmisc -lhbusrrdd -lhbnf -llibhpdf -lhbnetio
set libs=%w32files% %hbfiles% %fwfiles%
rem if not exist %1.rc %ccdir%\bin\gcc -o%1.exe %1.o -Wall -s -mwindows -L%ccdir%\lib -L%hrblib% -L%fwdir%\lib -Wl,--enable-stdcall-fixup -Wl,--start-group -lfivehg -lfivehgc -lgtgui -luser32 -lshell32 -lwinspool -lkernel32 -lcomctl32 -lcomdlg32 -lgdi32 -lgdiplus -lole32 -loleaut32 -lpsapi -loledlg -lmfcuia32 -lmsimg32 -lwin32k -lstdc++ -lversion -luuid -lwinmm -lvfw32 -lwsock32 -lshell32 -lmpr -lhbcommon -lhbcpage -lhbcplr -lhbct -lhbdebug -lhbhsx -lhblang -lhbmacro -lhbmainstd -lhbmzip -lodbc32 -lhbpcre -lhbpp -lhbrdd -lhbrtl -lhbsix -lhbsqlit3 -lhbtip -lhbusrrdd -lhbvm -lhbwin -lhbzlib -lrddcdx -lrddfpt -lrddntx -lxhb -lhbziparc -lminizip -lhbmzip -lhbziparc -lpng -Wl,--end-group
rem -Wl,--allow-multiple-definition 允許重複定義函數功能
if not exist %1.rc %ccdir%\bin\gcc -o%1.exe %1.o -Wl,--allow-multiple-definition -Wall -s -mwindows -L%ccdir%\lib -L%hrblib% -L%fwdir%\lib -Wl,--enable-stdcall-fixup -Wl,--start-group %libs% -Wl,--end-group
@echo off
if exist %1.rc %ccdir%\bin\gcc -o%1.exe %1.o _%1.o -Wall -s -mwindows -L%ccdir%\lib -L%hrblib% -L%fwdir%\lib -Wl,--enable-stdcall-fixup -Wl,--start-group -lfivehg -lfivehgc -lgtgui -luser32 -lshell32 -lwinspool -lkernel32 -lcomctl32 -lcomdlg32 -lgdi32 -lgdiplus -lole32 -loleaut32 -lpsapi -lmsimg32 -lwin32k -loledlg -lstdc++ -lmfcuia32 -lversion -luuid -lwinmm -lvfw32 -lwsock32 -lshell32 -lmpr -lhbcommon -lhbcpage -lhbcplr -lhbct -lhbdebug -lhbhsx -lhblang -lhbmacro -lhbmainstd -lhbmzip -lodbc32 -lhbpcre -lhbpp -lhbrdd -lhbrtl -lhbsix -lhbsqlit3 -lhbtip -lhbusrrdd -lhbvm -lhbwin -lhbzlib -lrddcdx -lrddfpt -lrddntx -lxhb -lhbziparc -lminizip -lhbmzip -lhbziparc -lpng -Wl,--end-group
@echo on
IF ERRORLEVEL 1 GOTO LINKERROR
ECHO * Application successfully built
%1
rem delete temporary files
@del %1.c
@if exist %1.rc del _%1.o
GOTO EXIT
ECHO
:RESOURCESERROR
ECHO * Resources errors *
GOTO EXIT
:COMPILEERROR
@type comp.log
ECHO * Compile errors *
GOTO EXIT
:LINKERROR
ECHO * Link errors *
GOTO EXIT
:SINTAX
ECHO SYNTAX: Buildg [Program] {-- No especifiques la extensi占? PRG
ECHO {-- Don't specify .PRG extension
GOTO EXIT
:NOEXIST
ECHO The specified PRG %1 does not exist
:EXIT
請自行設定自己的編譯環境:
set fwdir=d:\fwh2002 <-- fivewin directory
set hrbdir=d:\hb32mg32 <-- harbour directory
set ccdir=d:\mingw32 <-- mingw32 directory
其他參數:
fwfiles: fivewin library
w32files: mingw32 library
hbfiles: harbour library
下面都有一排 rem 是其他 library, 用到時在複製上去用!!
不要以為這樣修改就能跑出 .exe ....
#buildg testdlg
你會發現還是有錯誤,在程式碼底端加入:
still occur error, Please open testdlg.prg and edit it!
代碼: 選擇全部
/* Missing MinGW GUIDs
add:WenSheng:2020.08.14:解決 MinGW 8.2.0 編譯、連結問題
*/
#pragma BEGINDUMP
#include "windows.h"
#ifdef __MINGW32__
// 解決: 'IRichEditOleCallback' 未定義問題
const CLSID IID_IRichEditOle = { 0x00020D00, 0x00, 0x00, { 0xC0, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x46 } };
const CLSID IID_IRichEditOleCallback = { 0x00020D03, 0x00, 0x00, { 0xC0, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x46 } };
// 解決: '_imp____acrt_iob_func' 未定義問題
FILE* __cdecl __acrt_iob_func(unsigned);
FILE* __cdecl __iob_func(unsigned i) {
return __acrt_iob_func(i);
}
const void* _imp____acrt_iob_func = __acrt_iob_func;
#endif
#pragma ENDDUMP
#buildg testxbr4
Yeah!! Run OK!!
這段程式碼自己包裝到你自己的工具程式碼裡面去,編譯連結應該就沒問題了,收工!
include the code to your source code and run,compiler is all right!!