[omniORB] How to link c library in omni application

zhang ji zsfunl@yahoo.com
Mon Jun 10 04:39:01 2002


Hi bjorn,

Thanks for your reply!

Actually below is the share head file (hello.h) for
the c library and omniORB c++ applicaton code:
"
#if _cplusplus
extern "C" {
#endif
extern
void hello();
#if _cplusplus
}
#endif
"

The library compile is OK and when I linked the
library to the omniORB c++ code , it reported :
"
omniApp_i.o: In function `omniApp_i::runApp(void)':
/home/shzhang/code/test_share/omniApp_i.cc:20:
undefined reference to `hello(void)'
"

As last email mentioned, by using nm I can find two
different hello() siguature in libhello.so and
omniApp_i.o.

Thanks,
Shifeng
--- bjorn rohde jensen <shamus@tdcadsl.dk> wrote:
> Hi Shifeng,
> 
>  When you want to link with C lib's from C++, you
> have
> to tell the compiler, that the functions in the lib
> have
> C style linkage. That is usually done by specifying
> the
> functions as 'extern C' in the header file of the
> lib.
> 
> Yours sincerely,
> 
> bjorn


__________________________________________________
Do You Yahoo!?
Yahoo! - Official partner of 2002 FIFA World Cup
http://fifaworldcup.yahoo.com