Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
HomeAnnouncementsFree MagazinesWhite PapersSubmit Content
Discussion GroupsASP.NETWindows FormsLanguages.NET FrameworkVisual Studio.NET
Articles.NET FrameworkASP.NETToolsWindows Forms
.NET DirectoryOpen Source ProjectsUser GroupsWeb Resources
Related Topics
Visual Basic 6SQL ServerMS AccessOther DB ProductsMS Server ProductsMore Topics ...

.NET Forum / Languages / C++ Libraries / December 2003

Tip: Looking for answers? Try searching our database.

Link error LNK2019: unresolved external symbol

Thread view: 
Enable EMail Alerts  Start New Thread
Thread rating: 
AS - 02 Dec 2003 22:52 GMT
Hi,

I'm trying to use some power management features with windows 2000
Professional and I have visual studio .net 2003 installed with the latest
service packs and everything...  I want to write a simple app to turn the
system into sleep mode/suspend mode.  As per documentation of ACPI, you can
use the power options by including the Powrprof.h file and use the
Powrprof.lib file in your project, which I did, but when I build, it
compiles fine but I get this Link error.. :

error LNK2019: unresolved external symbol "unsigned char __stdcall
IsPwrSuspendAllowed(void)" (?IsPwrSuspendAllowed@@YGEXZ) referenced in
function _main
fatal error LNK1120: 1 unresolved externals

The code is as shown below :...
Any Ideas on what I'm missing here...  please help...

Thanks,
Regards,
AS.

/******************************************/
#include "stdafx.h"

#include "Windows.h"

#include "Powrprof.h"

int _tmain(int argc, _TCHAR* argv[])  {

if (isPwrSuspendAllowed() == TRUE)  {

 printf("Suspend state is allowed\n");

}

else  {

printf("Suspend state is NOT allowed\n");

}

return 0;

}
/************************************/

Signature

AS

David Goon [MSFT] - 15 Dec 2003 17:02 GMT
Hi AS,

Thanks very much for your query.

The problem is that the functions in powrprof.lib is exported as plain 'C'
functions. However, when compiling your application, the compiler defaults
to C++ since it sees a .cpp file extension. This causes the
IsPwrSuspendAllowed() API to be 'decorated' and will not match the exports
from the library.

To get around this, you can declare standard 'C' prototypes for the
powrprof.h include as below:

extern "C" {
#include <powrprof.h>
}

This will remove the decoration and your project should link fine (it does
for me).

Hope this helps,
David Goon
Microsoft

This posting is provided "AS IS" with no warranties, and confers no rights.
Use of included script samples are subject to the terms specified at
http://www.microsoft.com/info/cpyright.htm

Rate this thread:







Free Magazines

Get these publications absolutely FREE for up to 12 months. There are no hidden fees and no obligation. Simply choose a title, complete the application form and submit it. Read more ...

Oracle MagazineNetwork ComputingComputer WorldBio-IT WorldeWeekInformation WeekInfosecurity
 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2008 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.