help-gplusplus
[Top][All Lists]
Advanced

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

Re: g++/gcc compatibility issue.


From: Robert Heller
Subject: Re: g++/gcc compatibility issue.
Date: Tue, 14 Mar 2006 22:21:34 +0100

  "Vinod" <groups.vinod@gmail.com>,
  In a message on 14 Mar 2006 11:02:28 -0800, wrote :

"> Hi,
"> 
"> I am trying to compile a C++ application using g++, and I have a
"> C-library which was compiled using gcc. When I try to link my C++
"> application with the C-library, I face linker errors related to
"> undefined symbol references (even though the functions are actually
"> defined in the libraries). Is there any option/flag in g++/gcc for C++
"> applications to link to C-libraries. 

Did you wrap the C-code function declarations with 'extern "C"'?  If
you don't, the C++ compiler will 'mangle' the names (to allow for
overloading).  Eg:

#if defined(__cplusplus)
extern "C"
{
#endif

int someCfunction(int arg1, double arg2);
int someotherCfunction(char *foo);

#if defined(__cplusplus)
}
#endif



"> 
"> Thanks much.
"> 
"> - Vinod.
"> 
">                                                            

Robert Heller             -- 978-544-6933
Deepwoods Software        -- Linux Installation and Administration
http://www.deepsoft.com/  -- Web Hosting, with CGI and Database
heller@deepsoft.com       -- Contract Programming: C/C++, Tcl/Tk






               


reply via email to

[Prev in Thread] Current Thread [Next in Thread]