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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 30, 20262026-05-30T00:38:05+00:00 2026-05-30T00:38:05+00:00

I have a large project in C and i’m trying to integrate some Cuda

  • 0

I have a large project in C and i’m trying to integrate some Cuda kernels in it. I’m compiling my c-files with “gcc -c main.c” and my .cu files with “nvcc -c cuda_GMRES.cu” and then I try to link the 2 object files with nvcc: “nvcc -o main.o cuda_GMRES.o” and receive the following error:

/usr/lib/gcc/x86_64-redhat-linux/4.1.2/../../../../lib64/crt1.o: In function
_start':
(.text+0x20): undefined reference to
main’
collect2: ld returned 1 exit status

It’s the first time I’m trying to combine cuda with C files and I might have done something wrong.Can someone help me please. I’m on a GPU Cluster with Rocks OS.

My main.c file:

#include <stdio.h>
#include <math.h> 
#include "cuda_wrapper.h"   //header containing wrapper function
//cuda_GMRES that calls the kernel   cuda_dot

int main (int argc,char* argv[])
{
//content  
//bla bla bla
//cuda Function call  
  cuda_GMRES(50); 
   return 0;
}

My cuda_wrapper.h file:

#ifndef Cuda_GMRES_cuda_wrapper_h
#define Cuda_GMRES_cuda_wrapper_h
//wrapper function declaration

void cuda_GMRES(double a);
#endif

My cuda_GMRES.cu file that contains the kernel calling function:

#include <stdio.h>
#include "cuda_wrapper.h"
#include "cuda_dot.cu"   

//kernel declaration
__global__ void cuda_dot();

//kernel calling function
extern "C"
void cuda_GMRES(double a)
{
double b;

double *dev_a;
double *res;

cudaMemcpy(dev_a, &a, sizeof(double), cudaMemcpyHostToDevice );
cuda_dot<<< 1, 1 >>>(*dev_a, res );
cudaMemcpy(&b, res, sizeof(double), cudaMemcpyDeviceToHost );
}    

My cuda_dot.cu file that contains the kernel:

__global__ void cuda_dot(double a, double *help)
{
   *help=2*a;
}
  • 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-30T00:38:07+00:00Added an answer on May 30, 2026 at 12:38 am

    Your linking command appears to contain a fatal error. Supposing you first compile two objects like this:

    gcc -c main.c
    nvcc -c cuda_GMRES.cu 
    

    you should have two object files main.o and cuda_GMRES.o. You then do this:

    nvcc -o main.o cuda_GMRES.o
    

    This command says “link a program file called main.o using cuda_GMRES.o”, ie. overwrite main.o. It is for this reason that the linker is complaining about a missing main subroutine, you are not supplying one (and you are destroying the object file which contains one at the same time).

    You want something like this:

    nvcc -o executable main.o cuda_GMRES.o
    

    where executable is the name of the final linked program, or

    nvcc main.o cuda_GMRES.o
    

    which will emit a default linked program called a.out

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

Sidebar

Related Questions

I have a large project but I need only some folders in my svn
I have a large project built in as3. Part of its main functionality is
I have a large project which I am compiling with GWT. During this process
I have a very large project with tons of convoluted header files that all
I have a very large project with lots of files. I need to extract
I have a large project that has > 1000 files. When I press the
I have quite a large project to accomplish and I'm running into some dead
I have a large project that uses the Qt framework and am trying to
We have a large project using VS2008 and boost 1_42. I'm trying to upgrade
I have a large project for which I am attempting to use TDD. I

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.