Hi,
I have the next problem:
I am building a C++ shared object using the SUN's workshop 5.0 compiler and
an executable using the gcc 2.8.1 compiler. Every thing works
just find until the moment I am trying to use an iostream object, from this
moment on I get the unresolved symbol error.
The C++ header :
#ifdef __cplusplus
extern "C"
#endif
void foo( );
The source:
#include "a.h"
#include <iostream.h>
#ifdef __cplusplus
extern "C"
#endif
void foo( )
{
cout << "Hello world\n";
The C source (the executable):Quote:}
#include "a.h"
#include <dlfcn.h>
#include <errno.h>
#include <stdio.h>
int main(){
void* lpHandle;
void (*lpFunc)();
lpHandle=dlopen ( "liba.so", RTLD_NOW | RTLD_LOCAL);
if ( !lpHandle )
{
perror ( "dlopen");
printf ( "%s\n", dlerror());
exit (errno );
}
lpFunc = (void(*)())(dlsym ( lpHandle, "foo"));
if ( !lpFunc)
{
perror ( "dlsym");
printf ( "%s\n", dlerror());
exit (errno );
}
(*lpFunc)();
dlclose ( lpHandle);
Every thing works fine until I start to build the executable using the gccQuote:}
compiler instead of the CC compiler.
The error I get is:
dlopen: Error 0
ld.so.1: ./a.out: fatal: relocation error: file ./liba.so: symbol
__1cDstd2l6Frn0ANbasic_ostream4Ccn0ALchar_traits4Cc____pkc_2_: referenced
symbol not found
The motivation for doing this is that I want to write an Apache's module in
C++. I have to use the CC compiler since I am using the ObjectSpace's STL.
But
the Apache was build using gcc. Using the Apache I get the same problem.
Thank you for your time.
Eyal