Linking problem w. wxPython (core_wrap.o)

Try #including Python.h first.

Yope, that did it.

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?

None, I didn't use configure, only a hand-made spaghetti Makefile. You'll find output pf wx-config--libs under "echo__wx-config_--libs". But you're right, that's what was missing.

---Makefile-------------------------------------------

···

# # wxWin + embedded Python
#

CXX = $(shell wx-config --cxx)

PROGRAM = b1
OBJECTS = $(PROGRAM).o MOREOBJECTS= $(OBJECTS) example.o example_wrap.o \
  core_wrap.o \
  libpy.o helpers.o drawlist.o
# calendar_wrap.o controls_wrap.o gdi_wrap.o grid_wrap.o html_wrap.o \
# misc_wrap.o windows_wrap.o wizard_wrap.o \

############################################
####### PYTHON
INCLUDES= -I/usr/local/include/python2.3 -I/q/wxPy/include \
  -I/q/wxPy/GTKASCII/lib/wx/include/gtk2d-2.5 # -I/usr/include/gtk-2.0 -I/usr/include/gdk-2.0 -I/usr/include/glib-2.0

CXXFLAGS = -O2 -I/usr/include/pango-1.0 -I/usr/include/freetype2 \
  -I/usr/include/glib-2.0 -I/usr/lib/glib-2.0/include -pthread -Wall
CPPFLAGS = -D__WXDEBUG__ -I${top_builddir}lib/wx/include/gtk2d-2.5 \
  -I${top_srcdir}/include -D_REENTRANT -I/usr/include/gtk-2.0 \
  -I/usr/lib/gtk-2.0/include -I/usr/include/atk-1.0 -I/usr/include/pango-1.0 \
  -I/usr/X11R6/include -I/usr/include/freetype2 -I/usr/include/glib-2.0 \
  -I/usr/lib/glib-2.0/include -D_FILE_OFFSET_BITS=64 -D_LARGE_FILES \
  -I/usr/X11R6/include

# taken from /q/wxPy/GTKASKII-build/Makefile
MONOLIB_CFLAGS= -D__WXGTK__ \
-I../src/tiff -I../src/jpeg -I../src/png \
  -I../src/zlib -I../src/expat/lib -DwxUSE_BASE=1 -D__WXDEBUG__ \
  -Ilib/wx/include/gtk2d-2.5 -I../include -D_REENTRANT \
  -I/usr/include/gtk-2.0 -I/usr/lib/gtk-2.0/include -I/usr/include/atk-1.0 \
  -I/usr/include/pango-1.0 -I/usr/X11R6/include -I/usr/include/freetype2 \
  -I/usr/include/glib-2.0 -I/usr/lib/glib-2.0/include -D_FILE_OFFSET_BITS=64 \
  -D_LARGE_FILES -I/usr/X11R6/include -O2 -pthread -Wall

SRC= /q/wxPy/src
IMI= -D__WXGTK__ -DwxUSE_BASE=1 -D__WXDEBUG__ \
  -D_FILE_OFFSET_BITS=64 -D_LARGE_FILES \
  -I$(SRC)/tiff -I$(SRC)/jpeg -I$(SRC)/png -I$(SRC)/zlib/zlib.h \
  -I$(SRC)/expat/lib -I$(SRC)/../include

# The Python library
#LIBPYTHON= $(blddir)/libpython$(VERSION).a
LIBPYTHON= /usr/local/lib/python2.3/config/libpython2.3.a
WXLIBD= /q/wxPy/GTKASCII-build/lib

WXLIBS= $(WXLIBD)/libwxexpatd.a \
      $(WXLIBD)/libwxjpegd.a \
      $(WXLIBD)/libwxpngd.a \
      $(WXLIBD)/libwxtiffd.a \
      $(WXLIBD)/libwx_gtk2d_gizmos-2.5.a \
      $(WXLIBD)/libwx_gtk2d_gl-2.5.a \
      $(WXLIBD)/libwx_gtk2d_ogl-2.5.a \
      $(WXLIBD)/libwx_gtk2d_stc-2.5.a \
      $(WXLIBD)/libwx_gtk2d_xrc-2.5.a \
      $(WXLIBD)/libwxzlibd.a
# $(WXLIBD)/libwx_gtk2d-2.5.a \

# value of `wx-config --libs`
echo__wx-config_--libs= \
-L/q/wxPy/GTKASCII/lib \
-pthread -L/usr/X11R6/lib \
-Wl,--whole-archive \
/q/wxPy/GTKASCII/lib/libwx_gtk2d-2.5.a \
-Wl,--no-whole-archive \
-lgtk-x11-2.0 -lgdk-x11-2.0 -latk-1.0 -lgdk_pixbuf-2.0 \
-lm -lpangox-1.0 -lpangoxft-1.0 -lpango-1.0 -lgobject-2.0 \
-lgmodule-2.0 -ldl -lgthread-2.0 -lpthread -lglib-2.0 \
-lpangoft2-1.0 -lpango-1.0 -lgobject-2.0 -lgmodule-2.0 \
-ldl -lglib-2.0 -lXinerama -lXxf86vm -ldl -lm

# XXX edit LIBS (in particular) to match $(blddir)/Modules/Makefile
LIBS= -lnsl -ldl -lreadline -ltermcap -lieee -lpthread -lutil \
  -lz -ltiff -lpng
LDFLAGS= -Xlinker -export-dynamic
SYSLIBS= -lm
MODLIBS=
ALLLIBS= $(IMI) $(LIBPYTHON) $(MODLIBS) $(LIBS) $(SYSLIBS) #$(WXLIBS)
##########################################

# implementation

.SUFFIXES: .o .cpp

.cpp.o :

  echo "-----------------compiling-------------------"
# swig+compile 'shadow' example #
  swig -python -c++ ./shadow/example.i
  $(CXX) -g -c ./shadow/example.cxx ./shadow/example_wrap.cxx $(INCLUDES)
# ld -shared example.o example_wrap.o -o _example.so
#########################

# compile wrappers
  $(CXX) -g -c `wx-config --cxxflags` ./src/libpy.c $(INCLUDES)
  $(CXX) -g -c `wx-config --cxxflags` ./src/drawlist.cpp $(INCLUDES)
  $(CXX) -g -c `wx-config --cxxflags` ./src/helpers.cpp $(INCLUDES) $(CPPFLAGS)

  $(CXX) -g -c `wx-config --cxxflags` ./mygtk/core_wrap.cpp $(INCLUDES)
# $(CXX) -g -c `wx-config --cxxflags` ./mygtk/calendar_wrap.cpp $(INCLUDES)
# $(CXX) -g -c `wx-config --cxxflags` ./mygtk/controls_wrap.cpp $(INCLUDES)
# $(CXX) -g -c `wx-config --cxxflags` ./mygtk/gdi_wrap.cpp $(INCLUDES)
# $(CXX) -g -c `wx-config --cxxflags` ./mygtk/grid_wrap.cpp $(INCLUDES)
# $(CXX) -g -c `wx-config --cxxflags` ./mygtk/html_wrap.cpp $(INCLUDES)
# $(CXX) -g -c `wx-config --cxxflags` ./mygtk/misc_wrap.cpp $(INCLUDES)
# $(CXX) -g -c `wx-config --cxxflags` ./mygtk/windows_wrap.cpp $(INCLUDES)
# $(CXX) -g -c `wx-config --cxxflags` ./mygtk/wizard_wrap.cpp $(INCLUDES)

# compile 'b1.cpp'
  $(CXX) -g -c `wx-config --cxxflags` $(INCLUDES) -o $@ $<

#all: # echo `wx-config --libs`

all: $(PROGRAM)
# linking
  echo "------------------linking-------------------"
$(PROGRAM): $(OBJECTS)
# $(CXX) -o $(PROGRAM) $(OBJECTS) $(ALLLIBS) `wx-config --libs`
  $(CXX) -g -o $(PROGRAM) $(MOREOBJECTS) `wx-config --libs` $(ALLLIBS) # $(CXX) -g -o $(PROGRAM) $(MOREOBJECTS) $(echo__wx-config_--libs) $(ALLLIBS)

clean: rm -f *.o $(PROGRAM)

---/Makefile-------------------------------------------

Vio wrote:

Try #including Python.h first.

Yope, that did it.

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?

None, I didn't use configure, only a hand-made spaghetti Makefile.

I was refering to wxWidgets' configure.

···

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