Welcome guest. Before posting on our computer help forum, you must register. Click here it's easy and free.

Author Topic: Help! Can't get Microsoft Visual 2008 compiler to work!!!  (Read 5823 times)

0 Members and 1 Guest are viewing this topic.

Zac

    Topic Starter


    Rookie

  • Iron Man
    Help! Can't get Microsoft Visual 2008 compiler to work!!!
    « on: March 08, 2010, 05:02:28 AM »
    I hope I've come to the right category... Anyway, I installed borland, changed my environmental variables, then I uninstalled it, and installed Microsoft Visual 2008 C++. I like its writing program, I just can't get it to compile. The problem is, when I open its command-line window (the one that comes along with it), this is what it says.

    '"vsvars32.bat"' is not recognized as an internal or external command,
    operable program or batch file.

    C:\Program Files\Microsoft Visual Studio 9.0\VC>

    But vsvars32.bat isn't even what it is called. it is called "vcvarsall.bat"
    and when I try to change its name to that which the command prompt is looking for, it always looks for something else. So that is my problem, I can't compile anything until I have that batch file executed in the command line window. Is it because I havn't changed my Environmental variables from ";C:\BORLAND\BCC55\BIN;" to something else? (I forgot what they were before). My computer is a Gateway -M series laptop, I run 32bit, windows vista. If I forgot any more important info about my system, just let me know. (BTW I am a newbe, and I was just trying to compile a sample ;)
    Zac

    BC_Programmer


      Mastermind
    • Typing is no substitute for thinking.
    • Thanked: 1140
      • Yes
      • Yes
      • BC-Programming.com
    • Certifications: List
    • Computer: Specs
    • Experience: Beginner
    • OS: Windows 11
    Re: Help! Can't get Microsoft Visual 2008 compiler to work!!!
    « Reply #1 on: March 08, 2010, 05:42:22 AM »
    vcvars32.bat is in %program files%\Microsoft Visual Studio 9.0\VC\BIN for me, VIsual studio 2008 Professional. vcvarsall.bat is in %program files%\Microsoft Visual Studio 9.0\VC\.

    you probably need to add the "bin" directory to your path.

    I was trying to dereference Null Pointers before it was cool.

    Zac

      Topic Starter


      Rookie

    • Iron Man
      Re: Help! Can't get Microsoft Visual 2008 compiler to work!!!
      « Reply #2 on: March 08, 2010, 06:01:41 AM »
      After I changed my directory to /bin, It fixed the .bat problem, but it says it couldn't find my .cpp I made this is what it says

      Setting environment for using Microsoft Visual Studio 2008 x86 tools.

      C:\Program Files\Microsoft Visual Studio 9.0\VC>cl samplee.cpp
      Microsoft (R) 32-bit C/C++ Optimizing Compiler Version 15.00.30729.01 for 80x86
      Copyright (C) Microsoft Corporation.  All rights reserved.

      samplee.cpp
      c1xx : fatal error C1083: Cannot open source file: 'samplee.cpp': No such file o
      r directory

      C:\Program Files\Microsoft Visual Studio 9.0\VC>


      I opened a project called "samplee.cpp" in a new file (as you see)

      Setting environment for using Microsoft Visual Studio 2008 x86 tools.

      C:\Program Files\Microsoft Visual Studio 9.0\VC>cl samplee.cpp
      Microsoft (R) 32-bit C/C++ Optimizing Compiler Version 15.00.30729.01 for 80x86
      Copyright (C) Microsoft Corporation.  All rights reserved.

      samplee.cpp
      c1xx : fatal error C1083: Cannot open source file: 'samplee.cpp': No such file o
      r directory

      C:\Program Files\Microsoft Visual Studio 9.0\VC>cd bin

      C:\Program Files\Microsoft Visual Studio 9.0\VC\bin>cl -GX samplee.cpp
      Microsoft (R) 32-bit C/C++ Optimizing Compiler Version 15.00.30729.01 for 80x86
      Copyright (C) Microsoft Corporation.  All rights reserved.

      cl : Command line warning D9035 : option 'GX' has been deprecated and will be re
      moved in a future release
      cl : Command line warning D9036 : use 'EHsc' instead of 'GX'
      samplee.cpp
      c1xx : fatal error C1083: Cannot open source file: 'samplee.cpp': No such file o
      r directory

      C:\Program Files\Microsoft Visual Studio 9.0\VC\bin>

      So it says the same thing in both directories. BTW what is "EHsc"? my guide told me to run it -GX :-\
      Zac

      BC_Programmer


        Mastermind
      • Typing is no substitute for thinking.
      • Thanked: 1140
        • Yes
        • Yes
        • BC-Programming.com
      • Certifications: List
      • Computer: Specs
      • Experience: Beginner
      • OS: Windows 11
      Re: Help! Can't get Microsoft Visual 2008 compiler to work!!!
      « Reply #3 on: March 08, 2010, 06:38:12 AM »
      where is "samplee.cpp"? I'm guessing it's not in either "C:\Program Files\Microsoft Visual Studio 9.0\VC" or in "
      C:\Program Files\Microsoft Visual Studio 9.0\VC\bin" folders, which is causing your problem.

      If you can run the batch, that set's your path. but you need to be in the directory containing your cpp file to compile it- and the output will not be an EXE, but rather an "OBJ" file (if memory serves), you will then need to use link to link the obj into a executable.

      I was trying to dereference Null Pointers before it was cool.

      Zac

        Topic Starter


        Rookie

      • Iron Man
        Re: Help! Can't get Microsoft Visual 2008 compiler to work!!!
        « Reply #4 on: March 08, 2010, 07:01:58 AM »
        Thanks!!! I changed my directory to that which the file was located, and it worked! :D
        where is "samplee.cpp"? I'm guessing it's not in either "C:\Program Files\Microsoft Visual Studio 9.0\VC" or in "
        C:\Program Files\Microsoft Visual Studio 9.0\VC\bin" folders, which is causing your problem.

        If you can run the batch, that set's your path. but you need to be in the directory containing your cpp file to compile it- and the output will not be an EXE, but rather an "OBJ" file (if memory serves), you will then need to use link to link the obj into a executable.


        It did say its output was obj, but when I looked at its properties, it said it was a application(exe). Will you breifly explain "link to link the obj" thanks

        Zac
        Zac

        BC_Programmer


          Mastermind
        • Typing is no substitute for thinking.
        • Thanked: 1140
          • Yes
          • Yes
          • BC-Programming.com
        • Certifications: List
        • Computer: Specs
        • Experience: Beginner
        • OS: Windows 11
        Re: Help! Can't get Microsoft Visual 2008 compiler to work!!!
        « Reply #5 on: March 08, 2010, 07:17:54 AM »
        well, I just checked myself, seems that cl now automatically links the file using Link, whereas one used to need to do that manually.

        anyway, each module you compile becomes an object file- this is basically executable code, but all the external calls are sort of stubbed out and need "fixed". for example, the C run-time is compiled to a "lib" file. In order to compile an application that uses the C run-time in this fashion, all the calls to the C-run-time need to be "hooked up" to the appropriate entry points.

        When you link, what you are doing is placing the various statis libraries- such as the C run-time and your different modules, into a single executable file. the linker properly fixes up the external calls from each module to each other module.

        In fact, the c/C++-run-time is the module that contains the startup code that is originally called, and it externally links to your main() function.

        All C/C++ programs, (unless you compile and link with special switches) will have their entry point in some sort of run-time code, which eventually calls your actual main() routine.
        I was trying to dereference Null Pointers before it was cool.

        Zac

          Topic Starter


          Rookie

        • Iron Man
          Re: Help! Can't get Microsoft Visual 2008 compiler to work!!!
          « Reply #6 on: March 08, 2010, 10:05:01 AM »
          Thanks! I understand now.
          Zac