2017-09-14 569 views
0

我使用cmake 3.9.2和我在我的CMakeLists.txt以下行成員:沒有名爲命名空間「STD」 make_unique'

set(CMAKE_CXX_STANDARD 14) 
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -g -Wall") 

我還使用鐺4.0作爲我的編譯器,我的操作系統是Ubuntu Trusty。當我安裝鐺添加以下庫:

deb http://apt.llvm.org/trusty/ llvm-toolchain-trusty-4.0 main 
deb-src http://apt.llvm.org/trusty/ llvm-toolchain-trusty-4.0 main 
ppa:ubuntu-toolchain-r/test 

,並運行命令:

# apt-get install clang-4.0 libstdc++6 libc++1 

而且畢竟我仍然得到錯誤

error: no member named 'make_unique' in namespace 'std' 

在同一時間在我的OS X 10.11的一切構建和運行順利。在Ubuntu Zesty上我也沒有任何問題。我在Ubuntu Trusty上做錯了什麼?

+1

included''? –

+0

@RickAstley是的,它包含在內 – CaptainRR

+0

你的CXX_FLAGS最可能出現問題。我的猜測是它們鏈接到C++ 11(即-std = C++ 11),而不是C++ 14(即-std = C++ 14),其中引入了std :: make_unique。 – 101010

回答

1

看來我解決了這個問題。我需要安裝libc++-dev並確保-stdlib=libc++在命令行中。