Author Topic: error LNK2019: unresolved external symbol _imp__ShellExecuteA@24  (Read 7640 times)

vogelsang

  • Member
  • **
  • Posts: 64
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:
Code: [Select]
;--------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

  • Member
  • *****
  • Posts: 10644
  • Assembler is fun ;-)
    • MasmBasic
Re: error LNK2019: unresolved external symbol _imp__ShellExecuteA@24
« Reply #1 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?

vogelsang

  • Member
  • **
  • Posts: 64
Re: error LNK2019: unresolved external symbol _imp__ShellExecuteA@24
« Reply #2 on: April 15, 2014, 03:57:51 AM »
Windows.inc form WinInc208 includes shellapi.inc and there i've found:
Code: [Select]
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:
Code: [Select]
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

  • Member
  • *****
  • Posts: 10644
  • Assembler is fun ;-)
    • MasmBasic
Re: error LNK2019: unresolved external symbol _imp__ShellExecuteA@24
« Reply #3 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.

vogelsang

  • Member
  • **
  • Posts: 64
Re: error LNK2019: unresolved external symbol _imp__ShellExecuteA@24
« Reply #4 on: April 15, 2014, 04:24:04 AM »
Disabling the upper variant has worked. Great thanks jj2007.
"How beautiful this world ruled by dibs, not a gun!"
...

fearless

  • Member
  • ***
  • Posts: 480
    • LetTheLightIn
Re: error LNK2019: unresolved external symbol _imp__ShellExecuteA@24
« Reply #5 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)

Code: [Select]
; 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
fearless

CM690II Case, HX1000 PSU, Asus Z97, Intel i7-4790K, Seidon 120v Cooler, 16GB DDR3, MSI GTX 980TI

My Github  Twitter

Gunther

  • Member
  • *****
  • Posts: 3585
  • Forgive your enemies, but never forget their names
Re: error LNK2019: unresolved external symbol _imp__ShellExecuteA@24
« Reply #6 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
Get your facts first, and then you can distort them.

jj2007

  • Member
  • *****
  • Posts: 10644
  • Assembler is fun ;-)
    • MasmBasic
Re: error LNK2019: unresolved external symbol _imp__ShellExecuteA@24
« Reply #7 on: April 20, 2015, 06:33:33 PM »
It should work with ml and jWasm, I hope.

Test it...