Thread: compiling and executing file problem

  1. #1
    Registered User
    Join Date
    Dec 2010
    Posts
    29

    compiling and executing file problem

    hello,
    i am using visual studio 2010.
    i have been given two files by my teacher. he asked us to compile, execute and see what the result would be.
    i have to use cl -D_CRT_SECURE_NO_DEPRECATE *.cpp
    but then when i go the project via command window and execute the command it says:
    'cl' is not recognized as an internal or external command, operable program or file batch.
    if you want i will post both the files but any idea to what i could be doing wrong?

  2. #2
    Registered User
    Join Date
    Sep 2006
    Posts
    8,868
    Have you tried "cls" instead of "cl" ?

    That's the only console command for Windows that begins with "cl", and since the program obviously works with CRT commands, it fits right in.

  3. #3
    Registered User
    Join Date
    Dec 2010
    Posts
    29

    thank you

    i didn't get error message after changing cl to cls.

  4. #4
    C++ Witch laserlight's Avatar
    Join Date
    Oct 2003
    Location
    Singapore
    Posts
    28,413
    I haven't had cause to use the command line when compiling with a Microsoft compiler in quite some time, but cl should be correct. cls should clear the screen instead.

    You should either use the command prompt from within Visual Studio, or add the directory containing cl to the system path.

    By the way, this is the C programming forum. You might ask a C++ specific question next, in which case it should go to that forum.
    Quote Originally Posted by Bjarne Stroustrup (2000-10-14)
    I get maybe two dozen requests for help with some sort of programming or design problem every day. Most have more sense than to send me hundreds of lines of code. If they do, I ask them to find the smallest example that exhibits the problem and send me that. Mostly, they then find the error themselves. "Finding the smallest program that demonstrates the error" is a powerful debugging tool.
    Look up a C++ Reference and learn How To Ask Questions The Smart Way

  5. #5
    Registered User
    Join Date
    Dec 2010
    Posts
    29
    By the way, this is the C programming forum. You might ask a C++ specific question next, in which case it should go to that forum.
    actually the files are written in c language but ya i get your point.
    if you could please tell me how to add the path i would appreciate it ( on the command prompt, i am already inside the directory containing both the necessary files).
    supposedly after the cl command is executed, an "exe" file should be generated.
    Last edited by ilikeapplepie; 04-03-2011 at 09:57 PM. Reason: additional details

  6. #6
    C++ Witch laserlight's Avatar
    Join Date
    Oct 2003
    Location
    Singapore
    Posts
    28,413
    Quote Originally Posted by ilikeapplepie
    actually the files are written in c language
    Then change the file extension to .c

    Quote Originally Posted by ilikeapplepie
    if you could please tell me how to add the path i would appreciate it.
    Heheh, I cannot resist: instructions
    Quote Originally Posted by Bjarne Stroustrup (2000-10-14)
    I get maybe two dozen requests for help with some sort of programming or design problem every day. Most have more sense than to send me hundreds of lines of code. If they do, I ask them to find the smallest example that exhibits the problem and send me that. Mostly, they then find the error themselves. "Finding the smallest program that demonstrates the error" is a powerful debugging tool.
    Look up a C++ Reference and learn How To Ask Questions The Smart Way

  7. #7
    Registered User
    Join Date
    Dec 2010
    Posts
    29

    thank you.

    thanks, laserlight.

  8. #8
    C++ Witch laserlight's Avatar
    Join Date
    Oct 2003
    Location
    Singapore
    Posts
    28,413
    Quote Originally Posted by ilikeapplepie
    supposedly after the cl command is executed, an "exe" file should be generated.
    Yes, you will be compiling the source code to an executable program.
    Quote Originally Posted by Bjarne Stroustrup (2000-10-14)
    I get maybe two dozen requests for help with some sort of programming or design problem every day. Most have more sense than to send me hundreds of lines of code. If they do, I ask them to find the smallest example that exhibits the problem and send me that. Mostly, they then find the error themselves. "Finding the smallest program that demonstrates the error" is a powerful debugging tool.
    Look up a C++ Reference and learn How To Ask Questions The Smart Way

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Problem compiling
    By Programmer_P in forum C++ Programming
    Replies: 4
    Last Post: 03-01-2010, 03:43 PM
  2. Switch/case problem with file I/O
    By C++beginer in forum C++ Programming
    Replies: 2
    Last Post: 05-23-2005, 02:56 PM
  3. Project compiling, but not executing correctly
    By sansuki in forum C++ Programming
    Replies: 1
    Last Post: 03-30-2005, 06:40 AM
  4. compiling and executing issue with lcc win32
    By GanglyLamb in forum C Programming
    Replies: 10
    Last Post: 12-22-2004, 02:24 PM
  5. resource file problem
    By jjj93421 in forum Game Programming
    Replies: 6
    Last Post: 03-30-2004, 10:58 PM

Tags for this Thread