windows下使用的lazarus/fpc安裝到中文目錄時出錯的問題由以下3個不支持中文引起的:
1、make.exe
我使用mingw64帶的make.exe替換不支持中文的make.exe
2、fpc編譯器
修復讀取fpc.cfg時不支持utf8格式,打開fpcsrc/compiler/options.pas,找到procedure TOption.Interpret_file(const filename: TPathStr);(fpc 3.3.1)
在1744行(不同版本fpc行數可能不一樣)增加紅色代碼
while not eof(f) do begin readln(f,opts); {$ifdef windows}opts:=Utf8ToAnsi(opts);{$endif} inc(line); RemoveSep(opts); if (opts<>'') and (opts[1]<>';') then begin
3、lazarus
由于lazarus\components\codetools\definetemplates.pas 的ProcessOutputLine處理中文時有問題引起的
lazarus未修復前會FPC編譯器選項會提示fpc.cfg丟失:

1)在usrs增加LConvEncoding單元
2)按紅色代碼修改
procedure ProcessOutputLine(Line: string); var UpLine: string; function IsUpLine(p: integer; const s: string): boolean; begin Result:=StrLComp(@UpLine[p], PChar(s), length(s)) = 0; end; var SymbolName, SymbolValue, NewPath: string; i, len, CurPos: integer; Filename: String; p: SizeInt; begin Line:={$ifdef linux}SysToUtf8{$else}CP936ToUTF8{$endif}(Line); len := length(Line); if len <= 6 then Exit; // shortest match CurPos := 1; // skip timestamp e.g. [0.306] if Line[CurPos] = '[' then begin repeat
經修改后,已可能正常使用中文目錄編譯安裝lazarus/fpc。
已知存在問題:
由于fpc編譯器關鍵的代碼大量使用ansistring類型,很難完全支持中文目錄,fpc編譯路徑含有中文時編譯win程序沒問題,但交叉編譯linux程序時連接還是存在出錯,要繼續跟蹤fpc編譯器代碼,看能不能不能支持交叉編譯。

浙公網安備 33010602011771號