News:

MASM32 SDK Description, downloads and other helpful links
MASM32.com New Forum Link
masmforum WebSite

creating .inc files

Started by Danesh, March 24, 2005, 03:09:14 AM

Previous topic - Next topic

Danesh

Hi,

I have tried to create a .inc with a very simple function just for test but I could not. The code is assembled with no error but when I include .inc file in my code and call the function I get this error:

error LNK2001: unresolved external symbol _MyProc@4

can anybody help ? I have attached the .inc and the source of the function which I have tried to call.

Thanks,

Danesh



[attachment deleted by admin]

hutch--

Danesh,

Usually you use an INC file for things like prototypes in libraries or in a DLL import library. What you need to make sure is the code that the prototype is for can be found by the linker, either in a library or in the exports from a DLL.

Let us know what you have tried to do and we may be able to help you.
Download site for MASM32      New MASM Forum
https://masm32.com          https://masm32.com/board/index.php

hitchhikr

Either you haven't included myinc.asm in the code or (if you want to use it externally as an object file) the myinc.obj in the parameters of the linker like this:

Link.exe /SUBSYSTEM:WINDOWS "myprogram.obj" "myinc.obj"

So that your function will be linked with the main program.

Danesh

Hutch,

In that case I was in a wrong way. I thought that the linker will be able to find a prototype in an .OBJ file too, so I had written my function and assembled it and the object file has been created successfully. After that I wanted to use my function by using its prototype in an .INC file but it seems it is impossible. So I have to create LIB or DLL file to be able call functions by including prototypes which are placed in an .INC file, right ?

Thanks,

Danesh


hutch--

Danesh,

Ususlly its easier to make a library as you can call it directly from the include and includelib statements. If you have a module you have to put it on the LINK command line.
Download site for MASM32      New MASM Forum
https://masm32.com          https://masm32.com/board/index.php

hitchhikr

a .lib is just a convenient pack of .objs

Vortex

Hi Danesh,

Just as hitchhikr said, a static library is a collection of object files making easy the linkage storage. You should use lib.exe or Pelle's polib.exe to create a static library of your functions.

Danesh

Thanks for the tips. I think the best way is to create a LIB or DLL to manage modules. By the way I amjust asking, what does LIB.exe do ? Does it convert a .obj file into .lib format or what ?

Thanks,

Danesh


hutch--

Library managers bundle one or more object modules into a single library so that you can if you wish group whole collections of code in single libraries.
Download site for MASM32      New MASM Forum
https://masm32.com          https://masm32.com/board/index.php

Vortex

Hi Danesh,

Here is how to build a static library:

\masm32\bin\lib /OUT:libraryname.lib objectfile1.obj objectfile2.obj etc...