Hi Jens,<div><br></div><div>Thank you for getting back to me, much appreciated.</div><div>My source code "word.cpp" is attached.</div><div><br></div><div>OK, just to make sure we're all on the same page here, <a href="http://riverbankcomputing.co.uk/static/Docs/sip4/using.html">this is the page</a> containing the recipe I'm following.  :-)</div>
<div><br></div><div><br></div><div><br></div><div><br></div><div>        >>> What does "return (static char *)Null" mean?</div><div><br></div><div>My mistake...I meant "return (const char *)Null" ... not static....and yes I do believe NULL is used in C++.  At least the compiler didn't witch at me for it.</div>
<div><br></div><div><br></div><div>        >>> If you compile C++ code you should use g++ instead of gcc.</div><div><br></div><div>I re-ran through the entire example again using g++ instead and I still the get undefined symbol.  The difference between the two is now understood...thanks for that.</div>
<div><br></div><div><br></div><div>        >>> Do you have anything in configure.py ....</div><div>        >>> for example a line with </div><div>        >>> makefile.extra_libs = [ 'word' ]</div>
<div><br></div><div>I do, and exactly as you typed it.</div><div><br></div><div><br></div><div>        >>> That will result in the resulting Makefile having '-lword'</div>        >>> as linker option.<div>
<br></div><div>2 little snippets from the resulting makefile follow.  They also show that, in the making of the library word.so, the linker was indeed aware of the need to include my little wrapped library libword.so.</div>
<div><br></div><div><div>LIBS = -lword</div></div><div><br></div><div><div>$(TARGET): $(OFILES)</div><div><span class="Apple-tab-span" style="white-space:pre">   </span>@echo '{ global: initword; local: *; };' > word.exp</div>
<div><span class="Apple-tab-span" style="white-space:pre">      </span>$(LINK) $(LFLAGS) -o $(TARGET) $(OFILES) $(LIBS)</div></div><div><br></div><div><br></div><div>        >>> I would try ldd word.so</div><div><br></div>
<div>I did and the result show that there is indeed a dependency on the library libword.so...the one I copied into /usr/lib before doing the make.  ldd output follows:</div><div><br></div><div><div><span class="Apple-tab-span" style="white-space:pre"> </span>linux-gate.so.1 =>  (0x00ffb000)</div>
<div><span class="Apple-tab-span" style="white-space:pre">      </span>libword.so => /usr/lib/libword.so (0x00c24000)</div><div><span class="Apple-tab-span" style="white-space:pre">    </span>libstdc++.so.6 => /usr/lib/libstdc++.so.6 (0x00110000)</div>
<div><span class="Apple-tab-span" style="white-space:pre">      </span>libm.so.6 => /lib/tls/i686/cmov/libm.so.6 (0x00c6e000)</div><div><span class="Apple-tab-span" style="white-space:pre">    </span>libgcc_s.so.1 => /lib/libgcc_s.so.1 (0x00206000)</div>
<div><span class="Apple-tab-span" style="white-space:pre">      </span>libc.so.6 => /lib/tls/i686/cmov/libc.so.6 (0x00225000)</div><div><span class="Apple-tab-span" style="white-space:pre">    </span>/lib/ld-linux.so.2 (0x00cf1000)</div>
</div><div><br></div><div><br></div><div>        >>> I would use 'nm' for such checks</div><div>        >>>  Check the letter before the name of the function - if</div>        >>> it's a 'T' everything is fine (i.e. the symbol is defined in<br>
        >>> that library) but if it's a 'U' the symbol is undefined<div><br></div><div>When I use "nm -C libword.so" on my little wrapped library I see nothing in the output to suggest a "word" class or a "reverse" method.  However, when I run "nm -C word.so" against the library generated by make I get things like:</div>
<div><br></div><div><div>000021b4 d methods_Word</div><div>         U Word::Word(char const*)</div><div>         U Word::reverse() const</div><div><br></div><div>among other things.  I can provide complete outputs from both libraries if needed.</div>
<div><br></div><div>So I'm still stumped and will be researching  why I'm seeing (and not seeing) these things in the 2 libraries.  Until then, are there any</div><div>other ideas out there ?</div><div><br></div><div>
thanks,</div><div>         Gary ---</div><div><br></div><div><br></div><div><br></div><div><br></div><div><br></div><div><br></div><div><br></div><div><br></div><div><br></div><div><br></div><div><br><div><br></div><div><br>
<div class="gmail_quote">On Sat, Jan 21, 2012 at 3:51 PM, Jens Thoms Toerring <span dir="ltr"><<a href="mailto:jt@toerring.de">jt@toerring.de</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">
Hi Gary,<br>
<div class="im"><br>
On Sat, Jan 21, 2012 at 08:47:21AM -0500, Gary Fisher wrote:<br>
> So, I wrote a little C++ class called word and provided a method<br>
> called reverse which does nothing but "return (static char *)Null".<br>
<br>
</div>What does "return (static char *)Null" mean? There's no 'Null'<br>
in C++ and casting to 'static char pointer also looks rather<br>
strange (and shouldn't compile since you can't cast to some-<br>
thing that's 'static'). Do you simply want to return a char<br>
(NULL) pointer? Then<br>
<br>
  return 0;<br>
<br>
will be all you need (assuming that the function is defined<br>
to return a char pointer.<br>
<div class="im"><br>
> I then ran "gcc -o libword.so -shared word.cpp" to make my little<br>
> fictional library (as referred to in the text).<br>
<br>
</div>If you compile C++ code you should use g++ instead of gcc.<br>
<div class="im"><br>
> I then made the word.sip and configure.py files and ran configure.py.<br>
> Prior to running make I copied libword.so into /usr/lib so the linker would<br>
> find it.  Running make and 'make install' ran flawless, as did everything<br>
> until now.<br>
<br>
</div>Do you have anything in configure.py that would tell the make<br>
process that the resulting 'word.so' library will need the<br>
'libword.so' library, for example a line with<br>
<br>
makefile.extra_libs = [ 'word' ]<br>
<br>
That will result in the resulting Makefile having '-lword'<br>
as linker option.<br>
<div class="im"><br>
> At this point, if I understand the theory here, I figured I'd start up a<br>
> Python command line session and issue the command "import word" and<br>
> then try "word.reverse()".  To my surprise I got the following error:<br>
><br>
> >>> import word<br>
> Traceback (most recent call last):<br>
>   File "<stdin>", line 1, in <module><br>
> ImportError: ./word.so: undefined symbol: _ZNK4Word7reverseEv<br>
<br>
</div>So 'word.so' is the wrapper library for your original library<br>
written in C++ (which seems to be 'libword.so'), right? Looks<br>
to me as if when was 'word.so' created the linker wasn't aware<br>
that 'libword.so' would be needed when 'word.so' is used.<br>
'word.so' is also a library, so the linker will not complain<br>
when symbols aren't found while 'word.so' is created since<br>
they're then expected to be found somewhere when the library is<br>
loaded.<br>
<br>
I would try<br>
<br>
ldd word.so<br>
<br>
If 'libword.so' isn't listed as one of the libraries 'word.so'<br>
depends on then I would see this as a strong indication that<br>
my guess isn't completely off the mark.<br>
<div class="im"><br>
> I've tried numerous incantations with no luck.  I figured this would work<br>
> without my having to go and learn all about PyQT just to get it to run.<br>
<br>
</div>I don't think it's a problem about PyQt but just of the way<br>
'word.so' was created.<br>
<div class="im"><br>
> The command "Readelf -s word.so" shows the symbol is listed in the<br>
> library.<br>
<br>
</div>I would use 'nm' for such checks (if you run it with -C it<br>
will also demangle the strange names the symbols of C++ code<br>
have). Check the letter before the name of the function - if<br>
it's a 'T' everything is fine (i.e. the symbol is defined in<br>
that library) but if it's a 'U' the symbol is undefined and<br>
thus must be defined somewhere else.<br>
<br>
                               Regards, Jens<br>
<span class="HOEnZb"><font color="#888888">--<br>
  \   Jens Thoms Toerring  ________      <a href="mailto:jt@toerring.de">jt@toerring.de</a><br>
   \_______________________________      <a href="http://toerring.de" target="_blank">http://toerring.de</a><br>
</font></span></blockquote></div><br><br clear="all"><div><br></div>-- <br><div>--------------------------------------------------------------------------------------------------</div><div><span style="font-family:Arial,sans-serif"><br>
</span></div><div>
        
        
        


<p style="margin-top:0.19in;margin-bottom:0.19in;background:#ffffff">
<font color="#333333">“<font face="Arial, sans-serif"><font>Nothing
in all the world is more dangerous than sincere ignorance </font></font></font><span style="font-family:Arial,sans-serif;color:rgb(51,51,51)">and
conscientious stupidity.”</span></p>
<p style="margin-top:0.19in;margin-bottom:0.19in;background:#ffffff">
<font face="Arial, sans-serif"><font>     ~ Martin Luther King, Jr</font></font></p></div><div><p></p></div><font size="3" face="Times New Roman">



</font><br>
</div></div></div>