Cuda error: function has already been defined in another .cu.obj file

后端 未结 3 2013
眼角桃花
眼角桃花 2021-01-14 10:15

I am trying to compile a cuda project that someone sent me. Though the compile stage passes, the link stage is failing. Below is an example of the error:

Err         


        
相关标签:
3条回答
  • 2021-01-14 10:44

    This is just a guess, but if this is visual studio, I've seen this case before when the code is in a .cu file that is #included. In that case it should not also be compiled as a source file. To avoid this, right click on one of the files (hard to tell which from your description) and select properties, and then find and check the "exclude from build" check box.

    0 讨论(0)
  • 2021-01-14 10:58

    Had the same problem with a number of files, and was confused because the multiple definition problems usually are handled by guarding ala.

    # ifndef Function_name_Guard
    #define Function_name
    your code
    #endef % Function_name_Guard
    

    What worked was to instead omit the .cu files, and only keep the main file.

    0 讨论(0)
  • 2021-01-14 11:05

    Looks like your decode_p4.cu 3level_1.cu include these function more than ones, focus on the file defining these function.

    Make sure to put the declarations in .cuh file (same as head file in c) and include the cuh instead of cu files, then check out the include guards.

    Good Luck, Bro!

    0 讨论(0)
提交回复
热议问题