NO

Author Topic: Unresolved external symbol '__imp__MessageBoxA@16'.  (Read 17734 times)

David L Morris

  • Guest
Unresolved external symbol '__imp__MessageBoxA@16'.
« on: August 25, 2011, 12:26:14 pm »
Trying to compile a Windows Console code but I get this error:-
Building CallProc.exe.
POLINK: error: Unresolved external symbol '__imp__MessageBoxA@16'.
POLINK: fatal error: 1 unresolved external(s).
*** Error code: 1 ***
Done.
I think I have the Project options set correctly.  Where should I review next.  The code came from the forum to "Creating a Child Process with Redirected Input and Output"

CommonTater

  • Guest
Re: Unresolved external symbol '__imp__MessageBoxA@16'.
« Reply #1 on: August 25, 2011, 04:17:32 pm »
Does the project #include <windows.h>  ?
Also be sure you've set "enable microsoft extensions" in your project options.

You probably should post your code for us to take a look at.


Offline TimoVJL

  • Global Moderator
  • Member
  • *****
  • Posts: 1899
Re: Unresolved external symbol '__imp__MessageBoxA@16'.
« Reply #2 on: August 25, 2011, 05:41:30 pm »
Insert user32.lib to that project.
From menu Project -> Project options... -> Linker tab and to Library and objects files:

or #pragma comment(lib, "user32.lib") to source file.
or #define WIN32_DEFAULT_LIBS before <windows.h>
« Last Edit: August 25, 2011, 05:53:08 pm by timovjl »
May the source be with you

David L Morris

  • Guest
Re: Unresolved external symbol '__imp__MessageBoxA@16'.
« Reply #3 on: August 26, 2011, 02:25:11 am »
Thank you Tater and tomovjl for your replies.  I have windows.h included in the project, so I followed tomovjl's suggestion - Insert user32.lib to that project.
From menu Project -> Project options... -> Linker tab and to Library and objects files:
The project compiled without errors.
I hope I have attached the code correctly.  I haven't yet merged both applications to work together as I am trying to learn more by studying the code.
Thanks again
David

CommonTater

  • Guest
Re: Unresolved external symbol '__imp__MessageBoxA@16'.
« Reply #4 on: August 26, 2011, 04:23:28 am »
Actually I tend to prefer the #define WIN32_DEFAULT_LIBS method. 

As far as I know it's unique to Pelles C.  What it does is activate #pragmas in the Pelles Includes so that when you include a header file, it automatically adds the correct libraries to the linker's list.  I use it in practically every project that includes any Windows header... don't even have to think about linking issues.  (Which is why I didn't think to mention it, it's second nature... Thanks Timo!)

Glad you got it working...





David L Morris

  • Guest
Re: Unresolved external symbol '__imp__MessageBoxA@16'.
« Reply #5 on: August 27, 2011, 07:31:26 am »
The two programs seem to work well, so thanks for your help. 

The output is as below.  I use Kaspersky Internet Security and when the application runs a warning is presented indicating "behavior similar to PDM.RootShell. Allowed"

->Start of parent execution.

->Contents of dlmtest.txt written to child STDIN pipe.

->Contents of child process STDOUT:


 ** This is a message from the child process. **
Record one
Record two
Record three
Record five
David Morris

->End of parent execution.
Press any key to continue...

The learning from this is very satisfying.
Regards to all.  David

CommonTater

  • Guest
Re: Unresolved external symbol '__imp__MessageBoxA@16'.
« Reply #6 on: August 27, 2011, 03:24:24 pm »
No worries.... glad to help out....