如何从OS X Terminal编译带有多个类文件的C ++程序? [英] How do you compile a C++ program with multiple class files from OS X Terminal?

查看:46
本文介绍了如何从OS X Terminal编译带有多个类文件的C ++程序?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我尝试做

gcc [folderName] -o [executableName]

但这似乎不起作用.

推荐答案

gcc用于编译C源文件,但对于C ++,则需要使用g ++.至于多个文件,只需列出它们即可:

gcc is used for compiling C source files but for C++ you will need to use g++. As for the multiple files, just list them:

g ++ [所有源文件的列表] -o [executableName]

还请注意,如果您是通过xcode安装gcc的,那么它将是一个相当旧的版本.我建议使用 clang 代替,因为它是xcode使用的编译器,并且保持最新状态.它的工作原理与gcc几乎相同,因此对于您的情况,它将是:

Also note that if you have installed gcc via xcode then it will be quite an old version. I would recommend using clang instead as it is the compiler used by xcode and is kept up to date. It works pretty much the same as gcc so for your situation it would be:

clang ++ [所有源文件的列表] -o [executableName]

这篇关于如何从OS X Terminal编译带有多个类文件的C ++程序?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆