On 23/01/2011 10:58, Daniel Marjamäki wrote:

> I fail to use 'global_namespace':
> daniel@daniel:~/gcc/build/gcc$ ./xgcc -fplugin=./myplugin2.so -c test1.c
> cc1: error: cannot load plugin ./myplugin2.so

  You're running the C compiler (cc1) here, not the C++ one (cc1plus), because
you've passed a file with the plain .c extension to the driver.

> ./myplugin2.so: undefined symbol: global_namespace

  So it doesn't have this global variable that only exists in cc1plus.

  Either change your test file to .cpp, or add "-x c++" to the command-line.

  In general, as long as your plugin refers to global_namespace directly, it's
not going to be compatible with any of the other language sub-compilers apart
from cc1plus.  If you wanted it to work with any kind of language, I think
you'd need to look up global_namespace using dlsym (and handle the case when
it was not found), rather than linking against it directly.

    cheers,
      DaveK

Reply via email to