So I am following the book "Guide to assembly language. A concise introduction." By James T. Streib. And I am trying to run the following program in Visual Studio 2019:
includelib msvcrt.lib
includelib legacy_stdio_definitions.lib
.686
.model flat, c
.stack 100h
printf PROTO arg1:Ptr Byte
.data
msg1 byte "Hello World!",0Ah,0
.code
main proc
INVOKE printf, ADDR msg1
ret
main endp
end
The book recommends to add the libraries at the top to the linker->Input->Additional dependencies, But at the moment of trilling to assembly the code the following error still shows up: LINK : fatal error LNK1104: cannot open file 'legacy_stdio_definitions.'
Does anyone know what the problem is? Is the code presented in the book valid? Is there any way to make the program to work the way it is written? Thanks a lot.
CodePudding user response:
Solution 1
legacy_stdio_definitions.lib is not added yet to your project, Follow this step to resolve the error.
- Open the project in Visual Studio
- click Project at the top menu bar
- Click Properties > Linker > Input In Additional Dependencies click the down arrow beside and click "Edit".
Add "legacy_stdio_definitions.lib" and click "OK", then "OK".
Solution 2
Note:
If legacy_stdio_definitions.lib does not resolve the symbols then Microsoft suggests wrapping the static library in a DLL.
Therefore., You need to build the wrapper DLL with the same version of Visual Studio that was used to create the static library (libpost.lib) that you are wrapping. So use VS2010 to create the DLL and its import library.
In the VS2019 project remove all references to the static library and its headers. Use the import library for the DLL and its exported wrapper functions.
In Addition
Building the DLL with VS2010 should take care of any linking problems with libpost.lib
At a minimum, your DLL should export wrappers for what your VS2019 project needs to function. I assume that if you try to build the VS2019 project but omit providing libpost.lib to the linker the resultant error messages about unresolved symbols should serve as a guide to what needs to be exported by the wrapper DLL. I also assume that you have a header file that contains function prototypes (and maybe other relevant info) for libpost.lib.
Wrapping and exporting additional functions and variables may make sense if you will update other old projects that linked with libpost.lib.
Make sure to heed the MS guidance about not leaking CRT details from VS2010 across the DLL boundary for anything exported by your wrappers.