| Copy (10) | |||
|
Well, I've followed all the tutorials and it's still not working. I don't know where else to turn cause google isn't helping much. Tried figuring it out myself but couldn't... I did sudo apt-get install building essentials and sudo apt-get install g++ I then proceeded to take a sample program and enter it
I saved it as a .cpp on my desktop Next I proceeded to type g++ HelloWorld.cpp -o HelloWorld I'm getting this error g++: error: HelloWorld.cpp: No such file or directory g++: fatal error: no input files compilation terminated... Anyhelp would be appreciated. Now i've tried letting it know where my file is Desktop/HelloWorld/HelloWorld.cpp -o HelloWorld.o and it just enters the text and gives me a new line to type in. Nothing happened | |||
|
Last edited on
|
|||
| maeriden (339) | |
| Are you calling gcc from your home folder? If so, are you sure HelloWorld.o is not there? | |
|
Last edited on
|
|
| Aramil of Elixia (772) | |
|
no the problem is the directory your in doesnt contain your .cpp file if its on your desktop try this cd ~/Desktop g++ *.cpp -o * | |
|
|
|
| ne555 (4385) | |
|
¿why the last asterisk? it would overwrite files. @OP: *.o are usually used for object files (after compilation stage) | |
|
|
|
| Aramil of Elixia (772) | |
| no it wouldnt its a wild card variable. its how i used to compile for long names. what it would do is with the first * (in the .cpp) it gets the name of the first .cpp file and then * holds the value. then its still in the second * becuase thats being read in as a wild card thats not a file. i could be completely wrong but it would work for me when i was being lazy and it was the only .cpp file in the dir | |
|
|
|
| ne555 (4385) | |||
|
¿What shell do you use? in sh * expands to anything
If you only have 1 cpp then
| |||
|
|
|||
| Aramil of Elixia (772) | |
|
i just use the normal bash shell, but it just does it to the first one. and no your wrong. if i have *.cpp for a file called one.cpp its not going to expand to one.cpp.cpp its going to expand to one.cpp -o one. if i just did one * like this g++ * -o * then it expands to g++ one.cpp -o one.cpp and then the exe is named one.cpp.exe | |
|
|
|
| Aramil of Elixia (772) | |
| if you dont beleive me when i say my terminal does that i can take a video and post it to you tube | |
|
|
|
| ne555 (4385) | |
|
Do that (`script' would be better). Then issue a bug to bash. > if i have *.cpp for a file called one.cpp its not going to expand to one.cpp.cpp I never said that. You need to make it parse, so * -> one to form one.cpp However when you do g++ *.cpp -o * It translate to g++ one.cpp -o one.cpp because they are independent Edit: > it expands to g++ one.cpp -o one.cpp and then the exe is named one.cpp.exe ¿exe? ¿why does it add a suffix? | |
|
Last edited on
|
|
| halitciftcise (3) | |
|
Firstly you handle your directory to as home -> in console . > cd home after write your program and save as *.cpp to home directory. after all in console you must write this->> g++ -Wall *.cpp -o * | |
|
|
|
| TheIdeasMan (1753) | ||
@halitciftcise
cd home won't work unless you are in the directory above home. And home is not your directory - /home/halitciftcise is for exampleIn UNIX / Linux, there are some short cuts to one's home directory. The simplest is just cd., next there is cd ~ , and this is also handy for getting to a subdirectory of your home directory as in cd ~/DesktopIn my mind, one way would be to compile like this: g++ -std=c++11 -Wall -Wextra -pedantic *.cpp -o nameofexecfileEdit: And this is done in the directory where the .cpp files are, normally each project would have it's own directory. As you can see it specifies the name of the executable explicity. Also be aware there are traps in that, what if there are old versions of .cpp files - it will attempt to compile them as well. That leaves you with trying to specify more complicated wild cards (regular expressions) to avoid that. So the final answer is: Don't use wild cards to compile files unless you know what you are doing. Normally, one uses make files anyway. So for simple examples do this: g++ -std=c++11 -Wall -Wextra -pedantic one.cpp two.cpp three.cpp -o nameofexecfile | ||
|
Last edited on
|
||