News:

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

using masm32 lib

Started by Jimg, July 29, 2005, 03:33:21 PM

Previous topic - Next topic

Jimg

I'm having a little trouble adding masm32 lib to a project.  I had the following which worked without problems-

.486
.model Flat, Stdcall
option Casemap :None   ; case sensitive
include Windows.inc

uselib MACRO libname
    include    libname.inc
    includelib libname.lib
ENDM

uselib user32
uselib kernel32
uselib shell32
uselib comctl32
uselib comdlg32
uselib gdi32


I then added masm32 to the list0

uselib masm32 ; for debug

and got the following errors-


Dip.obj : error LNK2001: unresolved external symbol _run_synch_process_ex@8
masm32.lib(BitmapFromFile.obj) : error LNK2001: unresolved external symbol _OleLoadPicturePath@24
masm32.lib(BitmapFromMemory.obj) : error LNK2001: unresolved external symbol _OleLoadPicture@20
masm32.lib(QSORTA.obj) : error LNK2001: unresolved external symbol _SysAllocStringByteLen@8
masm32.lib(QSORTD.obj) : error LNK2001: unresolved external symbol _SysAllocStringByteLen@8
masm32.lib(a2wc.obj) : error LNK2001: unresolved external symbol _SysAllocStringByteLen@8
masm32.lib(QSORTA.obj) : error LNK2001: unresolved external symbol _SysFreeString@4
masm32.lib(QSORTD.obj) : error LNK2001: unresolved external symbol _SysFreeString@4
F:\WinAsm\Progs\Dip\Dip.exe : fatal error LNK1120: 5 unresolved externals


I've use this code in many other programs with no problem so am at a loss for an explanation.

Searching for some of these, I added the line-
uselib oleaut32
just to see what would happen.  There is no reason I can see why I would need this library, but I tried it anyway. Then I just got this error-
Dip.obj : error LNK2001: unresolved external symbol _run_synch_process_ex@8

Anyone know what is going on here?  I suspect it is some naming problem in my code conflicting with the library routines, but I can't seem to find it in the 3000 lines of code :(


P1

Are you sure the masm32.lib is in the search path?  Or at least copied to where the other *.lib files are?

Regards,  P1  :8)

Jimg

Dang, I looked for a long time before posting.  What was happening is I already had masm32 lib declared much farther down in the code where it didn't belong :red  Somehow it was in a section I thought was inactivated.  So the problem was having it included twice!  Duh.....  someday I'll learn :'(

joe

I have this problem some weeks ago too. My solution was in change including order. (I don't remember, if masm32 was first). Then it was OK.

Vortex

Hi Jimg,

You have to use CATSTR or @CatStr to concatenate strings :

Quote
String Directives and Predefined Functions

CATSTR

Concatenates one or more strings to a single string.

These directives assign a processed value to a text macro or numeric equate. For example, the following lines

num     =       7
newstr  CATSTR  <3 + >, %num, < = > , %3 + num ; "3 + 7 = 10"

assign the string "3 + 7 = 10" to newstr. CATSTR and SUBSTR assign text in the same way as the TEXTEQU directive. SIZESTR and INSTR assign a number in the same way as the = operator. The four string directives take only text values as arguments. Use the expansion operator (%) when you need to make sure that constants and numeric equates expand to text, as shown in the preceding lines.   

Each of the string directives has a corresponding predefined macro function version: @SubStr, @InStr, @SizeStr, and @CatStr. Macro functions are similar to the string directives, but you must enclose their arguments in parentheses. Macro functions return text values and can appear in any context where text is expected. The following section, "Returning Values with Macro Functions," tells how to write your own macro functions. The following example is equivalent to the previous CATSTR example:

num     =       7
newstr  TEXTEQU @CatStr( <3 + >, %num, < = > , %3 + num )

http://webster.cs.ucr.edu/Page_TechDocs/MASMDoc/ProgrammersGuide/Chap_09.htm

Jimg

??????!?  :dazzled:

Hi Vortex-

You usually post very helpful responses, however in this case it went completely over my head.  How does catstr apply to my original question??

Vortex

<untested>

uselib MACRO libname
    include    @CatStr(%libname , <.inc>)
    includelib @CatStr(%libname , <.lib>)
ENDM

hutch--

Vortex,

An interesting idea.  :U
Download site for MASM32      New MASM Forum
https://masm32.com          https://masm32.com/board/index.php

Jimg

Hmmm-

I have been using that uselib macro forever with no problems, why would catstr be required here?

Also, there's something slightly wrong with your suggestion as I get

F:\WinAsm\Progs\Dip\Dip.asm(23) : fatal error A1000: cannot open file : @CatStr(%user32 , <.inc>)

It should be

%    include    @CatStr(&libname , <.inc>)
%    includelib @CatStr(&libname , <.lib>)


but the real problem, as I metions above, is that I had masm32.lib declared twice.  And it doesn't seem worth putting in ifndef, etc. to get around the problem, better to just fix the code.

Or am I still being really dense and missing the point here?


hutch--

This roughie works.


    inclib MACRO barename
      LOCAL incc,libb
      incc equ <include >
      libb equ <includelib >
      incc CATSTR incc,<\masm32\include\>,<barename>,<.inc>
      libb CATSTR libb,<\masm32\lib\>,<barename>,<.lib>
      % incc
      % libb
    ENDM

    inclib kernel32
    inclib user32
    inclib gdi32
Download site for MASM32      New MASM Forum
https://masm32.com          https://masm32.com/board/index.php

Jimg

Ok, now I get it.  You guys are just trying to confuse me with the most complicated way of doing something simple.  It may take awhile but eventually I catch on.

Mark Jones

No, that would require decoding the (mangled) filename with a polyalphabetic substitution cipher. :)
"To deny our impulses... foolish; to revel in them, chaos." MCJ 2003.08

QvasiModo

Quote from: Jimg on July 29, 2005, 03:33:21 PM
Searching for some of these, I added the line-
uselib oleaut32
just to see what would happen.  There is no reason I can see why I would need this library, but I tried it anyway. Then I just got this error-
Dip.obj : error LNK2001: unresolved external symbol _run_synch_process_ex@8

The masm32 library includes functions from Ernie's ImageLib, which uses oleaut32.dll. That's why you need that import library as well - try it using bare "include" and "includelib" statements if you don't believe me.

The last error you got is probably another import required by the masm32 library.

Jimg

But I didn't need it!  The whole problem was having two includes for masm32.inc

I still have no idea why this would cause the errors I got just because I had the two includes, but I certainly know the solution!

PBrennick

Jimq,
Usually, it has been my experience, that if you accidently include a library twice you will get those errors because the assembler will toss out BOTH instances.  You had already solved your problem but there was an observation that the macro could be written in a more robust sort of way.  That is all.

My recommendation is that includes and includelibs should only be at the start of the source file so as to avoid these type of accidents.  Good job solving your problem, though.  As far as ifndef goes, I totally agree with you.  Just get it right and there is no need.  I have seen some users post code with 5 or 6 .ASM files; these are error prone for just this reason, and when you get a vague sort of error it can drive you out of your gourd.

Paul
The GeneSys Project is available from:
The Repository or My crappy website