|
|
#1 |
|
:( complete programming noob! (C++)
Hey guys,
Well from what you can see in the title I am completely new to C++ programming. I have just started it in college and am really enjoying it. However I wanted to set up all the software on my MBP so that I could work on it. In college we write the code on a program called Smultron, save it as a .cpp file and then go to terminal to run it. Now here comes my problem.... I have downloaded Smultron for my laptop and I have written a quick "ºC -> ºF conversion program". When I try to set that up in Terminal by using the command that we were told to use ("make program1") I get this error message in return... "make: *** No rule to make target `practical1'. Stop." This error doesn't come up in college. What I get in college is something like "g++ ........." and then I put in something like "./practical1" As I have said before I want to try and work on my programming at home so I would love for some of your help. Don't forget that I am a complete noob so try and keep it simple! We all start somewhere!
|
|
|
|
0
|
|
|
#2 |
|
make requires a Makefile to work. I suggest you copy the one from college.
__________________
Sponsor me to cycle 100Km round London in the dark |
|
|
|
0
|
|
|
#3 | |
|
Quote:
Code:
g++ practice1.cpp -o practice1 You usually need the "make" command when you want to compile a big program composed of many separately-compiled functions. Last edited by Bill McEnaney; Jan 20, 2011 at 07:01 AM. |
||
|
|
0
|
|
|
#4 |
|
|
0
|
|
|
#5 |
|
It'll be a file called "Makefile". Normally it'd be in the same directory as the code, but depending on their setup it could be anywhere. I'd ask your lecturer.
Or, as suggested above, do without it.
__________________
Sponsor me to cycle 100Km round London in the dark |
|
|
|
0
|
|
|
#6 |
|
How to make a makefile
http://www.eng.hawaii.edu/Tutor/Make/
You can just make your own makefile. If you are going to be doing more command-line programming, it would be a good idea to learn how to do so anyway. |
|
|
|
0
|
|
|
#7 | |
|
Quote:
|
||
|
|
0
|
|
|
#8 |
|
Ok and say I go in and get it to a usb where is the best place to store it and how do I set it up?
|
|
|
|
0
|
|
|
#9 |
|
First things first.
Do you have gcc/g++ installed on your Mac? The easiest way to get it is to install the Developer Tools (including Xcode) from the Optional Installs disc shipped with your Mac. B
__________________
MBA (13" 1.7 GHz 128GB), UMBP (15" SD 2.8 GHz), UMB (13" 2.4 GHz), iMac (17" Yonah), 32GB iPad 3 WiFi+LTE, 64 GB iPad WiFi, 32 GB iPhone 5, Airport Extreme |
|
|
|
0
|
|
|
#10 |
|
make will automatically look for a file called Makefile in the cwd. In all honesty instead of expecting to be spoon-fed every minor you should be doing your own research when pointed in the right direction. Before even asking the question at the top of this thread you should have read the manpage for make which would have told you the answer. Any programmer worth anything relies on being able to use the documentation for the tools, languages and APIs. Start building this critical core skill early.
__________________
Sponsor me to cycle 100Km round London in the dark |
|
|
|
0
|
|
|
#11 |
|
Ah the joy of IDEs and editors that hide the inner workings from you. (There was a recent thread that had some resources to cure you of this, will link here). EDIT: http://forums.macrumors.com/showthread.php?t=1078777 read lee1210's posts #4 and #13 in particular.
Another issue here is that at school it sounds like Smultron is calling g++, while it is trying to call make at home. EDIT: This may be a configuration issue with Smultron or just the fact that g++ is missing. Make sure you can get the instructions in lee1210's post #4 linked above to work. B
__________________
MBA (13" 1.7 GHz 128GB), UMBP (15" SD 2.8 GHz), UMB (13" 2.4 GHz), iMac (17" Yonah), 32GB iPad 3 WiFi+LTE, 64 GB iPad WiFi, 32 GB iPhone 5, Airport Extreme Last edited by balamw; Jan 20, 2011 at 08:07 AM. |
|
|
|
0
|
|
|
#12 |
|
Make doesn't always require a makefile. It has built-in rules (implicit rules) for making simple targets.
If I go to a directory that contains a file "handy.cpp" and I type: Code:
make handy Code:
g++ handy.cpp -o handy Code:
make -d handy |
|
|
|
0
|
|
|
#13 |
|
|
0
|
|
|
#14 |
|
Comes with. If you installed Xcode with the default settings, you have g++.
B
__________________
MBA (13" 1.7 GHz 128GB), UMBP (15" SD 2.8 GHz), UMB (13" 2.4 GHz), iMac (17" Yonah), 32GB iPad 3 WiFi+LTE, 64 GB iPad WiFi, 32 GB iPhone 5, Airport Extreme |
|
|
|
0
|
|
|
#15 |
|
|
0
|
|
|
#16 |
|
[QUOTE=chown33;11760143]
it will run the command: Code:
g++ handy.cpp -o handy "i686-apple-darwin10-g++-4.2.1: practical1.cpp: No such file or directory i686-apple-darwin10-g++-4.2.1: no input files" |
|
|
|
0
|
|
|
#17 |
|
|
0
|
|
|
#18 |
|
Are you in the folder where practical1.cpp is located? Did you spell it right etc?
Edit: The error message you get is from g++, the complaint is that g++ can't find the file practical.cpp in the current folder. |
|
|
|
0
|
|
|
#19 | |
|
Quote:
echo "#include <stdio.h> int main(int argc, char *argv[]) { printf(\"Hello, World.\\n\"); return 0; }" > myHello.c gcc myHello.c ./a.out ... to terminal and it worked so what should I do next? |
||
|
|
0
|
|
|
#20 |
|
I have the practical1.cpp file on my desktop and I am trying to use terminal to run it... That is how we were shown to do it in the lecture. We were told to go into terminal and type "make practical1" and then "./practical1"
|
|
|
|
0
|
|
|
#21 | |
|
Quote:
try this: Code:
cat > hello.cpp << eof
> #include <iostream>
>
> int main()
> {
> std::cout << "Hello, world\n";
> return 0;
> }
type: g++ hello.cpp -o hello then: ./hello There, your first c++ program. |
||
|
|
0
|
|
|
#22 |
|
Well that's neat... you learn something new every day...
__________________
Mooooooooooooo
|
|
|
|
0
|
|
|
#23 | ||
|
Quote:
Code:
pwd; ls -l I wonder about the accuracy of your posts. For example, in your original post you wrote: Quote:
You can copy from the Terminal window and paste into posts. You can also copy from other windows and paste into Terminal. I suggest that you edit command-lines in a text editor, then copy and paste them into Terminal. When something doesn't work, copy and paste the entire command-line and its output into a post. |
|||
|
|
0
|
|
|
#24 | |
|
Great. We know for sure you have a compiler now.
Quote:
If you need to substitute Code:
g++ -o practical1 practical1.cpp Code:
make practical1
__________________
MBA (13" 1.7 GHz 128GB), UMBP (15" SD 2.8 GHz), UMB (13" 2.4 GHz), iMac (17" Yonah), 32GB iPad 3 WiFi+LTE, 64 GB iPad WiFi, 32 GB iPhone 5, Airport Extreme |
||
|
|
0
|
|
|
#25 | |
|
Quote:
Code:
Gavin-McGuinnesss-MacBook-Pro:~ Gav$ make practical1 make: *** No rule to make target `practical1'. Stop. Gavin-McGuinnesss-MacBook-Pro:~ Gav$ g++ -o practical1 practical1.cpp i686-apple-darwin10-g++-4.2.1: practical1.cpp: No such file or directory i686-apple-darwin10-g++-4.2.1: no input files Gavin-McGuinnesss-MacBook-Pro:~ Gav$ |
||
|
|
0
|
![]() |
|
«
Previous Thread
|
Next Thread
»
| Thread Tools | Search this Thread |
| Display Modes | |
|
|
Similar Threads
|
||||
| thread | Thread Starter | Forum | Replies | Last Post |
| Help With Structures and Classes (C++) | ghall | Mac Programming | 13 | Dec 13, 2007 03:49 PM |
| what's wrong?! (c++) | chris200x9 | Mac Programming | 3 | Oct 31, 2007 07:59 PM |
| Computer Science class (C++) | svail11 | Mac Programming | 5 | Sep 24, 2006 05:53 PM |
| How do you use strings (c++) with xCode | rgwebb | Mac Programming | 2 | Nov 28, 2005 10:29 AM |
| Coding conundrum (C++) | GeeYouEye | Mac Help/Tips | 2 | May 17, 2003 01:48 AM |
All times are GMT -5. The time now is 03:21 AM.








Mooooooooooooo
Linear Mode

