I'm new to Eclipse. Despite its best efforts I got it to compile and run a
Hello World program. I am now trying to bring in a simple program I wrote that worked on MS Visual Studio 2010.
A user in reddit learnprogramming said I was missing a quotation mark in my make file, but I am using automatic make files. I don't know how to write my own and would rather work on the other 50 things wrong with the program. The Eclipse make file help page is technobabble to me.
I think Eclipse is not trying to build the files in the correct order, but I cannot find how to change the build order or how to point it towards the correct file to begin with. When I created the files in Eclipse, I hit "New Class" and then just copied and pasted in the old files. There are no red or yellow flags in the left margin indicating there are any problems. The file with the main method is Tier.cpp, but I believe it's trying to start with Player.cpp.
The compiler error is the very user friendly and easy to read:
01:31:42 **** Incremental Build of configuration Debug for project VanillaWoW ****
make all
Building file: ../VanillaWoWSource/Player.cpp
Invoking: Cross G++ Compiler
g++ -I"C:\cpp\boost_1_66_0\boost" -I"C:\cyg\bin"
-I"C:\cyg\lib\gcc\x86_64-pc-cygwin\6.4.0\include"
-I"C:\cyg\lib\gcc\x86_64-pc-cygwin\6.4.0\include\c++"
-I"C:\cyg\lib\gcc\x86_64-pc-cygwin\6.4.0\include\c++\backward"
-I"C:\cyg\lib\gcc\x86_64-pc-cygwin\6.4.0\include\c++\x86_64-pc-cygwin"
-I"C:\cyg\usr\include" -I"C:\cyg\usr\include\w32api"
-I"c:\cpp\boost_1_66_0\" -I"C:\cyg\lib\gcc\x86_64-w64-mingw32\6.4.0\include\c++"
-O0 -g3 -Wall -c -fmessage-length=0 -MMD -MP -MF"VanillaWoWSource/Player.d"
-MT"VanillaWoWSource/Player.o"
-o "VanillaWoWSource/Player.o" "../VanillaWoWSource/Player.cpp"
/bin/sh: -c: line 0: unexpected EOF while looking for matching `"'
/bin/sh: -c: line 1: syntax error: unexpected end of file
make: *** [VanillaWoWSource/subdir.mk:26: VanillaWoWSource/Player.o] Error 1
I don't understand why it's throwing an error on line 26 of an object file that I didn't think it had fully even created yet. I don't know what /bin/sh: -c refers to, and I don't know which file it's hitting the end of file on.
Full code is at :
https://docs.google.com/document/d/185sOHxk3wKAnl6N0oCSvlJZB7WUTY8gEtZCsLIr1q0o/edit?usp=sharing
Now I formatted up your error messages, I can see the problem:
-I"c:\cpp\boost_1_66_0\" -I"C:\cyg\lib\gcc\x86_64-w64-mingw32\6.4.0\include\c++"
Note the boost_1_66_0\" - the trailing backslash escapes the quote character, so the text colouring goes wonky. Look where you set up paths and either remove the trailing backslash, or better, use forward slashes throughout. Windows will accept them, and you won't get bitten by mysterious escape problems.
I'm not sure why getting C++ set up is so difficult for you. It might have something to do with you using Eclipse -- it's really more of a Java IDE, and I'd suggest using something that's built for C++. When I was starting C++, I wrote with Code::Blocks and it worked great for me. I'd suggest switching to that.
C++ is a lower level language than Java. It's arguably more difficult to program in because of that. Although I do think the brunt of your issue is more because of the environment you're coding in.
Related
i just started to code in cpp and nothing is working idk if i didn't install the gcc properly or what but i already set the path of the bin file idk why it refuses to run
the code:
#include<iostream>
int main()
{
std::cout<<"hello";
}
and the problem is that when I try to use the "code runner extension" it is not working so I just press f5 and then when I get the error messages which says at first "could not find the task file'c/c++:g++.exe build active file' " and I get three options 1:debug anyway
2:configure task
3:cancel
when I choose debug anyway I get this error here
Since you're on windows consider installing Visual Studio or CLion. They're more beginner friendly - VSCode can get tricky to run c++ on windows. Either way, looks like you're trying to run your project without building it first. There should be a build option right next to the run option. Try building it, then running. The build is what compiles and creates the project.exe file, which is what the compiler is saying isn't there.
The referenced IDE's always auto-build on run, so there's that
If you're familiar with using the command line, these commands will do what you want, assuming the .cpp file is in your current directory.
g++ <FILENAME>
./a.out
There are wonderful flags you can add to the first command (the compiling command) like -Wall, -Wextra, -o, and many more. But, since it seems like you're just starting out, there's no need to worry about those!
If you're not familiar with the command line, I would encourage you to become familiar! It is an extremely powerful tool for a programmer. Here is a YouTube video that talks about it.
I'm new to programming so I feel there is something simple I'm missing here.
I'm using the latest version of Mac and I've just installed Code::Blocks along with Xcode so I can use the gcc compiler.
I created a new "console application" project and the code for a hello world program shows up.
I built this code and it gave me 0 errors and 0 warnings so I thought it was off to a good start.
But when I go to run this code all I get is the following in my Terminal window:
*/Applications/CodeBlocks.app/Contents/MacOS/cb_console_runner DYLD_LIBRARY_PATH=$DYLD_LIBRARY_PATH:. /Users/Ryan/Documents/C++ book stuff/SayHello/bin/Debug/SayHello
Ryan-McMullens-iMac:~ Ryan$ /Applications/CodeBlocks.app/Contents/MacOS/cb_console_runner DYLD_LIBRARY_PATH=$DYLD_LIBRARY_PATH:. /Users/Ryan/Documents/C++ book stuff/SayHello/bin/Debug/SayHello
sh: /Users/Ryan/Documents/C++: No such file or directory
Process returned 127 (0x7F) execution time : 0.003 s
Press ENTER to continue.*
I've checked to make sure its using the gcc compiler. I've also tried creating a C++ directory in my documents folder but that didn't help.
Like I said, I feel like I'm just missing a step somewhere so any help would be really appreciated!
Thanks!
Try avoiding using '+' and spaces in the name of directories.
Many program don't handle escaping of pathnames when running external tools like compiler, linker or when calling the final executable.
Remove spaces from your path. It seems that codeblocks does not quote the paths, so every space will be introducing a new command or parameter. The problem here is this part:
C++ book
because it has a whitespace.
I'm a noob, I admit it. Regardless, I've had a really annoying problem with MinGW.... I can write AND compile programs in C with no problem whatsoever, but recently I've tried to install Cmake, but I can't because it fails every time it tests the C++ compiler (g++). So that lead me to just write a simple "hello world" program in C++ and try to compile it. No dice. Again and again I get no response whatsoever. On the command line, I'm typing
g++ -o hello++.cpp hello++
but have also tried
g++ -o hello++.cxx hello++
g++ -o hello++.cc hello++
g++ -o hello++ hello++.cpp
(Of course I saved copies of the source code in the same directory with the .cxx and .cc extensions respectively)
and a bunch of other combinations thereof. Everytime I get nothing. No warning. No error. Nothing. No .exe file was created in the directory, and typing "hello++" on the command line afterwards just gives me a "command not found" error. Soooo.... what the hell is going on? Why does the gcc command work but the g++ not?
I'm on windows 8, using cygwin.
The last one should have succeeded; you won't get a message saying it's succeeded, but you should see the executable in the current directory. The others all try to take the executable as input and output the source, which won't work; although I'm surprised you don't get error messages.
If it did succeed, then simply typing hello++ is unlikely to run it since the current directory is typically not on the path. Try ./hello++ instead.
If it didn't succeed, then it's possible that g++ isn't installed properly. I'm afraid I've no idea how to fix a broken Cygwin installation. Perhaps which g++, to see which program is actually being run, might give some clues.
i am getting this error at compile (actually this is a very simple project and the syntax is absolutely ok)
E:\proj1\Makefile.win [Build Error] [main.o] Error 1
this is my compiler log (dev c++ v 4.9.9.2)
Compiler: Default compiler
Building Makefile: "E:\proj1\Makefile.win"
Executing make...
make.exe -f "E:\proj1\Makefile.win" all
g++.exe -c main.cpp -o main.o -I"C:/Dev-Cpp/lib/gcc/mingw32/3.4.2/include" -I"C:/Dev-Cpp/include/c++/3.4.2/backward" -I"C:/Dev-Cpp/include/c++/3.4.2/mingw32" -I"C:/Dev-Cpp/include/c++/3.4.2" -I"C:/Dev-Cpp/include"
'C:\Users\r' is not recognized as an internal or external command,
operable program or batch file.
The system cannot find the path specified.
make.exe: *** [main.o] Error 1
Execution terminated
my user path is 'c:\Users\r&d', i think the '&' is makeing trouble in compile process , does anybody has any idea ?, i can not reinstall windows because i have got many softwares installed on my current windows and it is very time consuming to me, how can i fix this /
r&d is definitely a problem. Try surrounding it with quotes: "c:\users\r&d" and hope for the best. If it doesn't work, change the folder to something without an ampersand (you don't need to reinstall Windows for that, just create another user).
You can try creating another user without the ampersand, and then copying your profile to it to keep all your settings and application preferences, as well as documents.
You might want to try another build enviroment, like code:blocks which has its own internal build system. You probably want make sure you are using the latest gcc mingw compiler and build system from mingw(use their installer, I think it was http://sourceforge.net/projects/mingw/files/Installer/mingw-get-inst/mingw-get-inst-20120426/ ), and even if you don't go with code::blocks, make sure you are using the new branch of devc++ that was forked and still being developed. One last thing is if you go with code::blocks, use a nightly build in the forum, http://forums.codeblocks.org/index.php/board,20.0.html as they are much more up to date.
The escape character in Windows is ^. So try
C:\Users\r^&d
I am running the example found here to try out using YAML in C++. I copied the code verbatim into test.cpp in a new project folder. I compiled YAML into a static library and am linking it to my project. I'm running Ubuntu 11.10. I use the following command to compile:
g++ -Wall -I. -g test.cpp -lyaml-cpp -L.
I get the following error statement:
terminate called after throwing an instance of 'YAML::ParserException'
what(): yaml-cpp: error at line 4, column 2: illegal block entry
Aborted
What is the meaning of this exception? And what could be wrong? I couldn't find a clear documentation for what each of the exceptions could mean, so even a link to this information would be helpful. I am probably out of my depth, as I am new to YAML, using libraries, and linux for that matter. Thanks in advance for your help.
Edit: The error occurs before "parser.GetNextDocument(doc)". Also, I ran a simpler example from the website that stores a single scalar, and that worked fine. Is the exception about my input file, or my code?
The error indicates that there's a problem with the input file (monsters.yaml). Make sure you copied it exactly. It claims there's an error at line 4, column 2, so you can look at that spot first (but yaml-cpp isn't great with location of errors, so that may not be the right spot to look at).
Things to make sure about:
spaces, not tabs
the proper number of spaces for indentation