我正尝试在我的Linux机器(Ubuntu)上编译一个非常简单的线程程序,但是即使我指定了libc++,clang似乎仍然向我抛出错误。我的程序如下:
#include <iostream>
#include <thread>
void call_from_thread() {
std::cout << "Hello, World!" << std::endl;
}
int main()
{
std::thread t1(call_from_thread);
t1.join();
return 0;
}
makefile:
CC=clang++
CFLAGS=-std=c++11 -stdlib=libc++ -pthread -c -Wall
#proper declaration of libc++, but still an error...
LDFALGS=
SOURCES=main.cpp
OBJECTS=$(SOURCES:.cpp=.o)
EXECUTABLE=bimap
all: $(SOURCES) $(EXECUTABLE)
$(EXECUTABLE): $(OBJECTS)
$(CC) $(LDFLAGS) $(OBJECTS) -o $@
.cpp.o:
$(CC) $(CFLAGS) $< -o $@
具体错误:
In file included from main.cpp:2:
In file included from /usr/include/c++/4.6/thread:37:
/usr/include/c++/4.6/chrono:666:7: error: static_assert expression is not an
integral constant expression
static_assert(system_clock::duration::min()
^ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
1 error generated.
make: *** [main.o] Error 1
我不确定为什么clang没有使用libc++,因为如果我没记错的话,clang会使用这个库编译线程。感激任何帮助!
LDFLAGS
拼错了。 - kennytm