我正在尝试编译开源项目程序员德沃夏克 http://www.kaufmann.no/roland/dvorak/。问题是它有点旧,并且不能使用当前版本的构建工具进行构建。
您可以在我的网站上查看完整的源代码以及我在线所做的修改项目的 Google 代码页 http://code.google.com/p/ergo-dvorak-for-developers/. 修订版2 http://code.google.com/p/ergo-dvorak-for-developers/source/browse/?r=2#svn/trunk是原始项目中未修改的源文件。修订版3 http://code.google.com/p/ergo-dvorak-for-developers/source/browse/?r=3#svn/trunk是我做出所有重大改变的地方。你可以看到一个两次修订之间的差异在这里 http://code.google.com/p/ergo-dvorak-for-developers/source/detail?r=3.
剩下的唯一明显的问题是一些 LINK 警告:
-
LNK4254 http://msdn.microsoft.com/en-us/library/ms235500(VS.80).aspx (e.g.
section '.edata' (40000040) merged into '.data' (C0000040) with different attributes.
) -- 我问了这个问题的独立版本here https://stackoverflow.com/questions/3383675/how-can-i-resolve-lnk4254-warnings-in-link-exe.
-
LNK4210 http://msdn.microsoft.com/en-us/library/708by912(VS.71).aspx (e.g.
.CRT section exists; there may be unhandled static initializers or terminators
)
如何修复这些警告? 我可以忽略它们吗?
尽管有这些警告,它仍然会生成一个 exe。但是,如果我继续运行它,它就无法正确安装,我需要诉诸系统还原才能再次安装官方版本。
这可能是因为警告或仅仅因为我没有正确修改项目。
我还需要做什么才能使该项目可安装?
构建过程(以及我的修改的解释):
它说你需要 Windows DDK,但似乎已经取代了它,所以我得到了它。我只安装了“构建环境”。
1.根据Readme.txt http://code.google.com/p/ergo-dvorak-for-developers/source/browse/trunk/README.txt,你应该运行:
build-layout && build-installer
2. build-layout.bat http://code.google.com/p/ergo-dvorak-for-developers/source/browse/trunk/build-layout.bat is run.
我必须修改这个文件():
-
WinDDK
path was modified since I have a newer version (MOD-1).
-
set PATH=
... %WINDDK%\bin\x86\x86;
was added since link.exe
is located there (MOD-2).
- In
set INCLUDE=
, %WINDDK%\inc\wxp
was changed to %WINDDK%\inc\api
, because the wxp
folder does not exist, and my best guess is that the api
folder was needed since it contains kbd.h
, which kbddvp.c http://code.google.com/p/ergo-dvorak-for-developers/source/browse/trunk/kbddvp.c uses (MOD-3).
- For
set LIB=
, %WINDDK%\lib\crt
was modified to %WINDDK%\lib\crt\i386
, so that libcmt.lib
could be found. See MOD-7 below. (MOD-4)
3. fkbddvp.mak http://code.google.com/p/ergo-dvorak-for-developers/source/browse/trunk/kbddvp.mak is run.
我必须修改这个文件():
- The path for the variable
CL32
was changed from $(WINDDK)\bin\x86\cl.exe
to $(WINDDK)\bin\x86\x86\cl.exe
, the first .exe doesn't exist, I believe this is the .exe I'm supposed to use instead. (MOD-5)
- The path for the variable
CL64
was changed from $(WINDDK)\bin\win64\x86\amd64\cl.exe
to $(WINDDK)\bin\x86\amd64\cl.exe
, this is my best guess as to where the missing .exe is. (MOD-6)
-
-opt:nowin98
removed to suppress warning LNK4224 http://msdn.microsoft.com/en-us/library/w7ys78k4.aspx (i.e. /OPT:NOWIN98 is no longer supported
), as suggested by Bobby https://stackoverflow.com/questions/3360746/how-can-i-compile-programmer-dvorak#comment-3552068. (MOD-10)
- Instead of using the non-existent
libc.lib
, I'm using libcmt.lib
. I read this post http://social.msdn.microsoft.com/forums/en-US/vcgeneral/thread/45a46d37-5e20-4e1a-87e7-9f9f65986f6a/ which recommends using this file instead. (MOD-7)
- Instead of using the obsolete utility
cabarc
, I'm using makecab
with makecab-dir.ddf http://code.google.com/p/ergo-dvorak-for-developers/source/browse/trunk/makecab-dir.ddf. I took my best guess https://stackoverflow.com/questions/3375908/how-do-i-convert-a-multi-file-cabarc-command-to-a-corresponding-makecab-command as to how to execute the same logic with this new utility. (MOD-8)
4. build-installer.bat http://code.google.com/p/ergo-dvorak-for-developers/source/browse/trunk/build-installer.bat is run.
我必须修改这个文件():
- This was also using
cabarc
and I modified it to use makcab
, similar to MOD-8, except that here it creates the .ddf file programmaticaly. (MOD-9)
完整的输出
如果您想查看的话,这是完整的输出:
>build-layout && build-installer
"C:\WinDDK\7600.16385.1\bin\x86\x86\cl.exe" -nologo -c -I..\inc -Zp8 -Gy
-W3 -WX -Gz -Gm- -EHs-c- -GR- -GF -Zl -Oxs -D_WIN32_WINNT=0x0501 -Fokbddvp32.o
bj kbddvp.c
kbddvp.c
rc kbddvp.rc
Microsoft (R) Windows (R) Resource Compiler Version 6.1.6908.0
Copyright (C) Microsoft Corporation. All rights reserved.
link -machine:ix86 -nologo -dll -base:0x5FFF0000 -subsystem:native -def:
kbddvp.def -noentry -merge:.edata=.data -merge:.rdata=.data -merge:.text=.data
-merge:.bss=.data -ignore:4078,4070 -section:.data,re -stack:0x40000,0x1000 -op
t:ref,icf -release -out:kbddvp32.dll kbddvp32.obj kbddvp.res
Creating library kbddvp32.lib and object kbddvp32.exp
LINK : warning LNK4254: section '.edata' (40000040) merged into '.data' (C000004
0) with different attributes
LINK : warning LNK4254: section '.rdata' (40000040) merged into '.data' (C000004
0) with different attributes
LINK : warning LNK4254: section '.text' (60000020) merged into '.data' (C0000040
) with different attributes
LINK : warning LNK4254: section '.bss' (C0000080) merged into '.data' (C0000040)
with different attributes
"C:\WinDDK\7600.16385.1\bin\x86\amd64\cl.exe" -nologo -c -I..\inc -Zp8 -
Gy -W3 -WX -Gz -Gm- -EHs-c- -GR- -GF -Zl -Oxs -DBUILD_WOW6432 -D_WIN32_WINNT=0x
0501 -Fokbddvp64.obj kbddvp.c
kbddvp.c
link -machine:amd64 -nologo -dll -base:0x5FFE0000 -subsystem:native -def
:kbddvp.def -noentry -merge:.edata=.data -merge:.rdata=.data -merge:.text=.data
-merge:.bss=.data -ignore:4078,4070 -section:.data,re -stack:0x40000,0x1000 -o
pt:ref,icf -release -out:kbddvp64.dll kbddvp64.obj kbddvp.res
Creating library kbddvp64.lib and object kbddvp64.exp
LINK : warning LNK4254: section '.edata' (40000040) merged into '.data' (C000004
0) with different attributes
LINK : warning LNK4254: section '.rdata' (40000040) merged into '.data' (C000004
0) with different attributes
LINK : warning LNK4254: section '.text' (60000020) merged into '.data' (C0000040
) with different attributes
LINK : warning LNK4254: section '.bss' (C0000080) merged into '.data' (C0000040)
with different attributes
"C:\WinDDK\7600.16385.1\bin\x86\x86\cl.exe" -nologo -c -Folauncher.obj l
auncher.c
launcher.c
link -machine:ix86 -nologo -subsystem:windows -release -nodefaultlib -ou
t:launcher.exe launcher.obj kernel32.lib libcmt.lib user32.lib shell32.lib
libcmt.lib(cpu_disp.obj) : warning LNK4210: .CRT section exists; there may be un
handled static initializers or terminators
makecab /F makecab-dir.ddf
Microsoft (R) Cabinet Maker - Version 5.1.2600.5512
Copyright (c) Microsoft Corporation. All rights reserved..
27,686 bytes in 4 files
Total files: 4
Bytes before: 27,686
Bytes after: 8,140
After/Before: 29.40% compression
Time: 0.19 seconds ( 0 hr 0 min 0.19 sec)
Throughput: 144.58 Kb/second
iexpress /N /Q /M kbddvp.sed
1 file(s) copied.
Microsoft (R) Cabinet Maker - Version 5.1.2600.5512
Copyright (c) Microsoft Corporation. All rights reserved..
60,290 bytes in 16 files
Total files: 16
Bytes before: 60,290
Bytes after: 16,876
After/Before: 27.99% compression
Time: 0.27 seconds ( 0 hr 0 min 0.27 sec)
Throughput: 221.34 Kb/second