Re: Making a new GCC routine visible

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



On May 19, 2012, at 1:31 PM, Jonathan Wakely wrote:

> On 19 May 2012 18:22, Amittai Aviram wrote:
>> 
>> - Defined domp_malloc (and associated routines) in a new file, domp_malloc.c, in libgomp
>> - Added domp_malloc to libgomp.map, in the list at the top of the OMP 1.0 block with label "global"
>> - Added domp_malloc.c to libgomp/Makefile.am, reconfigured GCC, and rebuilt--with language support for C, C++, and Fortran.
>> 
>> When I build an OpenMP program in C, using my altered GCC C compiler (gcc), everything works fine: the linker finds the definition of domp_malloc.  However, if I write a C++ program that calls domp_malloc, and try to build it with my special g++, the linker cannot find the definition of domp_malloc, so my build fails.  What else can I do to make domp_malloc visible to the C++ linker?
> 
> How are you declaring domp_malloc in the C++ program?
> 
> Is it a name-mangling issue, such that the C++ program is looking for
> extern "C++" void* domp_malloc(size_t) but the library defines extern
> "C" void* malloc?

Aha!  It's declared as
void * domp_malloc(size_t);
in a header I #include into my program--but I had forgotten to mark that #include as "extern 'C'."  I just tried that and it works!--

extern "C" {
#include domp_defs.h
}

So this turned out not to be a GCC issue but just my lack of practice in mixing C and C++ code.  Thank you so much for the hint!

Amittai

Amittai Aviram
PhD Student in Computer Science
Yale University
646 483 2639
amittai.aviram@xxxxxxxx
http://www.amittai.com




[Index of Archives]     [Linux C Programming]     [Linux Kernel]     [eCos]     [Fedora Development]     [Fedora Announce]     [Autoconf]     [The DWARVES Debugging Tools]     [Yosemite Campsites]     [Yosemite News]     [Linux GCC]

  Powered by Linux