The MASM Forum Archive 2004 to 2012

General Forums => The Workshop => Topic started by: Danesh on March 24, 2005, 03:09:14 AM

Title: creating .inc files
Post by: Danesh on March 24, 2005, 03:09:14 AM
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]
Title: Re: creating .inc files
Post by: hutch-- on March 24, 2005, 03:13:45 AM
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.
Title: Re: creating .inc files
Post by: hitchhikr on March 24, 2005, 03:49:00 AM
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.
Title: Re: creating .inc files
Post by: Danesh on March 24, 2005, 04:44:49 AM
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

Title: Re: creating .inc files
Post by: hutch-- on March 24, 2005, 04:56:04 AM
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.
Title: Re: creating .inc files
Post by: hitchhikr on March 24, 2005, 05:07:09 AM
a .lib is just a convenient pack of .objs
Title: Re: creating .inc files
Post by: Vortex on March 24, 2005, 10:55:52 AM
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.
Title: Re: creating .inc files
Post by: Danesh on March 25, 2005, 11:34:07 AM
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

Title: Re: creating .inc files
Post by: hutch-- on March 25, 2005, 12:15:14 PM
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.
Title: Re: creating .inc files
Post by: Vortex on March 28, 2005, 10:10:53 AM
Hi Danesh,

Here is how to build a static library:

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