473,408 Members | 2,832 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,408 software developers and data experts.

Won't compile a Windows program

I've been following the tutorial here to learn Windows programming (along
with the help file from the Windows Platform SDK):

http://www.cprogramming.com/tutorial...ogramming.html

and when I try compiling the code given in this tutorial (even using copy
paste instead of manually typing it), I keep getting errors that prevent me
from compiling it. At first, it was because windows.h couldn't be found, but
that issue was resolved and now I've got one thing that is very confusing.
When I build, I get the error "unresolved external symbol". This is the
build log I get:

------ Build started: Project: Windowsapptest, Configuration: Debug Win32
------
Compiling...
firsttest.cpp
Linking...
firsttest.obj : error LNK2019: unresolved external symbol
__imp__MessageBoxA@16">__imp__MessageBoxA@16</areferenced in function <a
href="mailto:_WinMain@16
C:\My Documents\My programs\Windowsapptest\Debug\Windowsapptest.exe : fatal
error LNK1120: 1 unresolved externals
Build log was saved at "file://c:\My Documents\My
programs\Windowsapptest\Windowsapptest\Debug\Build Log.htm"
Windowsapptest - 2 error(s), 0 warning(s)
========== Build: 0 succeeded, 1 failed, 0 up-to-date, 0 skipped ==========

I have Windows XP Pro SP2 and Visual C++ 2005 Express. From another forum,
I quite some help, but I was later told to ask elsewhere so I figured I'd
post here. You can see the details (and a few screenshots) here:

http://forums.howwhatwhy.com/showthr...&view=&sb=5&o=

How can I fix this?

--
Some programming:
void bluewater() {while(game_runs == 1)
{if fox.position == in_blue_water) {fox.health -= 1;}
else {fox.wants_to_get_wet = true;} wait_frames(1);}}
Dec 3 '06 #1
6 2913
"ulillillia" <ul********@discussions.microsoft.comwrote in message
news:03**********************************@microsof t.com...
I've been following the tutorial here to learn Windows programming (along
with the help file from the Windows Platform SDK):

http://www.cprogramming.com/tutorial...ogramming.html

and when I try compiling the code given in this tutorial (even using copy
paste instead of manually typing it), I keep getting errors that prevent
me
from compiling it. At first, it was because windows.h couldn't be found,
but
that issue was resolved and now I've got one thing that is very confusing.
When I build, I get the error "unresolved external symbol". This is the
build log I get:

------ Build started: Project: Windowsapptest, Configuration: Debug Win32
------
Compiling...
firsttest.cpp
Linking...
firsttest.obj : error LNK2019: unresolved external symbol
__imp__MessageBoxA@16">__imp__MessageBoxA@16</areferenced in function <a
href="mailto:_WinMain@16
C:\My Documents\My programs\Windowsapptest\Debug\Windowsapptest.exe :
fatal
error LNK1120: 1 unresolved externals
So, you call MessageBox() in your application? IAC, the linker is telling
you that it can't be found. Look up the function on the MSDN site. You find
the definition here:

http://msdn.microsoft.com/library/de...messagebox.asp

Scroll down to the bottom of the page and you'll see that it requires the
USER32.LIB import library. Add that to the list of objects and libraries in
the linker's properties page and relink.

Of course, that presumes that you have downloaded the Windows software
development kit (SDK). Have you done that?

Regards,
Will
Dec 3 '06 #2
Yes, I have downloaded the Windows Platform SDK (R2) and installed it. I saw
that you need the user32.dll and/or user32.lib files. Thing is, how do you
link a library? An include?

Do note that I started with "empty project" or the like when I started this
temporary learning project. Much of the configuration stuff seems to be left
blank or empty. Don't bother mentioning to switch to "Win32 project" or
whatever as I don't have that available ("Windows console project" and
"Windows forms project" are the only two available). The only option I had
was to start with a empty project.

--
Some programming:
void bluewater() {while(game_runs == 1)
{if fox.position == in_blue_water) {fox.health -= 1;}
else {fox.wants_to_get_wet = true;} wait_frames(1);}}
Dec 3 '06 #3
"ulillillia" <ul********@discussions.microsoft.comwrote in message
news:AD**********************************@microsof t.com...
Yes, I have downloaded the Windows Platform SDK (R2) and installed it. I
saw
that you need the user32.dll and/or user32.lib files. Thing is, how do
you
link a library? An include?
You are using the Express Edition?

If so, choose Project->Properties from the menu. Click on the '+' to expand
the 'Configuration Properties', then open up the 'Linker' options the same
way, click on the 'Input' category, then in the edit box labeled 'Additional
Depencies' type

user32.lib

Regards,
Will
Dec 3 '06 #4
You should do like below steps:

Update the Visual C++ directories in the Projects and Solutions section in the Options dialog box.

Add the paths to the appropriate subsection:

Executable files: C:\Program Files\Microsoft Platform SDK for Windows Server 2003 R2\Bin

Include files: C:\Program Files\Microsoft Platform SDK for Windows Server 2003 R2\Include

Library files: C:\Program Files\Microsoft Platform SDK for Windows Server 2003 R2\Lib

Note: Alternatively, you can update the Visual C++ Directories by modifying the VCProjectEngine.dll.express.config file located in the \vc\vcpackages subdirectory of the Visual C++ Express install location. Please make sure that you also delete the file "vccomponents.dat" located in the "%USERPROFILE%\Local Settings\Application Data\Microsoft\VCExpress\8.0" if it exists before restarting Visual C++ Express Edition.

Update the corewin_express.vsprops file.

One more step is needed to make the Win32 template work in Visual C++ Express. You need to edit the corewin_express.vsprops file (found in C:\Program Files\Microsoft Visual Studio 8\VC\VCProjectDefaults) and

Change the string that reads:

AdditionalDependencies="kernel32.lib" to

AdditionalDependencies="kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib"

Generate and build a Win32 application to test your paths.

In Visual C++ Express, the Win32 Windows Application type is disabled in the Win32 Application Wizard. To enable that type, you need to edit the file AppSettings.htm file located in the folder ¡°%ProgramFiles%\Microsoft Visual Studio 8\VC\VCWizards\AppWiz\Generic\Application\html\103 3\".

In a text editor comment out lines 441 - 444 by putting a // in front of them as shown here:

// WIN_APP.disabled = true;
// WIN_APP_LABEL.disabled = true;
// DLL_APP.disabled = true;
// DLL_APP_LABEL.disabled = true;

Save and close the file and open Visual C++ Express.

From the File menu, click New Project. In the New Project dialog box, expand the Visual C++ node in the Product Types tree and then click Win32. Click on the Win32 Console Application template and then give your project a name and click OK. In the Win32 Application Wizard dialog box, make sure that Windows application is selected as the Application type and the ATL is not selected. Click the Finish button to generate the project.

As a final step, test your project by clicking the Start button in the IDE or by pressing F5. Your Win32 application should build and run.
--------------------------------------------------------------------------------
"William DePalo [MVP VC++]" <wi***********@mvps.orgдÈëÏûÏ¢ news:uC**************@TK2MSFTNGP03.phx.gbl...
"ulillillia" <ul********@discussions.microsoft.comwrote in message
news:AD**********************************@microsof t.com...
Yes, I have downloaded the Windows Platform SDK (R2) and installed it. I
saw
that you need the user32.dll and/or user32.lib files. Thing is, how do
you
link a library? An include?
You are using the Express Edition?

If so, choose Project->Properties from the menu. Click on the '+' to expand
the 'Configuration Properties', then open up the 'Linker' options the same
way, click on the 'Input' category, then in the edit box labeled 'Additional
Depencies' type

user32.lib

Regards,
Will
Dec 3 '06 #5
I'm very confused with the first part - setting the directories. I don't see
any of the "C:\Program Files\..." stuff, but other things that makes me very
confused. As an example, I see this in that file you mentioned:

Include="$(VCInstallDir)include;$(VCInstallDir)Pla tformSDK\include;$(FrameworkSDKDir)include"

I don't get what any of this means and as a result, I have no idea what I
need to do. I first used the options dialog stuff, but I saw this same thing
without the familiar "C:\Program Files\..." stuff. What do I do and where do
I put the additions I need. I don't see any "executable files" listed in
that file. Given the top line, it appears as if this is an XML file, the
first time I've actually seen such a file (which seems a lot like HTML only
with odd symbols and formatting (the dollar sign)).

I haven't done anything else past this first part since I feel as if I need
to do them in the order you've given.

Thanks so far though for the assistance, but I'm just very confused on the
first part I need to do.

--
Some programming:
void bluewater() {while(game_runs == 1)
{if fox.position == in_blue_water) {fox.health -= 1;}
else {fox.wants_to_get_wet = true;} wait_frames(1);}}
Dec 4 '06 #6
Okay, so I tried just copying and pasting the URL using the dialog through
the options menu instead of being confused with the weird formatting. That
appeared to have worked properly and I began following the other directions
you had and it all works. Thank you so much for the assistance and I can now
begin learning Windows programming and eventually get into game programming
when my ability gets good enough.

--
Some programming:
void bluewater() {while(game_runs == 1)
{if fox.position == in_blue_water) {fox.health -= 1;}
else {fox.wants_to_get_wet = true;} wait_frames(1);}}
Dec 5 '06 #7

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

19
by: Christopher | last post by:
I am getting a parse error from g++ pointing at my catch line and can't figure out whats wrong with this code: #include "BigPosInt.h" #include <iostream> #include <new> #include <assert.h> ...
4
by: Vince | last post by:
I'm getting this message when I try and run a .net web app in the development system: CS0016: Could not write to output file 'c#:\windows nt\Microsoft..net framework\v1.1.4322\Temporary ASP.NET...
1
by: ping | last post by:
Hello everyone! I had already installed VC6.0 in my computer, then i installed the Vs.net. I wrote some programs of vs.net with the UtraEdit and compiled them in command line. For example, i wrote...
13
by: developer | last post by:
re-compile under dev -c++ bloodshed. can u help ? #include<dos.h> #include<process.h> #include<io.h> #include<stdio.h> #define STROBE 0x01
11
by: bart | last post by:
Hello, I'm so sorry, but i don't understand the concept of the .net environment yet. I made a simple program that retrieves the hostname and ipaddress of the local computer. But when i give...
3
by: | last post by:
I am trying to compile a simple c# class in Web Matrix called howdy.cs: // Program start class public class HowdyPartner { // Main begins program execution public static void Main() { //...
30
by: MikeC | last post by:
Good People, I'm writing a backup utility that uses a chdir() to go into the source directory (in which the files reside that I want to back up), so I don't want to use chdir() to get into the...
0
by: dot | last post by:
I spent a few headache filled days trying to use GMP on windows (XP pro) I finally got it to work and since I found little help on the Web I thought someone might find what i did useful. ...
2
myusernotyours
by: myusernotyours | last post by:
Hi All, Am working on a Java application in which I have to use the JNI to Interface with some native code for both windows and unix. Am using netbeans IDE with the C/C++ pack installed. Am also...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.