gpt4 book ai didi

makefile - 在 Makefile 中使用 Clang++ 代替 G++

转载 作者:行者123 更新时间:2023-12-04 20:49:11 25 4
gpt4 key购买 nike

我有一个 makefile 可以用 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

当我将第一行更改为 GXX = clang++ -std=c++0x clang 抛出了一些关于 iostream 没有找到正确的参数的相当密集的错误,或者之后还有许多其他错误(但这是“根”错误)。
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)>

这是我的makefile的问题,还是这个简单的编译真的有区别?

使用叮当 2.9。

注: clang 提示的线路是 #include <iostream>

最佳答案

这是一个老问题,但万一其他人在这里偶然发现,要检查的一件事是您是否正在使用 clang std lib。为此,您需要标志:

-stdlib=libc++

关于makefile - 在 Makefile 中使用 Clang++ 代替 G++,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/9732707/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com