繁体   English   中英

带有 nvcc 的简单 boost 程序 - 错误:声明未声明任何内容 [-fpermissive]

[英]Simple boost program with nvcc - error: declaration does not declare anything [-fpermissive]

背景

我想使用boost库来序列化cuda中的一些对象。 我有一个更大的 Makefile,nvcc 编译了大约 20 个文件。 我希望用 boost 库编写 Makefile 的最小工作示例,然后将其添加到我更大的 makefile

提升库本地化在此处输入图像描述

Makefile

LIBS=--relocatable-device-code=true -lcusolver -lcusparse 
ARCH=-arch=sm_30
OPTIONS= -O2



hello: main.o 
    nvcc $(OPTIONS) $(ARCH) $(LIBS) -L${BOOST_ROOT}/lib/ -llibboost main.o -o hello 

main.o: main.cpp
    nvcc $(OPTIONS) $(ARCH) $(LIBS) -c main.cpp -o main.o
    

clean:
    rm -rf *.o hello.*

主文件

#include <iostream>
#include <boost/optional.hpp>
using namespace std;


int main() {

    boost::optional<string>;

    return 0;
}

运行make hello &&./hello

我得到的错误

[ test]$ make hello && ./hello
nvcc -O2 -arch=sm_30 --relocatable-device-code=true -lcusolver -lcusparse  -c main.cpp -o main.o
main.cpp: In function ‘int main()’:
main.cpp:8:12: error: declaration does not declare anything [-fpermissive]
     boost::optional<string>;
            ^
make: *** [main.o] Error

你没有给你的变量一个名字。 尝试将其更改为:

boost::optional<string> exampleName;

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM