简体   繁体   English

C ++ Hello World的简单构建

[英]Simple Building for a C++ Hello World

So I am trying to learn C++ while going through the Facebook Puzzles. 因此,我尝试通过Facebook Puzzles学习C ++。 To test if submittals to the Puzzle Master are working properly, the meepmeep program can be used. 要测试提交给Puzzle Master的提交是否正常,可以使用meepmeep程序。

The input file will contain ASCII text that is going to be completely ignored by your program. 输入文件将包含ASCII文本,程序将完全忽略该文本。 In fact, do not even bother opening up the file, it will just complicate things. 实际上,甚至不必打扰打开文件,它只会使事情复杂化。

The output should be the string "Meep meep!" 输出应为字符串“ 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 第一次使用时一切正常,仅使用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 我的编译器版本是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 ? 可能是我没有使用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. 您正在使用gcc版本4.2.1。 The Facebook puzzle page you linked to explicitly states in its Submission directions that it only accepts gcc 4.2.3 . 您链接到的Facebook拼图页面在其提交方向明确指出 ,该页面仅接受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. 达尔文(Darwin)是一个* NIX环境,所以这不是问题,但是您绝对应该升级编译器,因为支持库将不相同,并且您的程序将无法运行。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

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