Complie / cmd

This is a discussion on Complie / cmd within the Tech Board forums, part of the Community Boards category; im not sure if this should be under C++ but its not really C++ i have Visual C++ Express If ...

  1. #1
    Registered User
    Join Date
    Jun 2007
    Location
    UK
    Posts
    22

    Question Complie / cmd

    im not sure if this should be under C++ but its not really C++


    i have Visual C++ Express

    If i wrote some code a txt file and saved it as test.cpp for example

    how could i compile it though the console?

  2. #2
    Cat without Hat CornedBee's Avatar
    Join Date
    Apr 2003
    Posts
    8,893
    You would call cl.exe from VC++'s bin directory. In addition, you should set some environment variables. The bin directory should also contain a batch file that sets these variables.

    You made the right choice of forum. Questions about the usage of a particular compiler belong to tech.
    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

  3. #3
    Registered User
    Join Date
    Jun 2007
    Location
    UK
    Posts
    22
    sorry,
    can u tell me how i would complie a file on my desktop

  4. #4
    Cat without Hat CornedBee's Avatar
    Join Date
    Apr 2003
    Posts
    8,893
    You would open a console, navigate to your desktop folder (typically C:\Documents and Settings\username\Desktop), and follow the steps above.
    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

  5. #5
    Registered User
    Join Date
    Jun 2007
    Location
    UK
    Posts
    22
    ahh i found it

    C:\Program Files\Microsoft Visual Studio 8\VC\bin

    its cl.exe

    BUT

    "This application has failed to start because mspdb80.dll was not found re-installing the application may fix this problem"

    i gues i need to reinstall
    Last edited by DDAZZA; 06-10-2007 at 08:21 AM. Reason: added exe location

  6. #6
    Cat without Hat CornedBee's Avatar
    Join Date
    Apr 2003
    Posts
    8,893
    How did you call it?

    Is there a vcvars32.bat (or similar) in this bin directory, too? If so, try calling that before cl.exe.
    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

  7. #7
    Registered User
    Join Date
    Jun 2007
    Location
    UK
    Posts
    22
    via the console

    ye there is a vcvars32.bat

    when i run that first

    the console returns
    Code:
    usage: cl [option...] filename...[\link linkoption...]
    what is the option and is the filename the path of the C/CPP file?

  8. #8
    Cat without Hat CornedBee's Avatar
    Join Date
    Apr 2003
    Posts
    8,893
    Option can be many things. Pass /help and you should get a list.

    And yes, filename is the path of the code file.
    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

  9. #9
    Registered User
    Join Date
    Jun 2007
    Location
    UK
    Posts
    22
    OMG there is a lot of options

    ok i think im getting the syntax wrong


    im putting

    Code:
    cl C:/documents and settings/me/desktop/test.cpp

    i get the error:
    unreconised source file

    because documents and settings needs the spaces replacing what do i replace them with ?

  10. #10
    Deathray Engineer MacGyver's Avatar
    Join Date
    Mar 2007
    Posts
    3,211
    Put quotes around the path and filename.

  11. #11
    Registered User
    Join Date
    Jun 2007
    Location
    UK
    Posts
    22
    ok ty

    i now get the error:
    Code:
    Cannot open file test.obj: permission denied
    erm im new to programming

    do i need to make a test.obj file wat is it?
    do i need to compile with an option to exclude the test.obj file?

  12. #12
    Cat without Hat CornedBee's Avatar
    Join Date
    Apr 2003
    Posts
    8,893
    The .obj file is an intermediate file the compiler generates. The error means that whatever directory it tries to create it in (the VC++ bin directory, I would guess), it doesn't have write access there.

    The solution is to change the working directory to where your source files are and call the compiler from there. If you've run vcvars32.bat, it should be in the PATH so "cl" should work everywhere.
    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

  13. #13
    CSharpener vart's Avatar
    Join Date
    Oct 2006
    Location
    Rishon LeZion, Israel
    Posts
    6,473
    And why so many trouble just to not compile in the IDE?.. Just curios.
    The first 90% of a project takes 90% of the time,
    the last 10% takes the other 90% of the time.

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Replies: 23
    Last Post: 04-20-2009, 07:35 AM
  2. OOP Question DB Access Wrapper Classes
    By digioz in forum C# Programming
    Replies: 2
    Last Post: 09-07-2008, 04:30 PM
  3. Error running program in cmd - cygwin.dll missing -
    By JFonseka in forum C Programming
    Replies: 5
    Last Post: 08-27-2007, 12:12 PM
  4. Converting cmd arg to int
    By InstaDeath in forum C++ Programming
    Replies: 5
    Last Post: 03-17-2004, 08:45 PM
  5. Little help with CMD
    By robid1 in forum C Programming
    Replies: 2
    Last Post: 02-23-2003, 03:09 AM

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