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 / Managed C++ / December 2006

Tip: Looking for answers? Try searching our database.

Won't compile a Windows program

Thread view: 
Enable EMail Alerts  Start New Thread
Thread rating: 
ulillillia - 03 Dec 2006 04:05 GMT
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/opengl_windows_programming.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</a> referenced 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\BuildLog.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/showthreaded.php?Cat=&Board=software&Number=290240&
page=&view=&sb=5&o
=

How can I fix this?

Signature

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);}}

William DePalo [MVP VC++] - 03 Dec 2006 05:06 GMT
> I've been following the tutorial here to learn Windows programming (along
> with the help file from the Windows Platform SDK):
[quoted text clipped - 21 lines]
> 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/default.asp?url=/library/en-us/winui/winui/win
dowsuserinterface/windowing/dialogboxes/dialogboxreference/dialogboxfunctions/me
ssagebox.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
ulillillia - 03 Dec 2006 13:57 GMT
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.

Signature

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);}}

William DePalo [MVP VC++] - 03 Dec 2006 16:23 GMT
> 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
Wyvern - 03 Dec 2006 19:21 GMT
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\1033\".

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.

--------------------------------------------------------------------------------

 "ulillillia" <ulillillia@discussions.microsoft.com> wrote in message
 news:AD08EA94-055E-459E-9DA8-61A8DBBBFB04@microsoft.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
ulillillia - 04 Dec 2006 01:51 GMT
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)PlatformSDK\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.

Signature

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);}}

ulillillia - 05 Dec 2006 04:26 GMT
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.

Signature

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);}}


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.