今天在使用Mac编译C++文件时,提示以下错误。

 Undefined symbols for architecture x86_64:
"std::__1::__vector_base_common<true>::__throw_length_error() const", referenced from:
void std::__1::vector<E, std::__1::allocator<E> >::__push_back_slow_path<E const>(E const&) in main-8b5a99.o
"std::terminate()", referenced from:
___clang_call_terminate in main-8b5a99.o
"operator delete(void*)", referenced from:
std::__1::__vector_base<E, std::__1::allocator<E> >::~__vector_base() in main-8b5a99.o
std::__1::__split_buffer<E, std::__1::allocator<E>&>::~__split_buffer() in main-8b5a99.o
"operator new(unsigned long)", referenced from:
std::__1::__split_buffer<E, std::__1::allocator<E>&>::__split_buffer(unsigned long, unsigned long, std::__1::allocator<E>&) in main-8b5a99.o
"___cxa_begin_catch", referenced from:
___clang_call_terminate in main-8b5a99.o
"___cxa_call_unexpected", referenced from:
_main in main-8b5a99.o
"___gxx_personality_v0", referenced from:
_main in main-8b5a99.o
___cxx_global_array_dtor in main-8b5a99.o
void std::__1::vector<E, std::__1::allocator<E> >::__push_back_slow_path<E const>(E const&) in main-8b5a99.o
Dwarf Exception Unwind Info (__eh_frame) in main-8b5a99.o
ld: symbol(s) not found for architecture x86_64
clang: error: linker command failed with exit code (use -v to see invocation)

通过在stackoverflow翻阅找到相应的解决办法。 发生这种状况的原因是gcc默认文件时c文件,在编译时不会链接c++标准库。我们可以通过以下方式进行指定引入c++标准库

gcc main.c -o macin -lstdc++

或者使用

g++ main.c -o main

参考链接:stackoverflow

Mac上编译C++报错的更多相关文章

  1. Mac下编译tesseract报错 DotProductAVX can't be used on Android

    因为我的mac是64位的,所以用32位编译,执行的时候肯定会出错的. 所以应该在 arch/simddetect.cpp中把这句# define X86_BUILD 1 注释掉,就可以了. 参考 ht ...

  2. Mac上 intellij IDEA报错:Class JavaLaunchHelper is implemented in both /Library/Java/JavaVirtualMachines/jdk .jdk/Contents/Home/bin/java ( ) and /Library/Java/JavaVirtualMachines/jdk

    解决方案: 点击IDEA菜单里的Help-Edit Custom Properties,没有这个properties文件的话,会提示创建,在里面加上 idea.no.launcher=true 说明: ...

  3. mac笔记本编译go-ethereum报错CoreServices/CoreServices.h' file not found

    查看xcode是否安装: $ xcode-select --install xcode-select: error: command line tools are already installed, ...

  4. Xcode6在ios7上编译framework报错

    错误描述: dyld: Symbol not found: _OBJC_CLASS_$_UIPresentationController Referenced from: /var/mobile/Ap ...

  5. mac上安装webpack报错解决方法Hit error EACCES: permission denied, mkdir '/usr/local/lib/node_modules/webpack

    node-pre-gyp WARN Using needle for node-pre-gyp https download node-pre-gyp WARN Pre-built binaries ...

  6. Mac上编译并运行Android5.0源码

    下载.配置环境.build和运行参考的都是Android Source提供的文档,包括:Initializing a Build Environment,Downloading the Source和 ...

  7. webpack编译sass报错找不到module /css-loader/index.js... || 安装node-sass报错

    今天无论在家还是在公司,安装node-sass总是失败,或安装成功了,使用webpack编译sass报错,说找不到module,按照提示的错误我找了node_modules下的css-loader,发 ...

  8. 源码编译apache报错的解决方法

    源码编译apache报错的解决方法   问题介绍 在源码编译安装httpd时,./configure执行无错误,到make时就报错,在网络上搜索了很多文章,很多方法如换apr-util的低版本并不能很 ...

  9. MAC 上编译安装nginx-rtmp-module 流媒体服务器

    MAC 上编译安装nginx-rtmp-module 流媒体服务器 记录踩坑过程 下载nginx和nginx-rtmp-module wget http://nginx.org/download/ng ...

随机推荐

  1. Mongoose Schemas定义中timestamps选项的妙用

    在Node.js中使用MongoDB少不了Mongoose. 假设有如下Mongoose Schemas的定义: var ItemSchema = new mongoose.Schema({ biz: ...

  2. 修改TNSLSNR的端口

    oracle 服务一启动 TNSLSNR.exe 会占用8080端口,这时,如果我们其他程序需要使用8080端口就会比较麻烦,所以需要改一下端口: 用dba账户登录 CMD>sqlplus sy ...

  3. SQL Server 的 Statistics 簡介

    當你要清空「資料表(table)」,或倒入大量「資料(data;record)」,或公司「資料庫(database)」改用新版本要資料大搬家…等情形,不只是要重建「索引(index)」,還應要重建或更 ...

  4. css+div常用属性备忘录

    学习软件设计有一年多了,明年五月就要毕业了.回头看看发现自己其实挺差劲的. 最近开通了博客所以就整理了一下笔记,在这里发布一下自己以前学习css时总是记不住去翻书又很常用的属性,都是一些很基础的. 大 ...

  5. Spring学习记录(七)---表达式语言-SpEL

    SpEL---Spring Expression Language:是一个支持运行时查询和操作对象图表达式语言.使用#{...}作为定界符,为bean属性动态赋值提供了便利. ①对于普通的赋值,用Sp ...

  6. atitit.闭包的概念与理解attilax总结v2 qb18.doc

    atitit.闭包的概念与理解attilax总结v2 qb18.doc 1.1. 闭包(Closure)是词法闭包(Lexical Closure)的简称,是引用了自由变量的函数.1 2. #---- ...

  7. 3D旋转菜单

    今天来个3D旋转菜单,是纯css3实现的,主要用到transform,transition,backface-visibility. 主要是transform这个变换,它是今天猪脚. transfor ...

  8. 利用免费cdn加速webpack单页应用

    回顾现状 在之前的学习过程中,react单页应用经过webpack打包之后会输出大概如下的目录结构,它就是站点的所有前端组成了:   1 2 3 4 5 6 MacBook-Pro:output ba ...

  9. Sql Server系列:数据库对象

    数据库对象是数据库的组成部分,数据表.视图.索引.存储过程以及触发器等都是数据库对象. 数据库的主要对象是数据表,数据表是一系列二维数组的集合,用于存储各种信息. 视图表面上看与表几乎一样,具有一组命 ...

  10. floating IP 原理分析 - 每天5分钟玩转 OpenStack(107)

    上一节我们通过 Web UI 创建为 cirros-vm3 分配了浮动 IP,今天将分析其工作原理. 首先查看 router 的 interface 配置: 可以看到,floating IP 已经配置 ...