Problems compiling a c++ program with commandline version of vc++.net

This is a discussion on Problems compiling a c++ program with commandline version of vc++.net within the C++ Programming forums, part of the General Programming Boards category; Hello World c++ program not compiling with commandline version of vc++.net from .net sdk. Why? Code: #include <iostream> int main() ...

  1. #1
    Registered User
    Join Date
    Dec 2003
    Posts
    167

    Problems compiling a c++ program with commandline version of vc++.net

    Hello World c++ program not compiling with commandline version of vc++.net from .net sdk. Why?

    Code:
     
    #include <iostream>
    
    int main()
    {
        std::cout << "Hello World" << std::endl; 
        return 0;
    }
    I've had success compiling a c program and the HelloVc.cpp demo.
    silk.odyssey

  2. #2
    Registered User
    Join Date
    Sep 2003
    Posts
    135
    What error do you get?

  3. #3
    Registered User
    Join Date
    Dec 2003
    Posts
    167
    Unable to include iostream or something like that. I checked the include folder and it seems it only has C header files.
    silk.odyssey

  4. #4
    and the hat of wrongness Salem's Avatar
    Join Date
    Aug 2001
    Location
    The edge of the known universe
    Posts
    32,337
    Did you run the vcsetvars.bat file which is in the vc7\bin directory?
    It sets up a number of environment variables
    If you dance barefoot on the broken glass of undefined behaviour, you've got to expect the occasional cut.
    If at first you don't succeed, try writing your phone number on the exam paper.
    I support http://www.ukip.org/ as the first necessary step to a free Europe.

  5. #5
    Registered User
    Join Date
    Dec 2003
    Posts
    167
    There are no batch files in my vc7\bin directory. Maybe I should try downloading the sdk again?
    silk.odyssey

  6. #6
    and the hat of wrongness Salem's Avatar
    Join Date
    Aug 2001
    Location
    The edge of the known universe
    Posts
    32,337
    Well somewhere in the compiler installation directory structure there is a batch file which sets variables.
    Try searching for it
    If you dance barefoot on the broken glass of undefined behaviour, you've got to expect the occasional cut.
    If at first you don't succeed, try writing your phone number on the exam paper.
    I support http://www.ukip.org/ as the first necessary step to a free Europe.

  7. #7
    Registered User
    Join Date
    Dec 2003
    Posts
    167
    I found sdkvars.bat. Now I can compile some of the samples with the other compilers. I still can't compile the example I posted earlier. I get the same error message about not being able to find the iostream header file. This is not surprising because I checked the include folder for vc and it only has c header files.
    silk.odyssey

  8. #8
    Yes, my avatar is stolen anonytmouse's Avatar
    Join Date
    Dec 2002
    Posts
    2,544
    Unfortunately, the free C/C++ compiler included with the .net framework does not include the stl and is therefore only useable as a C compiler. Assumably, one can use StlPort or something like it, but I haven't tried it.

    When you get around to compiling Windows programs(you need the platform sdk), here is the batch file I use.

    Code:
    call C:\Progra~1\Microsoft.NET\SDK\v1.1\Bin\sdkvars
    SET INCLUDE=%INCLUDE%;C:\Program Files\Microsoft SDK\Include
    SET LIB=%LIB%;C:\Program Files\Microsoft SDK\Lib
    cls
    
    cl /W3 file1.c file2.c KERNEL32.LIB USER32.LIB GDI32.LIB ADVAPI32.LIB COMCTL32.LIB

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Problem building Quake source
    By Silvercord in forum Game Programming
    Replies: 16
    Last Post: 07-11-2010, 09:13 AM
  2. Blackjack program, having problems with the ace
    By yigster in forum C Programming
    Replies: 6
    Last Post: 05-07-2009, 06:41 AM
  3. fopen();
    By GanglyLamb in forum C Programming
    Replies: 8
    Last Post: 11-03-2002, 11:39 AM
  4. C++ console program using Ms Visual Studio .NET
    By matheo917 in forum C++ Programming
    Replies: 4
    Last Post: 09-05-2002, 11:16 PM
  5. C++ and Program Version Naming
    By kuphryn in forum C++ Programming
    Replies: 2
    Last Post: 11-27-2001, 10:19 AM

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21