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 8903233
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 15, 20262026-06-15T01:49:03+00:00 2026-06-15T01:49:03+00:00

I am having a hard time compiling a simple cuda program consiting of only

  • 0

I am having a hard time compiling a simple cuda program consiting of only two files.

The main.c looks like this:

#include "my_cuda.h"

int main(int argc, char** argv){
   dummy_gpu();
}

The cuda.h looks like this:

#ifndef MY_DUMMY
#define MY_DUMMY

void dummy_gpu();

#endif

And the my_cuda.cu file loos like this:

#include <cuda_runtime.h>
#include "my_cuda.h"

__global__ void dummy_gpu_kernel(){
   //do something
}

void dummy_gpu(){
   dummy_gpu_kernel<<<128,128>>>();
}

However if I compile I allways receive the following error:

gcc  -I/usr/local/cuda/5.0.35/include/ -c main.c
nvcc  -c my_cuda.cu
gcc  -L/usr/local_rwth/sw/cuda/5.0.35/lib64 -lcuda -lcudart -o md.exe main.o my_cuda.o 
main.o: In function `main':
main.c:(.text+0x15): undefined reference to `dummy_gpu'
collect2: ld returned 1 exit status

Thank you for your help.

  • 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-15T01:49:04+00:00Added an answer on June 15, 2026 at 1:49 am

    You have a problem with symbol name mangling. nvcc uses the host C++ compiler to compile host code, and this implies that symbol name mangling is applied to code emitted by the CUDA toolchain.

    There are two solutions to this problem. The first is to define dummy_gpu using C linkage, so change your my_cuda.cu to something like this:

    extern "C" {
    #include "my_cuda.h"
    }
    
    .....
    
    
    extern "C"
    void dummy_gpu(){
       dummy_gpu_kernel<<<128,128>>>();
    }
    

    Note that you will need to change your linkage command to this:

    gcc -L/usr/local_rwth/sw/cuda/5.0.35/lib64 -o md.exe main.o my_cuda.o -lcuda -lcudart 
    

    because the CUDA shared libraries need to be specified after the object files that use them.

    Your second alternative would be to use either g++ or nvcc to do the linking, in which case the whole problem should disappear.

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

Sidebar

Related Questions

I'm having hard time with this simple ajax call function sendreq() { $.ajax({ dataType:
I am having hard time digesting this syntax: void* operator new[](std::size_t, const std::nothrow_t&) throw();
im having hard time with this one, i want to create folder with write
I'm having hard time with this project, I'm building a boat configurator which is
I am having a super hard time compiling and using TagLib 1.6.3 in my
I'm having hard time googling this. I found a lot of articles but I
I having hard time understanding importance and benefits of Annotations and so have two
I'm having hard time wrapping my head around this. I have an array called
i'm having hard time for a pretty silly simple task i need to add
In my code, I am having hard time to wrap text in last two

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.