This program can build successfully on Windows - Visual Studio 12, but I got some problem when I compile it on Linux.
Compile command : nvcc main.cu
int main(int argc, char **argv) {
... (Skip some code)
// Read file.
MemoryBuffer<char> text(size + 1); // size type is size_t
auto text_smem = text.CreateSync(size);
fread(text_smem.get_cpu_wo(), 1, size, fp);
... (Skip some code)
}
Compiler error message:
auto text_smem = text.CreateSync(size);
occured about error: explicit type is missing ("int" assumed)
and error: no suitable conversion function from "SyncedMemory<char>" to "int" exists
fread(text_smem.get_cpu_wo(), 1, size, fp);
occured about error: expression must have class type
How to solve the compiler error in Linux OS?
MemoryBuffer is a class, detail code can see from here .
This depends on version of CUDA Toolkit, that you have installed, but I guess you could try with --std=c++11
option to the nvcc
, in order to explicitely enable modern C++ features.
Reffering to https://devblogs.nvidia.com/parallelforall/power-cpp11-cuda-7/
To enable C++11 support, pass the flag
--std=c++11
tonvcc
(this option is not required for Microsoft Visual Studio).
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.