Pelles C linking error : (unresolved external symbol)

When trying to debug a Win32 project sometimes linking errors may occur.
 I came across such situation when I used ShellExecute() API in my program. The error says

POLINK: error: Unresolved external symbol '__imp__ShellExecuteA@24'.
POLINK: fatal error: 1 unresolved external(s).
*** Error code: 1 ***

What I have in my code was like this

char sys[MAX_PATH];
. . . . .
. . . . .
. . . . .
GetSystemDirectory(sys,MAX_PATH);
ShellExecute(NULL,"open",sys,NULL,NULL,SW_NORMAL);  


The above code will open the "System32" folder in explorer

In this case, the solution is to add shell32.lib to the library and object files list.

In Pelles C go to Project->Project Options

A dialog box will open now.
Select "linker" tab


In library and object files, add shell32.lib seperated by a space as below


Add all the required library files here and Press OK.

Comments

Post a Comment