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

  • SEARCH
  • Home
  • 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 9018499
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 16, 20262026-06-16T04:32:33+00:00 2026-06-16T04:32:33+00:00

I am trying to include some CUDA code in a C project. To do

  • 0

I am trying to include some CUDA code in a C project. To do this, I am compiling the CUDA source (.cu file) to a static library (.lib, I’m developing in Windows). I then wish to link in this static library to my C project. However, my linker is complaining about this step, and I believe it’s because of a C/C++ linkage problem. The specific errors I am getting look something like this:

 Undefined symbol '_cudaMallocHost@8' referenced in "cufft object file.lib".

I am using CUDA 5.0 and I’m working in Visual Studio 10 to write and compile the CUDA source on a Windows 7 machine.

First, I have a .cu source file which compiles to a static library (“cufft object file.lib”) just fine. I wrapped the whole thing in extern C { }. It looks something like this:

extern "C" {

#include <cuda.h>
#include <cufft.h>

int myCUDAfunction()
{
    //Some CUDA code
}

}

To go along with this, I made a header file with a list of functions define in the .cu source (“myCUDAheader.h”) whose contents are just a series of function prototypes:

int myCUDAfunction();

etc

Finally in my C project I add the static library and include the header file.

Before I started declaring the functions in the CUDA source .cu file with extern "C", the linker complained about missing the symbols for those functions. They must be getting compiled correctly to C linkage now, but the actual CUDA functions (such as cudaMalloc) still seem to have C++ linkage. How do I get around this?

  • 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-06-16T04:32:34+00:00Added an answer on June 16, 2026 at 4:32 am

    Have you included the CUDA headers and linked cudart.lib to your C application? If not you will probably need to do this as your static library will not include the actual CUDA library implementation. Also, I think the order in which you link them matters, I can’t remember off the top my head if it’s your library then cudart.lib or the other way around. If the worst comes to the worst you may have to set up your C project as a CUDA project.

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

Sidebar

Related Questions

I'm trying include this barcode source code Stefanhafeneger - Barcode github.com to my project
I'm trying to include some (effectivly) static XML data in an HTML file, and
I'm trying to include some Visa Code into my mex file but can't figure
I am trying to compile a code that has a include directory with some
I need some help trying to match a C include file with full path
I'm trying to include some SMTP settings in my ASP.NET MVC project by adding
I'm trying ton include some JSF into my webapp. For the components lib I've
I am trying to include some dependencies in my Maven project. These dependencies are
I am trying to include some xml layouts in another xml layout file and
I'm currently trying to work with the python Dendropy library and include some PAUP

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.