Thread: Becoming frustrated with incomptability issues.

  1. #1
    Registered User
    Join Date
    Jul 2009
    Posts
    3

    Becoming frustrated with incomptability issues.

    Hello. I'm a beginner. I have programmed in different languages before, but I'm new to C++.

    In-order to begin to work with the tutorials in this website, I chose to install two compilers: Bloodshed's Dev-C++, and Microsoft's Visual C++ 2008 Express. As pathetic as it may sound, pasting the first piece of code available in the very first tutorial generated errors in both compilers.

    Code:
    #include <iostream>
    
    using namespace std;
    
    int main()
    {
      cout<<"HEY, you, I'm alive! Oh, and Hello World!\n";
      cin.get();
    }

    I attached the following pictures:

    Attachment 9106

    Attachment 9107

    I'm not sure if it's a problem on my end, or on your end. It's probably on my end.
    Anyhow, I tried to tweak with the source, change things. Nothing worked out.
    I'm simply paralyzed at the moment.

    Any help or suggestion would be appreciated.
    Thanks.

  2. #2
    Webhead Spidey's Avatar
    Join Date
    Jul 2009
    Posts
    285
    What type of project are you creating ?

    In visual studio -
    select empty project
    right click on 'source files'
    add -> new item
    .cpp file
    (Give it a name)

    and then paste in the same code and see what you get.

    Make sure you don't select precompiled header and select Empty Project. That is why you are getting the error in your screen shot.

  3. #3
    Registered User
    Join Date
    Jul 2009
    Posts
    3
    I indeed followed your instructions, to no avail..


    Build Log Build started: Project: BBB, Configuration: Debug|Win32

    Command Lines

    Creating temporary file "c:\Documents and Settings\Home\My Documents\Visual Studio 2008\Projects\BBB\BBB\Debug\RSP00000131363512.rsp" with contents
    [
    /Od /D "WIN32" /D "_DEBUG" /D "_WINDOWS" /D "_UNICODE" /D "UNICODE" /Gm /EHsc /RTC1 /MDd /Fo"Debug\\" /Fd"Debug\vc90.pdb" /W3 /c /ZI /TP ".\main.cpp"
    ]
    Creating command line "cl.exe @"c:\Documents and Settings\Home\My Documents\Visual Studio 2008\Projects\BBB\BBB\Debug\RSP00000131363512.rsp" /nologo /errorReportrompt"
    Creating temporary file "c:\Documents and Settings\Home\My Documents\Visual Studio 2008\Projects\BBB\BBB\Debug\TMP00000231363512.tmp" with contents
    [
    1 /* CREATEPROCESS_MANIFEST_RESOURCE_ID */ 24 /* RT_MANIFEST */ ".\\Debug\\BBB.exe.embed.manifest"
    ]
    Creating command line "rc.exe /fo".\Debug\BBB.exe.embed.manifest.res" "c:\Documents and Settings\Home\My Documents\Visual Studio 2008\Projects\BBB\BBB\Debug\TMP00000231363512.tmp" "
    Creating temporary file "c:\Documents and Settings\Home\My Documents\Visual Studio 2008\Projects\BBB\BBB\Debug\RSP00000331363512.rsp" with contents
    [
    /OUT:"C:\Documents and Settings\Home\My Documents\Visual Studio 2008\Projects\BBB\Debug\BBB.exe" /INCREMENTAL /MANIFEST /MANIFESTFILE:"Debug\BBB.exe.intermediate.manifest" /MANIFESTUAC:"level='asInvoker' uiAccess='false'" /DEBUG /PDB:"C:\Documents and Settings\Home\My Documents\Visual Studio 2008\Projects\BBB\Debug\BBB.pdb" /SUBSYSTEM:WINDOWS /DYNAMICBASE /NXCOMPAT /MACHINE:X86 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib

    ".\Debug\main.obj"

    ".\Debug\BBB.exe.embed.manifest.res"
    ]
    Creating command line "link.exe @"c:\Documents and Settings\Home\My Documents\Visual Studio 2008\Projects\BBB\BBB\Debug\RSP00000331363512.rsp" /NOLOGO /ERRORREPORT:PROMPT"

    Output Window

    Compiling...
    main.cpp
    Compiling manifest to resources...
    Microsoft (R) Windows (R) Resource Compiler Version 6.1.6723.1
    Copyright (C) Microsoft Corporation. All rights reserved.
    Linking...
    MSVCRTD.lib(crtexew.obj) : error LNK2019: unresolved external symbol _WinMain@16 referenced in function ___tmainCRTStartup
    C:\Documents and Settings\Home\My Documents\Visual Studio 2008\Projects\BBB\Debug\BBB.exe : fatal error LNK1120: 1 unresolved externals

    Results

    Build log was saved at "file://c:\Documents and Settings\Home\My Documents\Visual Studio 2008\Projects\BBB\BBB\Debug\BuildLog.htm"
    BBB - 2 error(s), 0 warning(s)

    I'm more curious to know why the error occures both in DEV-C++ AND in MSVCPP..
    Last edited by unionac; 07-18-2009 at 06:09 AM.

  4. #4
    Webhead Spidey's Avatar
    Join Date
    Jul 2009
    Posts
    285
    MSVCRTD.lib(crtexew.obj) : error LNK2019: unresolved external symbol _WinMain@16 referenced in function ___tmainCRTStartup
    C:\Documents and Settings\Home\My Documents\Visual Studio 2008\Projects\BBB\Debug\BBB.exe : fatal error LNK1120: 1 unresolved externals
    Seems like your creating a windows application. You have to select console application and check the empty project box(even if you select win32console project); or create an empty project like I described above.

  5. #5
    Registered User
    Join Date
    Jul 2009
    Posts
    3
    Quote Originally Posted by Spidey View Post
    Seems like your creating a windows application. You have to select console application and check the empty project box(even if you select win32console project); or create an empty project like I described above.
    Seems to work. Thank you, Sir!

    Yet still, any idea why the failure occurs with Dev-C++?

    Thank you!

  6. #6
    Webhead Spidey's Avatar
    Join Date
    Jul 2009
    Posts
    285
    Also, your main needs to return a value at the end.

    Code:
    int main()
    {
      cout<<"HEY, you, I'm alive! Oh, and Hello World!\n";
      cin.get();
    
      return 0;
    }

  7. #7
    C++11 User Tux0r's Avatar
    Join Date
    Nov 2008
    Location
    Sweden
    Posts
    135
    Quote Originally Posted by Spidey View Post
    Also, your main needs to return a value at the end.

    Code:
    int main()
    {
      cout<<"HEY, you, I'm alive! Oh, and Hello World!\n";
      cin.get();
    
      return 0;
    }
    It does not have to.

  8. #8
    Webhead Spidey's Avatar
    Join Date
    Jul 2009
    Posts
    285
    Yet still, any idea why the failure occurs with Dev-C++?
    Probably the same thing, select console application and it should work.

  9. #9
    Registered User
    Join Date
    Jun 2005
    Posts
    6,815
    The problem is on "your end", not ours.

    You have configured Visual Studio (or it is configured by default) to create a windows application. That's what the "win32" at the end of the first bold line in your build log is saying.

    The entry point (the first function in a program written by the programmer) for a windows application is a function called WinMain() - the name is specific to Microsoft windows - and that appears to the linker as a function named _WinMain@16 (which is not being found).

    The code you have is standard C++ (in the sense of being what an ISO standard compliant compiler will accept). The ISO C++ standard specifies that the entry point is named main() - not WinMain().

    The solution will be to go through compiler or project settings, and configure Visual Studio to create a "Console" application rather than a "windows" (aka Win32) application. Building a "Console" application is Visual Studio's method of working with standard C++ rather than using Microsoft specific extensions related to building windows GUI applications.

    I'm not specifically aware, offhand, of how to change that setting in Visual Studio - the method is specific to the Visual Studio software. However, if you go through available menu settings (probably related to the "Project Options" or something similar) you will find an appropriate setting to change.

    Another way is to start a new project, but specify it is a console mode project. Note that when creating a new project, Microsoft development environments default to building a win32 application, so you you have to change settings accordingly when creating a new project.

    The problem with Dev-C++ is that it is not finding the <iostream> header. That means one of your environment settings (probably INCLUDE_LIBRARY_PATH or something like that) is misconfigured and needs contain the actual path of the directory that contains the standard headers. That setting can, again, be changed through the Dev-C++ user interface. This is usually an installation problem.
    Last edited by grumpy; 07-18-2009 at 06:29 AM.

  10. #10
    Webhead Spidey's Avatar
    Join Date
    Jul 2009
    Posts
    285
    It does not have to.
    True, but it should.

  11. #11
    C++11 User Tux0r's Avatar
    Join Date
    Nov 2008
    Location
    Sweden
    Posts
    135
    Quote Originally Posted by Spidey View Post
    True, but it should.
    Not if you are going to set it to 0 anyway.

  12. #12
    C++まいる!Cをこわせ!
    Join Date
    Oct 2007
    Location
    Inside my computer
    Posts
    24,654
    Quote Originally Posted by unionac View Post
    I'm not sure if it's a problem on my end, or on your end. It's probably on my end.
    Anyhow, I tried to tweak with the source, change things. Nothing worked out.
    I'm simply paralyzed at the moment.

    Any help or suggestion would be appreciated.
    Thanks.
    Did you see how it asked if you had added #include "stdafx.h"? That error is pretty obvious.
    If you need help with compiler errors in Visual Studio, select the error and press F1. A help will open describing it. The help on the error you got is very straight forward.
    Try that next time!
    Quote Originally Posted by Adak View Post
    io.h certainly IS included in some modern compilers. It is no longer part of the standard for C, but it is nevertheless, included in the very latest Pelles C versions.
    Quote Originally Posted by Salem View Post
    You mean it's included as a crutch to help ancient programmers limp along without them having to relearn too much.

    Outside of your DOS world, your header file is meaningless.

  13. #13
    Cat without Hat CornedBee's Avatar
    Join Date
    Apr 2003
    Posts
    8,895
    Dev-C++ is out of date. Don't use it.

    Did you see how it asked if you had added #include "stdafx.h"? That error is pretty obvious.
    Not really - for example, you have to add it above every other include, which is not obvious. Neither is it the least obvious why you need it. The fact is that Visual C++'s default project options are not aimed at the beginner.
    All the buzzt!
    CornedBee

    "There is not now, nor has there ever been, nor will there ever be, any programming language in which it is the least bit difficult to write bad code."
    - Flon's Law

  14. #14
    C++まいる!Cをこわせ!
    Join Date
    Oct 2007
    Location
    Inside my computer
    Posts
    24,654
    Quote Originally Posted by CornedBee View Post
    Not really - for example, you have to add it above every other include, which is not obvious. Neither is it the least obvious why you need it. The fact is that Visual C++'s default project options are not aimed at the beginner.
    Yes, those two are not that obvious, but that you need it is obvious.
    The lesson I tried to teach is to always read and listen to the error messages!
    Quote Originally Posted by Adak View Post
    io.h certainly IS included in some modern compilers. It is no longer part of the standard for C, but it is nevertheless, included in the very latest Pelles C versions.
    Quote Originally Posted by Salem View Post
    You mean it's included as a crutch to help ancient programmers limp along without them having to relearn too much.

    Outside of your DOS world, your header file is meaningless.

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. iterator issues
    By Elkvis in forum C++ Programming
    Replies: 10
    Last Post: 02-05-2009, 09:52 PM
  2. windows linux compatibility issues
    By svaidya in forum C++ Programming
    Replies: 3
    Last Post: 08-26-2007, 04:57 PM
  3. Memmory Issues and Threads
    By ddod in forum Windows Programming
    Replies: 2
    Last Post: 08-13-2004, 10:30 AM
  4. hexdump issues
    By daluu in forum C Programming
    Replies: 2
    Last Post: 03-04-2003, 09:01 PM
  5. so confused and frustrated
    By ct26torr in forum C Programming
    Replies: 2
    Last Post: 02-13-2003, 10:40 PM