Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 3427374
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 18, 20262026-05-18T06:49:43+00:00 2026-05-18T06:49:43+00:00

This question is very much related to: A) How to separate CUDA code into

  • 0

This question is very much related to:

A) How to separate CUDA code into multiple files

B) Link error LNK2005 when trying to compile several CUDA files together

Following advice from here:
https://meta.stackexchange.com/questions/42343/same-question-but-not-quite
and here
https://meta.stackexchange.com/questions/8910/asking-a-similar-but-not-the-same-question

I am asking a very similar question but I want to be absolutely clear about where is the difference between my question and the questions linked above.

I was getting the linker errors from the title when including a header file, which contained the definition of a __device__ function, into multiple source files.

This is different from Link A) where the same errors occur with __kernel__ functions because __device__ according to the CUDA manual implies inline:

In device code compiled for devices of compute capability 1.x, a __device__ function is always inlined by default. The __noinline__ function qualifier however can be used as a hint for the compiler not to inline the function if possible (see Section E.1).

Link B) is more related (and one answer correctly points out that it seems not to get inlined no matter what the manual says) but link B) refers to a header shipped by NVIDIA rather than a own header so while the problem is most likely to lie within my header file, it is most unlikely to lie within a NVIDIA header file. In other words it is likely that Link B) and my questions have different answers.

In the meantime I have found out that declaring a function as __device__ inline solves the problem so the above is only to document the solution for the rest of the world.

The open question is the reason for that behaviour.

Possible explanations I came up with:

  • The manual is wrong
  • nvcc -arch=compute_11 does not qualify as “compiling for devices of compute capability 1.x” or there is a bug in nvcc
  • this is MS-VS specific and does work on platforms tested by NVIDIA
  • I have a severe misconception about how inline works. A non cuda related example ca ne found here: Multiply defined linker error using inlined functions My understanding is the one expressed by “caf” there that “the compiler shouldn’t generate an external definition of the function, so it shouldn’t bother the linker” others over there seemed to disagree.

I’d greatly apprechiate if someone with more insght could clarify what is happening here.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-18T06:49:44+00:00Added an answer on May 18, 2026 at 6:49 am

    In MS VS, as well as in gcc and possibly other compilers (but not in the one referenced by your “multiply defined linker error” link), inline implies static by default. You can force a function to be extern inline, but, unless you do, the compiler either won’t place an external definition of the function into the object file, or will mark it as safe to duplicate somehow.

    HOWEVER, nowhere in the documentation does it say that CUDA __device__ functions are effectively declared inline (and therefore static). The documentation says that the function is “always inlined by default”. There’s a subtle difference.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

My question is about memory use and objects in actionscript 2. If I have
This is beyond both making sense and my control. That being said here is
I have found this example on StackOverflow: var people = new List<Person> { new
I want to use a temp directory that will be unique to this build.
I'm trying to build a C++ extension for python using swig. I've followed the
After having read Ian Boyd 's constructor series questions ( 1 , 2 ,
I have a new web app that is packaged as a WAR as part
(please excuse that I didn't use aliases). I would like my query output to
Let say I have the following desire, to simplify the IConvertible's to allow me
I have a login.jsp page which contains a login form. Once logged in the

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.