clang++

gtest: Undefined symbols for architecture x86_64 error with clang++ and std::vector

陌路散爱 提交于 2019-12-06 04:44:54
问题 I downloaded the gtest 1.6, and compiled it with clang++. export CC=/usr/bin/clang export CXX=/usr/bin/clang++ configure make I got the libgtest.a, and I copied it into /usr/local/lib/libgtest_clang.a . When I tested with simple C++ code, everything works OK, however, when I tried to use vector in test code, I got these error messages in the build process. Compilation works fine. Undefined symbols for architecture x86_64: "std::basic_string<wchar_t, std::char_traits<wchar_t>, std::allocator

How to explicit instantiate template constructor in C++?

给你一囗甜甜゛ 提交于 2019-12-06 02:27:26
Currently I have the following class //AABB.h class AABB { public: template <class T> AABB(const std::vector<T>& verties); template <class T> AABB(const std::vector<int>& indicies, const std::vector<T>& verties); template <class T> AABB(const std::vector<int>::const_iterator begin, const std::vector<int>::const_iterator end, const std::vector<T>& verties); AABB(); AABB(const vec3 min, const vec3 max); AABB(const AABB& other); const vec3& min_p() const { return m_min; } const vec3& max_p() const { return m_max; } vec3 center(); float volume(); float surface_area(); bool inside(vec3 point);

clang++ mac os x c++11 linker issue

。_饼干妹妹 提交于 2019-12-06 00:50:27
I have a problem compiling a program with "-std=c++11 -stdlib=libc++" under mac os x 10.8.3 using clang++ from xcode 4.6.2. When I try to use std::mem_fn() or (deprecated) std::mem_fun_ref(), I get linker error "symbol(s) not found". The same code (with std::mem_fun_ref instead of std::mem_fn) compiles and links without any issues under the c++03 standard. If I call the same member function on an object without referring to it via mem_fn or mem_fun_ref, the program compiles and runs without any problems. Is it a clang++ problem, a mac os problem, or am I doing something wrong? The code:

Undefined reference with clang++ with O2

血红的双手。 提交于 2019-12-05 20:50:12
问题 I'm trying CLang 3.4 and libc++ on a project and I get strange linking errors in release mode: /home/wichtounet/dev/eddic/src/ast/Operator.cpp:17: error: undefined reference to 'std::__1::basic_ostream<char, std::__1::char_traits<char>>& std::__1::operator<< <char, std::__1::char_traits<char>, std::__1::allocator<char>>( std::__1::basic_ostream<char, std::__1::char_traits<char>>&, std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char>> const& )' clang: error:

std::cerr on linux with clang++ and libc++ causes SIGABRT

对着背影说爱祢 提交于 2019-12-05 20:11:09
I'm trying to get a simple program running on Ubuntu 12.04 x64 compiled with clang++ 3.3 libc++ libc++abi . Program: #include <iostream> int main(int argc, char **argv) { try { std::cerr << "Test cerr \n"; } catch (...) { std::cout << "catch exception"; } return 0; } Writing to std::cerr prints the message, but results in SIGABRT. However, writing to std::cout works fine. Here the ldd output of the executable: $ldd cerr_test linux-vdso.so.1 => (0x00007fffce5ff000) libc++abi.so.1 => /usr/local/lib/libc++abi.so.1 (0x00007fa4079fd000) libc++.so.1 => /usr/local/lib/libc++.so.1 (0x00007fa407759000)

clang++ under QtCreator can't work with c++11

旧城冷巷雨未停 提交于 2019-12-05 16:16:43
OS : OS X 10.8.1 QtCreator : 2.6.2 Command line is fine, but QtCreator fail to compile the codes. #include <functional> #include <iostream> #include <memory> #include <string> #include <vector> int main(int argc, const char * argv[]) { std::vector<std::string> strs{"yahoo", "haha"}; for(auto const &data : strs){ std::cout<<data<<std::endl; } std::vector<std::string> strs2 = std::move(strs); std::unique_ptr<int> A(new int(3)); std::cout<<*A<<std::endl; return 0; } Command line : clang++ -stdlib=libc++ -std=c++11 main.cpp -o test Compiler setting of QtCreator http://www.flickr.com/photos

Why can't clang enable all sanitizers?

此生再无相见时 提交于 2019-12-05 13:18:46
问题 Clang has various sanitizers that can be turned on to catch problems at runtime. However, there are some sanitizers that I can't use together. Why is that? clang++-3.9 -std=c++1z -g -fsanitize=memory -fsanitize=address -o main main.cpp 1 clang: error: invalid argument '-fsanitize=address' not allowed with '-fsanitize=memory' It's not a big deal, but when I run my unit tests, it takes longer than it should, because I have create multiple binaries for the same tests, and run each of them

Clang Code Coverage Invalid Output

生来就可爱ヽ(ⅴ<●) 提交于 2019-12-05 11:35:55
So I've checked out and built the clang trunk by following these instructions http://clang.llvm.org/get_started.html . I can build my binary with --coverage and run it to get the .gcno and .gcda files, but when I run lcov I get "GENINFO: ... reached unexpected end of file". Now I'm stuck and came to SO to look for help :) I'm working with Ubuntu 13.04 and writing c++11, just in case that makes a difference. Himanshu I had the same problem with clang with lcov on Ubuntu 13.04. Here is the solution which worked for me on more than one Ubuntu setup. You will find there are two versions of gcov on

Why am I getting “Undefined symbols … typeinfo … vtable” with a virtual and concrete class?

假如想象 提交于 2019-12-05 10:59:40
I'm relearning C++ (meaning: go gentle on me! :). I have a superclass ( Node ) with an abstract method ( step() ) that must be implemented in a subclass ( TestNode ). It compiles without error and without any warnings, but linking it results in: bash-3.2$ g++ -Wall -o ./bin/t1 src/t1.cpp Undefined symbols for architecture x86_64: "typeinfo for test::Node", referenced from: typeinfo for test::TestNode in t1-9f6e93.o "vtable for test::Node", referenced from: test::Node::Node() in t1-9f6e93.o NOTE: a missing vtable usually means the first non-inline virtual member function has no definition. ld:

How to fix a purported lack of an “explicit instantiation declaration” when compiling a CRTP Singleton with Clang?

自闭症网瘾萝莉.ら 提交于 2019-12-05 08:21:58
We're using the curiously recurring template pattern to implement singletons. However, with recent Clang versions we're getting a -Wundefined-var-template warning. The suggested fix to which is to add an "explicit instantiation declaration". I attempted to do this, but then I get errors about "explicit specialization after instantiation" in the compilation unit where the definition of the singleton template class member variable is. What's the appropriate construct to fix the issue highlighted by this warning? Simplified Details (much of the logic has been removed, to make a MCVE):