[英]Linking programs
我一直在嘗試使用Windows XP上運行的tasm編譯一個asm文件。
Tasm32版本-Turbo Turbo Assembler Version 5.0 Copyright (c) 1988, 1996 Borland International
Turbo Link Version 1.6.71.0 Copyright (c) 1993,1996 Borland International
通過將當前目錄設置為tasm\\bin
我可以執行以下操作:
TASM32 /m29A /ml filename.asm
這將生成普通的.Obj文件。 到現在為止還挺好。 然后我嘗試使用-鏈接
TLINK32 -Tpe -aa -x filename.obj,,,"kernel32.lib"
我正在使用kernel32.lib的適當路徑
但這會引發以下錯誤-
Fatal: Unable to open file 'filename.obj,,,C:\\Program Files\\Microsoft SDKs\\Windo ws\\v6.0A\\Lib\\Kernel32.lib'
我對asm知之甚少,谷歌一直在尋找解決方案,但似乎找不到。 似乎鏈接程序將所有內容都作為一個文件。
任何幫助將不勝感激,因為我完全在海上如何解決此問題。
謝謝。
我安裝了Borland C ++ Builder 5,其中包括tasm32和tlink32。 TASM32的命令行選項如下所示:
Turbo Assembler Version 5.3 Copyright (c) 1988, 2000 Inprise Corporation
Syntax: TASM [options] source [,object] [,listing] [,xref]
/a,/s Alphabetic or Source-code segment ordering
/c Generate cross-reference in listing
/dSYM[=VAL] Define symbol SYM = 0, or = value VAL
/e,/r Emulated or Real floating-point instructions
/h,/? Display this help screen
/iPATH Search PATH for include files
/jCMD Jam in an assembler directive CMD (eg. /jIDEAL)
/kh# Hash table capacity # symbols
/l,/la Generate listing: l=normal listing, la=expanded listing
/ml,/mx,/mu Case sensitivity on symbols: ml=all, mx=globals, mu=none
/mv# Set maximum valid length for symbols
/m# Allow # multiple passes to resolve forward references
/n Suppress symbol tables in listing
/os,/o,/op,/oi Object code: standard, standard w/overlays, Phar Lap, IBM
/p Check for code segment overrides in protected mode
/q Suppress OBJ records not needed for linking
/t Suppress messages if successful assembly
/uxxxx Set version emulation, version xxxx
/w0,/w1,/w2 Set warning level: w0=none, w1=w2=warnings on
/w-xxx,/w+xxx Disable (-) or enable (+) warning xxx
/x Include false conditionals in listing
/z Display source line with error message
/zi,/zd,/zn Debug info: zi=full, zd=line numbers only, zn=none
TLINK32的命令行選項如下所示:
Turbo Link Version 2.5.0.0 Copyright (c) 1993,1998 Borland International
Syntax: TLINK32 objfiles, exefile, mapfile, libfiles, deffile, resfiles
@xxxx indicates use response file xxxx
-m Map file with publics -x No map
-s Detailed segment map -L Specify library search paths
-M Map with mangled names -j Specify object search paths
-c Case sensitive link -v Full symbolic debug information
-Enn Max number of errors -n No default libraries
-P- Disable code packing -H:xxxx Specify app heap reserve size
-OS Do smart linking
-B:xxxx Specify image base addr -Hc:xxxx Specify app heap commit size
-wxxx Warning control -S:xxxx Specify app stack reserve size
-Txx Specify output file type -Sc:xxxx Specify app stack commit size
-Tpx PE image -Af:nnnn Specify file alignment
(x: e=EXE, d=DLL) -Ao:nnnn Specify object alignment
-ax Specify application type -o Import by ordinals
-ap Windowing Compatible -Vd.d Specify Windows version
-aa Uses Windowing API -r Verbose link
因此,您的鏈接器命令行
TLINK32 -Tpe -aa -x filename.obj,,,"kernel32.lib"
具有以下選項:-Tpe表示輸出文件類型為PE exe,-aa表示應用程序類型為“使用Windowing API”,-x表示無映射。 由於未指定-n選項,因此將包含默認的運行時庫。
然后有六個文件名列表。 列表用逗號分隔。 如果我沒記錯的話,文件名之間用空格隔開。
當前,您有objfiles = filename.obj,resfiles = kernel32.lib,其他四個文件名列表為空。 我認為您實際上是指kernel32.lib在libfiles列表中。 嘗試這個:
TLINK32 -Tpe -aa -x filename.obj, , , kernel32.lib, ,
如果創建一個makefile,則該項目將更易於構建和維護,因為它所要做的只是使連接器階段失敗的一個逗號。 您已經經歷了嘗試調試一個神秘的構建方案的挫敗感。
# makefile for Borland make
# *** not tested yet! no source code.
# Not compatible with nmake.
# May be compatible with gnu make.
#
# Borland Turbo Assembler
$(TASM32)=TASM32.exe
$(TASM32FLAGS)=/m29A /ml
#
# Borland Turbo Link
$(TLINK32)=TLINK32.exe
$(TLINK32FLAGS)=-Tpe -aa -x
#
# objfiles
$(OBJ)=filename.obj
#
# exefile
$(BIN)=filename.exe
#
# mapfile
$(MAP)=
#
# libfiles
$(LIBS)=kernel32.lib
#
# deffile
$(DEF)=
#
# resfiles
$(RES)=
all: all-before $(BIN) all-after
$(BIN): filename.asm
# Turbo Assembler Version 5.3 Copyright (c) 1988, 2000 Inprise Corporation
# Syntax: TASM [options] source [,object] [,listing] [,xref]
.asm.o:
$(TASM32) $(TASM32FLAGS) $<
# Turbo Link Version 2.5.0.0 Copyright (c) 1993,1998 Borland International
# Syntax: TLINK32 objfiles, exefile, mapfile, libfiles, deffile, resfiles
# Note the commas separate the lists of filenames, not the filenames themselves
$(BIN): $(OBJ)
$(TLINK32) $(TLINK32FLAGS) $(OBJ), $(BIN), $(MAP), $(LIBS), $(DEF), $(RES)
抱歉,這是我所能解決的最大問題,實際上我沒有什么可以測試的。 希望這足以使您的構建步入正軌。 祝好運!
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.