Linking problem w. wxPython (core_wrap.o)

Hello Robin,
First, many thanks for wxPython. Quite a piece of work.
Second, many thanks for your help. I'm still new at this (experienced python coder, but freshman c/c++). So your hints are greatly appreciated.

g++ -g -c `wx-config --cxxflags` -I/usr/local/include/python2.3 -I/q/wxPy/include -I/q/wxPy/GTKASCII/lib/wx/include/gtk2d-2.5 -o b1.o b1.cpp
In file included from /usr/local/include/python2.3/Python.h:8,
                from b1.cpp:25:
/usr/local/include/python2.3/pyconfig.h:844: warning: `_POSIX_C_SOURCE' redefined
/usr/include/features.h:171: warning: this is the location of the previous definition

IIRC, this can be corrected by changing the order that things are #included in b1.cpp.

b1.cpp's includes sequence goes something like this. Anything out of sequence?:

···

------------------------------------------------

#include <iostream>
#include <wx/string.h>

// Embedded Python interpreter
#include "Python.h"
// For compilers that support precompilation, includes "wx/wx.h".
#include "wx/wxprec.h"

// wx Py wrappers
#include "wx/wxPython/wxPython.h"

// my swig code: integrating the swing example into my code
#include "shadow/example.h"
#include "shadow/example_py.h" //these are simply SWIG-generated py
#include "shadow/runme_py.h" //code embedded in wxArrayStrings
//basic idea being to put all dependancies in one single executable
//eventually other needed wxPy python wrapper code will be put here,
//as needed

#ifdef __BORLANDC__
    #pragma hdrstop
#endif

// for all others, include the necessary headers (this file is usually all you
// need because it includes almost all "standard" wxWindows headers)
#ifndef WX_PRECOMP
    #include "wx/wx.h"
#endif
------------------------------------------------

/q/wxPy/GTKASCII-build/lib/libwxtiffd.a /q/wxPy/GTKASCII-build/lib/libwxzlibd.a -lnsl -ldl -lreadline -ltermcap -lieee -lpthread -lutil -lm `wx-config --libs`
core_wrap.o: In function `wxGetApp(void)':
/c/d/wx/wx/./mygtk/core_wrap.cpp(.text+0x23a8): multiple definition of `wxGetApp(void)'

[...]

You are linking the wx libs twice. First when you specify the .a files (which means to add all the objects in the .a into your app, probably not what you want) and second when the output of `wx-config --libs` is expanded into -L and -l flags.

Agreed. My intention was actually to get rid of the following problem:
----------------------------------------
g++ -g -o b1 b1.o example.o example_wrap.o core_wrap.o libpy.o helpers.o
drawlist.o /usr/local/lib/python2.3/config/libpython2.3.a -lnsl -ldl -lreadline
-ltermcap -lieee -lpthread -lutil -lm `wx-config --libs`

/q/wxPy/GTKASCII/lib/libwx_gtk2d-2.5.a(monolib_unzip.o): In function `unzReadCurrentFile':
monolib_unzip.o(.text+0xf6c): undefined reference to `crc32'
monolib_unzip.o(.text+0xfa0): undefined reference to `inflate'
monolib_unzip.o(.text+0xfb7): undefined reference to `crc32'
/q/wxPy/GTKASCII/lib/libwx_gtk2d-2.5.a(monolib_unzip.o): In function `unzCloseCurrentFile':
monolib_unzip.o(.text+0x1129): undefined reference to `inflateEnd'
...
monolib_imagjpeg.o(.text+0x6a2): undefined reference to `jpeg_CreateCompress'monolib_imagjpeg.o(.text+0x6f3): undefined reference to `jpeg_set_defaults'
...
monolib_imagpng.o(.text+0x9a6): undefined reference to `png_set_error_fn'
monolib_imagpng.o(.text+0x9c0): undefined reference to `png_set_read_fn'
...
/q/wxPy/GTKASCII/lib/libwx_gtk2d-2.5.a(monolib_imagtiff.o): In function `wxTIFFHandler::SaveFile(wxImage *, wxOutputStream &, bool)':
monolib_imagtiff.o(.text+0x8c9): undefined reference to `TIFFScanlineSize'
...
----------------------------------------

So, monolib comes from the main wx library.
/q/wxPy/GTKASCII/lib/libwx_gtk2d-2.5.a(monolib_unzip.o)
But I don't quite understand what it's complaining about. Seems like some image-related includes or helper files it doesn't see. Yesterday, browsing through the wxPy sources, I made the wrond assertions, took a wild guess and mistakingly included the wx libs twice, as you pointed out. Ok, since GTKASCII installation build without a hitch, I'll have a look at the config.log in my GTKASCII-build directory for more ideas. If you have any hints, please share.

Cheers,
Vio

Vio wrote:

Hello Robin,
First, many thanks for wxPython. Quite a piece of work.
Second, many thanks for your help. I'm still new at this (experienced python coder, but freshman c/c++). So your hints are greatly appreciated.

g++ -g -c `wx-config --cxxflags` -I/usr/local/include/python2.3 -I/q/wxPy/include -I/q/wxPy/GTKASCII/lib/wx/include/gtk2d-2.5 -o b1.o b1.cpp
In file included from /usr/local/include/python2.3/Python.h:8,
                from b1.cpp:25:
/usr/local/include/python2.3/pyconfig.h:844: warning: `_POSIX_C_SOURCE' redefined
/usr/include/features.h:171: warning: this is the location of the previous definition

IIRC, this can be corrected by changing the order that things are #included in b1.cpp.

b1.cpp's includes sequence goes something like this. Anything out of sequence?:

Try #including Python.h first.

[...]

Agreed. My intention was actually to get rid of the following problem:
----------------------------------------
g++ -g -o b1 b1.o example.o example_wrap.o core_wrap.o libpy.o helpers.o
drawlist.o /usr/local/lib/python2.3/config/libpython2.3.a -lnsl -ldl -lreadline
-ltermcap -lieee -lpthread -lutil -lm `wx-config --libs`

/q/wxPy/GTKASCII/lib/libwx_gtk2d-2.5.a(monolib_unzip.o): In function `unzReadCurrentFile':
monolib_unzip.o(.text+0xf6c): undefined reference to `crc32'
monolib_unzip.o(.text+0xfa0): undefined reference to `inflate'
monolib_unzip.o(.text+0xfb7): undefined reference to `crc32'

Sounds like a missing -lz

[...]

And -ljpeg, -lpng and etc., but I would have expected wx-config to output those flags if they were needed. What flags did you pass to configure?

So, monolib comes from the main wx library.
/q/wxPy/GTKASCII/lib/libwx_gtk2d-2.5.a(monolib_unzip.o)
But I don't quite understand what it's complaining about. Seems like some image-related includes or helper files it doesn't see. Yesterday, browsing through the wxPy sources, I made the wrond assertions, took a wild guess and mistakingly included the wx libs twice, as you pointed out. Ok, since GTKASCII installation build without a hitch, I'll have a look at the config.log in my GTKASCII-build directory for more ideas. If you have any hints, please share.

Is GTKASCII your install dir (specified with --prefix to configure) and GTKASCII-build your build dir? If so, is GTKASCII/bin on the path so the wx-config there is the first one found? (Check with "which wx-config") What is the output of "wx-config --libs" ?

···

--
Robin Dunn
Software Craftsman
http://wxPython.org Java give you jitters? Relax with wxPython!