error LNK2019: unresolved external symbol _imp__ShellExecuteA@24

Started by vogelsang, April 15, 2014, 03:20:17 AM

Previous topic - Next topic

vogelsang

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?
"How beautiful this world ruled by dibs, not a gun!"
...

jj2007

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?

vogelsang

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.
"How beautiful this world ruled by dibs, not a gun!"
...

jj2007

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.

vogelsang

Disabling the upper variant has worked. Great thanks jj2007.
"How beautiful this world ruled by dibs, not a gun!"
...

fearless

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


Gunther

Thank you fearless for sharing your improved file. It should work with ml and jWasm, I hope.

Gunther
You have to know the facts before you can distort them.

jj2007