Author Topic: Problem with linking (link.exe)  (Read 10789 times)

Offline AttonRand

  • Jr. Member
  • *
  • Posts: 2
Problem with linking (link.exe)
« on: January 28, 2012, 04:21:30 PM »
Hello guys!
I know i should write to M$ for this but i hope to get better support from you.

I am trying to set a learning environment with nasm in Windows. I use Notepad++ and Nppexec to speed up the compiling process. The problem is that everytime i try to compile any obj file i get:

Code: [Select]
fatal error LNK1107: invalid or corrupt file: cannot read at 0x225
different sources, same error.
I downloaded link.exe from WindowsDDK.
Commands that i use to compile and link are:
Code: [Select]
C:\NASM\nasm.exe -i C:\NASM\library\ -f obj C:\SOURCE\app.asm
C:\NASM\link.exe C:\SOURCE\app.obj C:\NASM\library\IO.OBJ /OUT:C:\SOURCE\app.exe

If anybody has some experience with this please tell me!
Thank you in advance.

EDIT: a source example that gives me problem can be found here hxxp://www.mediafire.com/?bcs5oyjqcel1kbm
« Last Edit: January 28, 2012, 05:02:05 PM by AttonRand »

Offline Frank Kotler

  • NASM Developer
  • Hero Member
  • *****
  • Posts: 2667
  • Country: us
Re: Problem with linking (link.exe)
« Reply #1 on: January 28, 2012, 06:02:19 PM »
There's an article that references that error number, which may or may not be relevant...

http://stackoverflow.com/questions/6346581/strange-vc-linker-error-lnk1107-that-references-link-exe

Nevermind. I just read your edit, and looked at the code. It is 16-bit code, and the linker you've got (I think) won't do 16-bit code. You'd think the error message might be more informative...

For 16-bit code, you need a 16-bit linker. MS's is available here:

ftp://ftp.microsoft.com/Softlib/MSLFILES/LNK563.EXE

Or... you could use Alink (which will do both 16- and 32-bit code):

http://alink.sourceforge.net/

I think that'll solve your problem.

Answer a question for me, if you would: what's "Nppexec"? I don't think I've ever heard of that one.

Best,
Frank


Offline AttonRand

  • Jr. Member
  • *
  • Posts: 2
Re: Problem with linking (link.exe)
« Reply #2 on: January 28, 2012, 07:03:47 PM »
You are right! Thank you i thought that newer link.exe can support 16bit aswell but i was wrong.

As for nppexec, it's a plugin for notepad++ to do some automatic tasks for the command line.
Say you have to type everytime:

Code: [Select]
C:\NASM\nasm.exe -i C:\NASM\library\ -f obj C:\SOURCE\app.asm
C:\NASM\link.exe C:\SOURCE\app.obj C:\NASM\library\IO.OBJ /OUT:C:\SOURCE\app.exe

now you can create some scripts that will do the same for every nasm source (you can compile from notepad++ by pressing f6):

Code: [Select]
NPP_SAVE
C:\NASM\nasm.exe -i C:\NASM\library\ -f obj $(FULL_CURRENT_PATH)
C:\NASM\link.exe $(CURRENT_DIRECTORY)\$(NAME_PART).obj C:\NASM\library\IO.OBJ /OUT:$(CURRENT_DIRECTORY)\$(NAME_PART).exe

you can find more in the help file that comes with the install. just grab notepad++ and use the plugin manager to download it.

Thank you for your fast reply.

Offline Frank Kotler

  • NASM Developer
  • Hero Member
  • *****
  • Posts: 2667
  • Country: us
Re: Problem with linking (link.exe)
« Reply #3 on: January 28, 2012, 08:01:50 PM »
Ah! Thank you for your fast reply, too. Nppexec sounds pretty cool. I've been running Linux for some time now, so have to use "other methods" to do similar things. That's a good one to know, for the Windows folk!

Best,
Frank