C Board  

Go Back   C Board > Community Boards > Tech Board

Reply
 
LinkBack Thread Tools Display Modes
Old 06-10-2007, 03:17 AM   #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?
DDAZZA is offline   Reply With Quote
Old 06-10-2007, 05:38 AM   #2
Cat without Hat
 
CornedBee's Avatar
 
Join Date: Apr 2003
Posts: 8,492
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
CornedBee is offline   Reply With Quote
Old 06-10-2007, 06:34 AM   #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
DDAZZA is offline   Reply With Quote
Old 06-10-2007, 06:41 AM   #4
Cat without Hat
 
CornedBee's Avatar
 
Join Date: Apr 2003
Posts: 8,492
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
CornedBee is offline   Reply With Quote
Old 06-10-2007, 08:14 AM   #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
DDAZZA is offline   Reply With Quote
Old 06-10-2007, 10:42 AM   #6
Cat without Hat
 
CornedBee's Avatar
 
Join Date: Apr 2003
Posts: 8,492
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
CornedBee is offline   Reply With Quote
Old 06-10-2007, 01:39 PM   #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?
DDAZZA is offline   Reply With Quote
Old 06-10-2007, 02:05 PM   #8
Cat without Hat
 
CornedBee's Avatar
 
Join Date: Apr 2003
Posts: 8,492
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
CornedBee is offline   Reply With Quote
Old 06-11-2007, 12:31 PM   #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 ?
DDAZZA is offline   Reply With Quote
Old 06-11-2007, 12:32 PM   #10
Deathray Engineer
 
MacGyver's Avatar
 
Join Date: Mar 2007
Posts: 3,211
Put quotes around the path and filename.
__________________
MacGyver is offline   Reply With Quote
Old 06-11-2007, 12:42 PM   #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?
DDAZZA is offline   Reply With Quote
Old 06-11-2007, 02:19 PM   #12
Cat without Hat
 
CornedBee's Avatar
 
Join Date: Apr 2003
Posts: 8,492
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
CornedBee is offline   Reply With Quote
Old 06-11-2007, 09:42 PM   #13
CSharpener
 
vart's Avatar
 
Join Date: Oct 2006
Posts: 5,334
And why so many trouble just to not compile in the IDE?.. Just curios.
__________________
If I have eight hours for cutting wood, I spend six sharpening my axe.
vart is offline   Reply With Quote
Reply

Thread Tools
Display Modes

Forum Jump

Similar Threads
Thread Thread Starter Forum Replies Last Post
C window code - How easy is it to intergrate cmd code spadez C Programming 23 04-20-2009 07:35 AM
OOP Question DB Access Wrapper Classes digioz C# Programming 2 09-07-2008 04:30 PM
Error running program in cmd - cygwin.dll missing - JFonseka C Programming 5 08-27-2007 12:12 PM
Converting cmd arg to int InstaDeath C++ Programming 5 03-17-2004 09:45 PM
Little help with CMD robid1 C Programming 2 02-23-2003 04:09 AM


All times are GMT -6. The time now is 03:20 AM.


Powered by vBulletin® Version 3.8.1
Copyright ©2000 - 2010, Jelsoft Enterprises Ltd.
Search Engine Optimization by vBSEO 3.3.2

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