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号