# linking error betwwen c and cu

**URL:** <https://forums.developer.nvidia.com/t/linking-error-betwwen-c-and-cu/22635>\
**Category:** CUDA Programming and Performance\
**Created:** [May 26, 2011, 8:54am UTC](https://forums.developer.nvidia.com/t/linking-error-betwwen-c-and-cu/22635 "2011-05-26T08:54:54Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![arthshah1](https://developer.download.nvidia.com/images/forums/profile-default-devtalk-84.png) [@arthshah1](https://forums.developer.nvidia.com/u/arthshah1)\
**Post date:** [May 26, 2011, 8:54am UTC](https://forums.developer.nvidia.com/t/linking-error-betwwen-c-and-cu/22635/1 "2011-05-26T08:54:54Z")

</div>

hey,

I am trying to use CUDA in files which are primarily written in .c format. I converted one of them where I want to write my CUDA kernels to .cu file.  
The .cu file calls a function lying in one of the .c files, so I get an error while linking them.

The files—

## .cu file:

#include “a.h”  
extern “C”{  
void somefunction(){

…  
cfunction();  
…  
cfunction(Matrix);

…

## } }

## .c file:

#include “a.h”  
void cfunction(MatriPtr Matrix){

…

## }

## .h file:

typedef struct … MatrixPtr

## … #ifdef **STDC** extern “C” void somefunction(); extern void cfunction(MatrixPtr ); #else extern void cfunction();

error: undefined reference to “cfuction(MatriPtr )”

I read somewhere that I should have an extern “C” linkage also for cfunction().  
When I try this I get the error saying " more than one instance of overloaded function “cfunction” has “C” linkage" while compiling the .cu file.

Can anyone help me here?

thnx in advance,  
Arth.
