简体   繁体   中英

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

Background

I want to use boost library to serialize some objects in cuda. I have a bigger Makefile with nvcc compiling about 20 files. I hope to write the smallest working example of Makefile with boost library and then add it to my larger makefile

Boost library localization在此处输入图像描述

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.*

main.cpp

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


int main() {

    boost::optional<string>;

    return 0;
}

Running make hello &&./hello

Error which I get

[ 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

You have not given your variable a name. Try changing it to:

boost::optional<string> exampleName;

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.

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