From: ptkwt@...1.aracnet.com (Phil Tomson) Date: 2002-06-11T16:19:28+09:00 Subject: SWIG, C++ and static member variables OK, my terminology may not be correct in C++ terms (I've been doing a lot of Ruby and not a lot of C++ until the last few weeks), but, say I've got a C++ class with a class variable (statically scoped), like: //Person.h class Person { static unsigned numPeople; const char* name; unsigned age; public: Person(const char* nm, unsigned age=0); Person(const char* nm, int age=0); static unsigned numberOfPeople() { return numPeople; } void identify() const; }; unsigned Person::numPeople = 0; //end of Person.h I did: swig -c++ -ruby Person.i g++ -c Person.cpp g++ -c Person.cc g++ -c Person_wrap.cxx -I /usr/lib/ruby/1.6/i686-linux-gnu g++ -shared Person.o Person_wrap.o -o Person.so Trying to compile that shared lib gave me: Person_wrap.o(.data+0x20): multiple definition of `Person::numPeople' Person.o(.data+0x0): first defined here collect2: ld returned 1 exit status So SWIG interpretted numPeople as a static member function instead of as a static variable (class variable). Anyway to get around this? Phil