我正在尝试C++使用 LLVM/Clang 3.7.0 构建一个简单的(“hello world”)程序,该程序是根据工具链的源代码构建的libc++,使用命令行:
clang++ -std=c++14 -stdlib=libc++ -fno-exceptions hello.cpp\nRun Code Online (Sandbox Code Playgroud)\n\n但是,我收到以下错误:
\n\n/usr/bin/ld: warning: libc++abi.so.1, needed by /bulk/workbench/llvm/3.7.0\n/toolchain4/bin/../lib/libc++.so, not found (try using -rpath or -rpath-link)\n/bulk/workbench/llvm/3.7.0/toolchain4/bin/../lib/libc++.so: undefined reference to `__cxa_rethrow_primary_exception\'\n/bulk/workbench/llvm/3.7.0/toolchain4/bin/../lib/libc++.so: undefined reference to `__cxa_decrement_exception_refcount\'\n/bulk/workbench/llvm/3.7.0/toolchain4/bin/../lib/libc++.so: undefined reference to `std::out_of_range::~out_of_range()\'\n[...]\nRun Code Online (Sandbox Code Playgroud)\n\n未LD_LIBRARY_PATH设置,工具链的安装目录已添加到我的工作中PATH中:
export PATH=$PATH:/bulk/workbench/llvm/3.7.0/toolchain4/bin/\nRun Code Online (Sandbox Code Playgroud)\n\n我上线了Ubuntu GNU/Linux 14.04,并且尚未从任何存储库安装任何 LLVM 或 Clang 相关的软件包。
根据libc++ 文档:
\n\n\n在 Linux 上,libc++ 通常只能与 \xe2\x80\x98-stdlib=libc++\xe2\x80\x99 一起使用。然而,某些 libc++ 安装需要用户自己手动链接 libc++abi。如果在使用 …
我想尝试 C++17 的并行 STL。但是,我在 libc++ 中找不到experimental/execution_policy。我怎样才能试试这个?
我正在尝试http://en.cppreference.com/w/cpp/experimental/reduce,它说我应该包含这些文件,但我找不到 execution_policy。
#include <experimental/execution_policy>
Run Code Online (Sandbox Code Playgroud)
安装 libc++ 后(我遵循了http://libcxx.llvm.org/docs/BuildingLibcxx.html),我尝试了以下命令,但徒劳无功。
$ clang++-3.5 -std=c++1z test.cpp -lc++experimental
test.cpp:5:10: fatal error: 'experimental/execution_policy' file not found
#include <experimental/execution_policy>
^
1 error generated.
Run Code Online (Sandbox Code Playgroud)
这还没有实施吗?
我读过您可以在 Windows 上将 Clang 用于 C++ 应用程序,同时使用 C++ 标准库的 MS 实现。但是如果你想在 Windows 上使用 libc++,你目前需要使用类似 cygwin 或 mingw 的东西。我还看到了一些旧帖子,表明有人正在努力将 libc++ 移植到 Windows,但我找不到有关这项工作状态的任何信息。
也感谢有关类似努力/项目的任何信息。
我正在运行 Ubuntu 18.04.1 LTS,并尝试让 Half Life 的游戏库在 Xash3D 引擎中运行。它们构建正常,但是当我尝试运行引擎时,我收到以下令人困惑的错误:
undefined symbol: _ZTVN10__cxxabiv120__si_class_type_infoE
Run Code Online (Sandbox Code Playgroud)
经过一些互联网研究后,我认为这基本上可以解决“VTable for __cxxabiv1::__si_class_type_info”。我已经安装了libc++abi-dev、libc++-dev、libc++abi1以及libc++1它们的 i386 对应版本(因为我必须以 32 位进行编译),所以我不知道为什么运行时链接会失败。
如果有帮助的话,我发现半条命存储库中的其他库(特别是死亡竞赛经典库)也可以工作。我检查了 makefile,DMC 库没有任何LDFLAGS设置,而标准的 Half Life 库使用:
LDFLAGS= -lm -lstdc++
Run Code Online (Sandbox Code Playgroud)
有什么原因导致我在这里收到链接器错误吗?我可以做什么来修复它们?
编辑:我正在使用 GCC/G++ 7.3.0。如果有帮助,我正在使用的库的 makefile 在这里:
有效的:https://github.com/ValveSoftware/halflife/blob/master/linux/Makefile.dmcdll
没有的:https://github.com/ValveSoftware/halflife/blob/master/linux/Makefile.hldll
我还在*_map.txt编译生成的文件中搜索了“libc”。这就是现在的情况:
在工作 DMC 映射文件中:
Archive member included to satisfy reference by file (symbol)
/usr/lib/i386-linux-gnu/libc_nonshared.a(stack_chk_fail_local.oS)
/home/vesper/Documents/afterburner-game/build/game/obj/dmcdll/animating.o (__stack_chk_fail_local)
As-needed library included to satisfy reference by file (symbol)
libstdc++.so.6 /home/vesper/Documents/afterburner-game/build/game/obj/dmcdll/nodes.o (operator new[](unsigned …Run Code Online (Sandbox Code Playgroud) 我已经构建了 libc++ 并且想在编译我的程序时使用它?所以我有类似的东西
clang++ -stdlib=~/libc++/libc++.so main.cpp
Run Code Online (Sandbox Code Playgroud)
但这不起作用。构建应用程序时如何使用我自定义构建的 libc++?
我有一个简单的程序,它使用在命令行上传递给它的一系列语言环境来测试wchar_t和char之间的转换.它通过打印出语言环境名称和无法转换的字符串输出失败的转换列表.
我正在使用clang和libc ++构建它.我的理解是libc ++的命名语言环境支持由OS X上的xlocale库提供.
我看到一些意外的失败,以及转换失败的一些情况,但事实并非如此.
这是程序.
#warning call this program like: "locale -a | ./a.out" or pass \
locale names valid for your platform, one per line via standard input
#include <iostream>
#include <codecvt>
#include <locale>
#include <array>
template <class Facet>
class usable_facet : public Facet {
public:
// FIXME: use inheriting constructors when available
// using Facet::Facet;
template <class ...Args>
usable_facet(Args&& ...args) : Facet(std::forward<Args>(args)...) {}
~usable_facet() {}
};
int main() {
std::array<std::wstring,11> args = {L"a",L"é",L"¤",L"€",L"??",L"?",L"?",L"?",L"?",L"?",L""};
std::wstring_convert<usable_facet<std::codecvt_utf8<wchar_t>>> u8cvt; // …Run Code Online (Sandbox Code Playgroud) 有关libc ++中C++ 11标准支持的良好信息来源吗?它的网站说支持98%的标准,但我想知道其他2%的功能是什么.
类似于libstdc ++的这个列表的东西会很好:http: //gcc.gnu.org/onlinedocs/libstdc++/manual/status.html#status.iso.2011
以下程序演示了libc ++和libstdc ++之间std :: getline行为的不一致性(使用clang3.3).
程序打开文件testfile,读取它直到eof,然后使用ifstream :: clear清除错误位并再次尝试从同一个文件句柄读取以查看是否有新数据附加到文件中.
#include <fstream>
#include <iostream>
#include <unistd.h>
using namespace std;
int main() {
ifstream* file = new ifstream("testfile");
if ( ! file->is_open() ) {
cout << "testfile does not exist" << endl;
return -1;
}
while ( 1 ) {
file->clear(); // remove end of file evil bits
string line;
// workaround:
// file->seekg(file->tellg());
while ( getline(*file, line) )
cout << "read line: " << line << endl;
if ( file->eof() )
cout …Run Code Online (Sandbox Code Playgroud) 尝试使用Xcode 6.1中的clang版本(基于LLVM 3.5svn的clang-600.0.54)编译以下代码,-std=c++11并-stdlib=libc++给出一些我不太了解的错误.
#include <functional>
struct Impl
{
typedef std::function<void ()> L;
L l;
int i;
};
struct Hndl
{
Impl* impl;
Hndl(Impl* i): impl(i) {}
~Hndl() noexcept(false) {}
};
int main(int argc, char * argv[]) {
Hndl h(new Impl());
h.impl->l = [=]
{
h.impl->i = 42;
};
return 0;
}
Run Code Online (Sandbox Code Playgroud)
结果:
In file included from t.cpp:1:
/Applications/Xcode-6.1.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/../include/c++/v1/functional:1293:52: error: exception specification of overriding
function is more lax than base version
template<class _FD, class _Alloc, class _FB> …Run Code Online (Sandbox Code Playgroud) I'm updating a project to use the latest Qt and taking the opportunity to switch to libc++ and C++11 at the same time. My understanding is that OS X 10.7 and above support this without me needing to ship my own build of the standard library. I'm happy to no longer support OS X versions <10.7.
C ++ 11支持很棒,但是我真的很想使用C ++ 14。
为OS X> 10.7的最终用户安装的libc ++是否还支持C ++ 14标准库功能?
我的猜测是“是”,并且操作系统更新在> 10.7中一直保持最新状态-但我一直找不到确切的资料说明这种情况。