I've been trying to compile several C++ tutorial files that include the standard Microsoft header files, such as 'windows.h' to create a basic window. I'm fairly new to this C++ business, but I have a bit of experience with writing console applications on C.

The problem is that the command line compiler keeps throwing the LNK2019 error for every external function I use. I did some searching online and someone mentioned that it was because the function I was trying to use was the prototype but there wasn't a supposed implementation. (They look the same, actually.)

Not entirely convinced, I looked around some more, went back to my tutorial and it said, "Make sure you have specified a Win32 GUI (NOT 'Console') project/makefile/target, whatever applies to your compiler."

I found out that I can compile some of the files using the full-blown Visual Studio. I'm not used to Visual Studio and I think it's clunky and funky.

So is there a way to tell the CL compiler that it's a Win32 app so it'll include the Windows headers and avoid Visual Studio entirely?

Note: the files already include <windows.h>, so that isn't the problem.

Well, thanks anyway, but I found a simple solution to my problem. I wasn't including the user32.lib file as #pragma comment(lib,"user32.lib") Edit: For anybody else struggling with this, you can also include the file as cl myprogra.cpp [b]user32.lib[/b] when using the CL compiler on the command line.

Links: http://social.msdn.microsoft.com/Forums/en-US/vcgeneral/thread/534b926b-ab1c-460d-b5f7-7ff0d85f8378
http://msdn.microsoft.com/en-us/library/7f0aews7%28VS.71%29.aspx

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.