Unresolved external symbol '__imp__MessageBoxA@16'.

Started by David L Morris, August 25, 2011, 12:26:14 PM

Previous topic - Next topic

David L Morris

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

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.


TimoVJL

#2
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>
May the source be with you

David L Morris

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

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

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