Page 2 of 2 FirstFirst
1
2
  1. #21
    If you are using Microsoft Visual Studio and clicked empty project to create this, try the following:

    Project (Menu) -> Properties

    Click the + next to Configuration Properties
    Click the + next to Linker
    Click System
    And on the right hand side set the SubSystem to Console (/SUBSYSTEM:CONSOLE)

  2. #22
    Deleted
    Quote Originally Posted by Cactrot View Post
    Navigate to the folder, and type "cl helloworld.cpp".
    "cl is not an intern commando, extern commando, program or commandofile."

  3. #23
    Quote Originally Posted by Tomatketchup View Post
    "cl is not an intern commando, extern commando, program or commandofile."
    You did it from the visual studio command prompt? Not a regular one?
    You are using visual studio, yea?

  4. #24
    Deleted
    Quote Originally Posted by Cactrot View Post
    You did it from the visual studio command prompt? Not a regular one?
    You are using visual studio, yea?
    When I tried to do it in Visual Studio it gave me an error.

    Visual Studio command prompt is the console window you get when pressing F5, right?

    (this feels quite horrible...)

  5. #25
    Quote Originally Posted by Tomatketchup View Post
    When I tried to do it in Visual Studio it gave me an error.

    Visual Studio command prompt is the console window you get when pressing F5, right?

    (this feels quite horrible...)
    So what are you using to compile?
    No, I don't think it's given by F5. At least, when I just pressed F5 it didn't open one. I think that's "rebuild" or something, which does stuff you don't need yet. What are you using, exactly? If you're using VS 2008, under "tools" there is a "Visual Studio 2008 command prompt" you can click, it opens up a terminal like windows+r, cmd does, but with a few important differences hidden from you.

    On my install, going start menu -> all programs -> Microsoft Visual C++ 2008 Express Edition -> Visual Studio tools -> Visual Studio 2008 Command Prompt also works.
    Last edited by Cactrot; 2011-11-08 at 09:30 PM.

  6. #26
    Deleted
    Oh, alright. Well, I typed in cl helloworld.cpp and got this:
    Code:
    Microsoft (R) 32-bit C/C++ Optimizing Compiler Version 16.00.30319.01 for 80x86
    Copyright (C) Microsoft Corporation. All rights reserved.
    
    helloworld.cpp
    C:\Program Files\Microsoft Visual Studio 10.0\VC\INCLUDE\xlocale(323) : warning
    C4530: C++ exception handler used, but unwind semantics are not enabled. Specify
     /EHsc
    c:\Program Files\helloworld.cpp : fatal error C1083: Cannot open compiler generated file: 'helloworld.obj': Permission denied
    ...I guess I didn't put it in the right folder?

  7. #27
    Quote Originally Posted by Tomatketchup View Post
    Oh, alright. Well, I typed in cl helloworld.cpp and got this:
    Code:
    Microsoft (R) 32-bit C/C++ Optimizing Compiler Version 16.00.30319.01 for 80x86
    Copyright (C) Microsoft Corporation. All rights reserved.
    
    helloworld.cpp
    C:\Program Files\Microsoft Visual Studio 10.0\VC\INCLUDE\xlocale(323) : warning
    C4530: C++ exception handler used, but unwind semantics are not enabled. Specify
     /EHsc
    c:\Program Files\helloworld.cpp : fatal error C1083: Cannot open compiler generated file: 'helloworld.obj': Permission denied
    ...I guess I didn't put it in the right folder?
    0_o, permission denied? That's weird... Try moving it out of Program Files, into mydocuments or something. Perhaps your computer is set to not let you play around with files in program files much. You probably shouldn't be putting stuff in there anyway.

  8. #28
    Deleted
    Ah, alright, got it fixed now. Yes, it works fine in commando prompt. Still, I would love if I didn't have to do this with every single console code.

  9. #29
    For what you are doing now std::cout is kinda overkill but it should learn you how to use your own namespace when you need it.
    Also to see your output try reading something after cout or put getchar(); (should be something like that the function). Blame windows not the book for that, although they could have mention it somewhere to avoid things like this.

  10. #30
    I'd say try changing the Linker Subsystem to that of a console (see my post above) and try rebuilding and running it without using the command prompt and see if that works.

  11. #31
    Deleted
    Quote Originally Posted by Zircrom View Post
    If you are using Microsoft Visual Studio and clicked empty project to create this, try the following:

    Project (Menu) -> Properties

    Click the + next to Configuration Properties
    Click the + next to Linker
    Click System
    And on the right hand side set the SubSystem to Console (/SUBSYSTEM:CONSOLE)
    Already had it like that since before.

  12. #32
    Ah well, was worth a try. I've had to change that for quite a number of projects I did years ago so that's the only thing I could think of.

  13. #33
    Deleted
    Bump. Noone knows how to fix this?

  14. #34
    Quote Originally Posted by Tomatketchup View Post
    Bump. Noone knows how to fix this?
    Mk, sorry, was in a meeting. So it works from command line, but not when you build from the GUI?
    You could try making a new project from source, using an external build system, and make "cl source.cpp" the build command...

    What exactly isn't working still?

  15. #35
    Deleted
    Quote Originally Posted by Cactrot View Post
    You could try making a new project from source, using an external build system, and make "cl source.cpp" the build command...
    Uhm, how do I do this? :<

  16. #36
    Epic! Pejo's Avatar
    10+ Year Old Account
    Join Date
    Mar 2011
    Location
    C eh N eh D eh
    Posts
    1,555
    All looks fine from what I can see. When you compile your program in Visual Studio, try running it using CTRL+F5 instead of just f5. This will run it in Debug mode which will add a Pause after the output so you'll be able to see it saying _______.

  17. #37
    Quote Originally Posted by Tomatketchup View Post
    Uhm, how do I do this? :<
    File, new project from existing source, point it at the .cpp i told you to make earlier, make it a visual c++ project. Umm, can't remember from there at the moment, but where it has an option to select external build system you can try that, and then just leave everything but the build command blank and put in what I just said for the build command. I'm not positive it'll even work. Meetings and lunch though, so I can't look at the moment. Sorry =(

  18. #38
    Deleted
    Quote Originally Posted by Cactrot View Post
    File, new project from existing source, point it at the .cpp i told you to make earlier, make it a visual c++ project. Umm, can't remember from there at the moment, but where it has an option to select external build system you can try that, and then just leave everything but the build command blank and put in what I just said for the build command. I'm not positive it'll even work. Meetings and lunch though, so I can't look at the moment. Sorry =(
    Meh, gonna go to bed anyway. :P Thanks for the help, I'll try more tomorrow.

  19. #39
    I use to use notepad to write C++ code and I would have the console close on me upon launch. I just put in 'cin.ignore(); cin.get();' before return 0 and it fixed my problems, try that and see how it goes.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •