Windows API

How do I fix link error with visual 2005

Page 1 of 1

6 Replies - 515 Views - Last Post: 13 July 2010 - 08:33 AM Rate Topic: -----

#1 dinisrainman  Icon User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 33
  • Joined: 10-February 08

Windows API

Posted 12 July 2010 - 10:25 PM

Hello Everyone

I started developing Window apps today and i'm using Visual Studio 2005 and coding in C, my fave language and i'm following a web tutorial. However, when the program is compiled i'm getting a link error.
I opened a new project and the error persists. Below is part of what the compiler displays:
 [size="4"][b][b]error LNK2019: unresolved external symbol _CreateWindowEX referenced in function _WinMain@16
\Visual Studio 2005\Projects\petProduction Management\Debug\petProduction Management.exe : fatal error LNK1120: 1 unresolved externals [/b][/b][/size][/i][/u].



Any ideas , any suggestions on what settings do I need to change?
Please refer any useful tutorials on windows programming using c/c++ . I know C# seems to be the most popular but i'm not familiar with C# yet and I don't intend to learn it now.

thanks

Is This A Good Question/Topic? 0
  • +

Replies To: Windows API

#2 no2pencil  Icon User is offline

  • Original Digital Gansta
  • member icon

Reputation: 4466
  • View blog
  • Posts: 24,916
  • Joined: 10-May 07

Re: Windows API

Posted 12 July 2010 - 10:27 PM

Your code most likely contains main() & you need to use WinMain().

MSDN for WinMain
Was This Post Helpful? 0
  • +
  • -

#3 sarmanu  Icon User is offline

  • D.I.C Lover
  • member icon

Reputation: 965
  • View blog
  • Posts: 2,362
  • Joined: 04-December 09

Re: Windows API

Posted 12 July 2010 - 10:48 PM

No. Take a look at error message:

Quote

unresolved external symbol _CreateWindowEX referenced in function _WinMain@16

So the unresolved external is CreateWindowEX, and it's used in WinMain. He most likely need to link with user32.lib.
Was This Post Helpful? 0
  • +
  • -

#4 no2pencil  Icon User is offline

  • Original Digital Gansta
  • member icon

Reputation: 4466
  • View blog
  • Posts: 24,916
  • Joined: 10-May 07

Re: Windows API

Posted 12 July 2010 - 10:59 PM

oops, I got confused :P
Was This Post Helpful? 0
  • +
  • -

#5 dinisrainman  Icon User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 33
  • Joined: 10-February 08

Re: Windows API

Posted 12 July 2010 - 11:58 PM

I used WinMain. sarmanu how do I link to
user32.lib? 
. Is that a library within windows or part of visual studio itself?
Was This Post Helpful? 0
  • +
  • -

#6 sarmanu  Icon User is offline

  • D.I.C Lover
  • member icon

Reputation: 965
  • View blog
  • Posts: 2,362
  • Joined: 04-December 09

Re: Windows API

Posted 13 July 2010 - 12:04 AM

It comes with Visual Studio. You can link directly from a source file (or header) using #pragma comment:
#pragma comment(lib, "user32.lib")


or you can link from project settings. Do this:
Right click on project name -> Properties -> Expand Linker tab -> Now, at Additional dependencies, simply write: user32.lib
Was This Post Helpful? 0
  • +
  • -

#7 Aphex19  Icon User is offline

  • Born again Pastafarian.
  • member icon

Reputation: 604
  • View blog
  • Posts: 1,866
  • Joined: 02-August 09

Re: Windows API

Posted 13 July 2010 - 08:33 AM

You probably created the project as a console application, create it as a Win32 application, that is most likely the source of the error. Good luck
Was This Post Helpful? 1
  • +
  • -

Page 1 of 1