The MASM Forum

64 bit assembler => 64 bit assembler. Conceptual Issues => Topic started by: vogelsang on April 15, 2014, 03:20:17 AM

Title: error LNK2019: unresolved external symbol _imp__ShellExecuteA@24
Post by: vogelsang on April 15, 2014, 03:20:17 AM
Hi guys,

I have a problem with linking code. this piece of code is only to show what is it about.

Here is the code:

;--------MAKE------------------------------------------------------------------------
;
; assembling:
; jwasm -win64 -Zp8 ShellExecute.asm
; linking:
; link /SUBSYSTEM:WINDOWS ShellExecute.obj
;
;--------INCLUDES--------------------------------------------------------------------

option casemap:none

;EXTERN ShellExecuteA:PROC

include /JWASM/wininc208/include/windows.inc

includelib      /JWASM/wininc208/lib64/kernel32.lib
includelib      /JWASM/wininc208/lib64/user32.lib
includelib      /JWASM/wininc208/lib64/shell32.lib

;--------DATA------------------------------------------------------------------------

.DATA

.DATA?

;--------CODE------------------------------------------------------------------------

.CODE

WinMainCRTStartup PROC FRAME

push rbp
.PUSHREG RBP
mov rbp, rsp
.SETFRAME RBP, 0
.ENDPROLOG

sub rsp, 8*8

call ShellExecuteA

WinMainCRTStartup ENDP
END
;--------EOF-------------------------------------------------------------------------


and when i'm trying to build it i get this error message:

ShellExecute.obj: error LNK2019: unresolved external symbol _imp__ShellExecuteA@24
referenced in function WinMainCRTStartup

When i comment out line:

include      /JWASM/WinInc208/include/windows.inc

and uncomment line:

;EXTERN      ShellExecuteA:PROC

linker knows where to search this proc. But i need all the includes windows.inc provides. This is weak solution. I tried to include shellapi.inc but that didn't fixed issue.
Someone knows what i'm doing wrong?
Title: Re: error LNK2019: unresolved external symbol _imp__ShellExecuteA@24
Post by: jj2007 on April 15, 2014, 03:34:14 AM
The Masm32 equivalent is in Shell32.inc:

ShellExecuteA PROTO STDCALL :DWORD,:DWORD,:DWORD,:DWORD,:DWORD,:DWORD
IFNDEF __UNICODE__
  ShellExecute equ <ShellExecuteA>
ENDIF


How is it treated in Windows.inc? Can you simply comment it out there and use your working solution?
Title: Re: error LNK2019: unresolved external symbol _imp__ShellExecuteA@24
Post by: vogelsang on April 15, 2014, 03:57:51 AM
Windows.inc form WinInc208 includes shellapi.inc and there i've found:

proto_ShellExecuteA typedef proto WINSTDCALLCONV :HWND, :LPSTR, :LPSTR, :LPSTR, :LPSTR, :DWORD
externdef WINSTDCALLCONV _imp__ShellExecuteA@24: ptr proto_ShellExecuteA
ShellExecuteA equ <_imp__ShellExecuteA@24>
proto_ShellExecuteW typedef proto WINSTDCALLCONV :HWND, :LPWSTR, :LPWSTR, :LPWSTR, :LPWSTR, :DWORD
externdef WINSTDCALLCONV _imp__ShellExecuteW@24: ptr proto_ShellExecuteW
ShellExecuteW equ <_imp__ShellExecuteW@24>
ifdef UNICODE
ShellExecute EQU <ShellExecuteW>
else
ShellExecute EQU <ShellExecuteA>
endif

and a bit lower:

proto_ShellExecuteExA typedef proto WINSTDCALLCONV :LPSHELLEXECUTEINFOA
externdef WINSTDCALLCONV _imp__ShellExecuteExA@4: ptr proto_ShellExecuteExA
ShellExecuteExA equ <_imp__ShellExecuteExA@4>
proto_ShellExecuteExW typedef proto WINSTDCALLCONV :LPSHELLEXECUTEINFOW
externdef WINSTDCALLCONV _imp__ShellExecuteExW@4: ptr proto_ShellExecuteExW
ShellExecuteExW equ <_imp__ShellExecuteExW@4>
ifdef UNICODE
ShellExecuteEx EQU <ShellExecuteExW>
else
ShellExecuteEx EQU <ShellExecuteExA>
endif


But i don't know what to do with this.
These are probably all instances of ShellExecute(ctrl+f) in this file.
Title: Re: error LNK2019: unresolved external symbol _imp__ShellExecuteA@24
Post by: jj2007 on April 15, 2014, 04:14:40 AM
Looks like it has been converted from a C header...
Try in Windows.inc:

if 0
...
endif

to disable the upper or lower variant. One of them will probably work.
Title: Re: error LNK2019: unresolved external symbol _imp__ShellExecuteA@24
Post by: vogelsang on April 15, 2014, 04:24:04 AM
Disabling the upper variant has worked. Great thanks jj2007.
Title: Re: error LNK2019: unresolved external symbol _imp__ShellExecuteA@24
Post by: fearless on April 20, 2015, 10:38:16 AM
I had a similar problem with _imp_ShellAboutA@16, but i tried a few things suggested and it still complained, so i edited the shellapi.inc as such: (for future reference if someone else has a similar issue)

; Commented out these definitions for ShellAbout:
;proto_ShellAboutA typedef proto WINSTDCALLCONV :HWND, :LPSTR, :LPSTR, :HICON
;externdef WINSTDCALLCONV _imp__ShellAboutA@16: ptr proto_ShellAboutA
;ShellAboutA equ <_imp__ShellAboutA@16>
;proto_ShellAboutW typedef proto WINSTDCALLCONV :HWND, :LPWSTR, :LPWSTR, :HICON
;externdef WINSTDCALLCONV _imp__ShellAboutW@16: ptr proto_ShellAboutW
;ShellAboutW equ <_imp__ShellAboutW@16>
;ifdef UNICODE
;ShellAbout    EQU    <ShellAboutW>
;else
;ShellAbout    EQU    <ShellAboutA>
;endif
;
; Using these instead:
;
@DefProto WINBASEAPI, ShellAboutA, stdcall, , <:HWND, :LPSTR, :LPSTR, :HICON>, 16
@DefProto WINBASEAPI, ShellAboutW, stdcall, , <:HWND, :LPSTR, :LPSTR, :HICON>, 16
ifdef UNICODE
ShellAbout    EQU    <ShellAboutW>
else
ShellAbout    EQU    <ShellAboutA>
endif

Title: Re: error LNK2019: unresolved external symbol _imp__ShellExecuteA@24
Post by: Gunther on April 20, 2015, 04:58:29 PM
Thank you fearless for sharing your improved file. It should work with ml and jWasm, I hope.

Gunther
Title: Re: error LNK2019: unresolved external symbol _imp__ShellExecuteA@24
Post by: jj2007 on April 20, 2015, 06:33:33 PM
Quote from: Gunther on April 20, 2015, 04:58:29 PM
It should work with ml and jWasm, I hope.

Test it...