osX下编译c++程序出现Undefined symbols for architecture x86_64的原因及解决

本文详细解释了在C++编译过程中使用GCC与G++的区别,强调了自动链接正确C++库的重要性。通过对比两种编译器的默认行为,阐述了如何选择合适的编译器来确保程序的正常运行。

摘要生成于 C知道 ,由 DeepSeek-R1 满血版支持, 前往体验 >

摘自stackoverflow.com

1.The error isn't that it's the wrong architecture, it's that std::cout (and other symbols) isn't defined.

You should compile and link with g++ not gcc, to automatically link with correct C++ libraries.



2.The error is caused because you're compiling with gcc, which only default-links libc. You need to compile with g++ so that libstdc++ is auto-linked in too.

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值