olk
October 29, 2017, 9:57am
1
Hi,
I try to compile some C++ code with nvcc. Unfortunately I get following error:
/usr/local/include/boost/fiber/context.hpp:190:44: error: »tp_std« was not declared
std::chrono::steady_clock::time_point tp_{ (std::chrono::steady_clock::time_point::max)() };
compiled with:
/opt/cuda/bin/nvcc -ccbin g++ -I/opt/cuda/include -I/usr/local/include -I/usr/include -m64 -std=c++11 --expt-relaxed-constexpr -Xcompiler -O2 -Xcompiler -W -Xcompiler -Wall -gencode arch=compute_61,code=compute_61 -o simple.o -c simple.cu
Is nvcc unable to handle std::chrono library?
I’m using nvcc release V9.0.176, gcc 7.2.0 on x86_64.
ty,
Oliver
gcc 7.2 is not a supported host compiler for nvcc on CUDA 9:
http://docs.nvidia.com/cuda/cuda-installation-guide-linux/index.html#system-requirements
I didn’t have any trouble compiling this in CUDA 9 with gcc 4.8.4 (Ubuntu 14.04):
$ cat t450.cu
#include <chrono>
int main(int argc, char ** argv)
{
std::chrono::steady_clock::time_point tp_{ (std::chrono::steady_clock::time_point::max)() };
}
$ nvcc -std=c++11 t450.cu -o t450
t450.cu(5): warning: variable "tp_" was declared but never referenced
t450.cu(5): warning: variable "tp_" was declared but never referenced
$
olk
October 30, 2017, 6:49am
3
Indeed your example works for me too.
It’s strange that including a header from a C++ library (that can be successfully compiled by gcc; without problems) generates the error I mentioned above (»tp_std« was not declared).
Maybe some compiler arguments are missing in my command line?
olk
October 31, 2017, 6:32am
4
nvcc does not handle in-class member initializers correctly:
#include <chrono>
struct foo {
std::chrono::steady_clock::time_point tp_{ (std::chrono::steady_clock::time_point::max)() };
};
int main() {
return 0;
}
generates error:
error: »tp_std« was not declared
std::chrono::steady_clock::time_point tp_{ (std::chrono::steady_clock::time_point::max)() };
olk
October 31, 2017, 6:39am
5
nvcc has some problems with parsing…
while the exampel above fails, following code compiles:
#include <chrono>
std::chrono::steady_clock::time_point bar() {
return (std::chrono::steady_clock::time_point::max)();
}
struct foo {
std::chrono::steady_clock::time_point tp_{ bar() };
};
int main() {
return 0;
}