简体   繁体   中英

Simple Building for a C++ Hello World

So I am trying to learn C++ while going through the Facebook Puzzles. To test if submittals to the Puzzle Master are working properly, the meepmeep program can be used.

The input file will contain ASCII text that is going to be completely ignored by your program. In fact, do not even bother opening up the file, it will just complicate things.

The output should be the string "Meep meep!" (without the double quotes, using exact capitalization) followed by a single newline (don't forget this part!).

Sounds simple enough. Got everything working the first time around and just use the inbuilt compiler that came from XCode

g++ meepmeep.cpp -o meepmeep

Send that in and the robot said there are errors so I thought maybe I am not building this properly.

Made a makefile by searching around for how to do makefiles

meepmeep: meepmeep.cpp Makefile
    $(CXX) -o $@ $<

Still no luck robot would not accept. Of course there could be coding errors/syntax I am not seeing

#include <fstream>
#include <iostream>
using namespace std;

int main(int argc,char *argv[])
{
    cout << "Meep meep!\n";
    return 0;
}

So I am building this right or not ? What is the proper way to build ?

My compiler version is 4.2.1

Using built-in specs.
Target: i686-apple-darwin10
Configured with: /var/tmp/gcc/gcc-5664~105/src/configure --disable-checking --enable-werror --prefix=/usr --mandir=/share/man --enable-languages=c,objc,c++,obj-c++ --program-transform-name=/^[cg][^.-]*$/s/$/-4.2/ --with-slibdir=/usr/lib --build=i686-apple-darwin10 --program-prefix=i686-apple-darwin10- --host=x86_64-apple-darwin10 --target=i686-apple-darwin10 --with-gxx-include-dir=/include/c++/4.2.1
Thread model: posix
gcc version 4.2.1 (Apple Inc. build 5664)

Could it be that I am not using 4.2.3 ? or the architecture ? (The main question is still the first ... Is the build right or not)

If the code is not right that would be awesome. I wish it is that easy.

I don't want to know how the robot checks it or what tests it uses, please don't tell me. I just want to know if it is a legit build/code so I can go the next step and ask the Puzzle Master about it.

You're using gcc version 4.2.1. The Facebook puzzle page you linked to explicitly states in its Submission directions that it only accepts gcc 4.2.3 .

Darwin is a *NIX environment, so that's not the problem, but you should definitely upgrade your compiler, because the support libraries won't be the same and your program won't work.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM