Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Using Clang++ in Makefile in place of G++

I have a makefile that builds my project just fine with g++ 4.6.

#specify the compiler  
GXX=g++ -std=c++0x

# Specifiy the target  
all: linkedList

# Specify the object files that the target depends on  
# Also specify the object files needed to create the executable  
linkedList: StudentRecord.o Node.o LinkedList.o  ListMain.o
    $(GXX) StudentRecord.o Node.o LinkedList.o  ListMain.o -o linkedList

# Specify how the object files should be created from source files  
LinkedList.o: LinkedList.cpp
    $(GXX)  -c  LinkedList.cpp

ListMain.o: ListMain.cpp
    $(GXX)  -c  ListMain.cpp

StudentRecord.o: StudentRecord.cpp
    $(GXX)  -c  StudentRecord.cpp

Node.o: Node.cpp
    $(GXX)  -c  Node.cpp

When I change the first line to be GXX = clang++ -std=c++0x clang throws some rather dense error about iostream not finding the correct args or something along with many other errors after that (but this is the "root" error).

In file included from /usr/include/c++/4.6/iostream:39:
In file included from /usr/include/c++/4.6/ostream:39:
In file included from /usr/include/c++/4.6/ios:40:
In file included from /usr/include/c++/4.6/bits/char_traits.h:40:
In file included from /usr/include/c++/4.6/bits/stl_algobase.h:65:
In file included from /usr/include/c++/4.6/bits/stl_pair.h:60:
In file included from /usr/include/c++/4.6/bits/move.h:53:
/usr/include/c++/4.6/type_traits:630:59: error: '_Tp' does not refer to a value
    : public integral_constant<bool, __is_standard_layout(_Tp)>

Is this a problem with my makefile, or is could there really be a difference in this simple compilation?

Using clang 2.9.

Note: The line that clang is complaining about is #include <iostream>

like image 410
soandos Avatar asked Nov 04 '22 03:11

soandos


1 Answers

This is an old question, but in case any one else stumbles in here, one thing to check is whether you're using the clang std lib. For that you need the flag:

-stdlib=libc++
like image 121
Rob Lachlan Avatar answered Nov 27 '22 13:11

Rob Lachlan