hhatto / pgmagick

pgmagick is a yet another boost.python based wrapper for GraphicsMagick/ImageMagick.
MIT License
147 stars 33 forks source link

undefined symbol: _ZNK6Magick14DrawableAffineclEPN9MagickLib12_DrawContextE #42

Closed vigo332 closed 6 years ago

vigo332 commented 6 years ago

Hi, Developer,

I tried to install pgmagick on Red Hat 6.9 with customized boost, imagemagick and GraphicsMagick installation locations. I tried to do the source install as pip install does not honor the BOOST_DIR BOOST_LIB BOOST_INC env variables.

I changed the setup.py accordingly to include BOOST_INC, imagemagick and GraphicsMagick, and the src/Makefile: for setup.py

19 search_include_dirs = ['/usr/local/include/GraphicsMagick/',
 20                        '/usr/include/GraphicsMagick/',
 21                        '/home2/s167891/installs/GraphicsMagick/include',
 22                        '/home2/s167891/installs/imagemagick/incldue']
 23 
 24 search_library_dirs = ['/usr/local/lib64/', '/usr/lib64/',
 25                        '/usr/local/lib/', '/usr/lib/',
 26                        '/home2/s167891/installs/GraphicsMagick/lib',
 27                        '/home2/s167891/installs/imagemagick/lib']
 28 
 29 search_pkgconfig_dirs = ['/usr/local/lib/pkgconfig/', '/usr/local/lib64/pkgconfig/',
 30                          '/usr/lib/pkgconfig/', '/usr/lib64/pkgconfig']
 31 
 32 if 'BOOST_INC' in os.environ:
 33     include_dirs.append(os.environ['BOOST_INC'])
 34     search_library_dirs.append(os.environ['BOOST_LIB'])
 35     search_include_dirs.append(os.environ['BOOST_INC'])
 36     library_dirs.append(os.environ['BOOST_LIB'])

for src/Makefile

 1 CC = g++
  2 FLAGS = -Wall
  3 INCS = -I$(PYTHONPATH)/../include/python2.7 -I$(BOOST_INC) -I$(MAGICK_HOME)/include/Grap hicsMagick
  4 
  5 
  6 
  7 SO = _pgmagick.so
  8 LIBS = -lboost_python -lGraphicsMagick -L$(BOOST_LIB) -L$(MAGICK_HOME)/lib
  9 
 10 LINK_FLAGS = -fPIC -shared
 11 CPPFLAGS = -DPGMAGICK_LIB_GRAPHICSMAGICK_1_3_26 -DPGMAGICK_LIB_GRAPHICSMAGICK_1_3_24 -DPGMAGICK_LIB_GRAPHICSMAGI    CK_1_3_22 -DPGMAGICK_LIB_GRAPHICSMAGICK_1_3_20 -DPGMAGICK_LIB_GRAPHICSMAGICK_1_3_19 -DPGMAGICK_LIB_GRAPHICSMAGIC    K_1_3_6 -DPGMAGICK_LIB_GRAPHICSMAGICK_1_3_x
 12 #-D_LIBRARY_VERSION="1.3.27"

127 $(SO): $(OBJS)
128     $(CC) $(CPPFLAGS) $(LIBS) $(LINK_FLAGS) -o $(SO) $^
129 
130 .cpp.o:
131     $(CC) $(CPPFLAGS) $(FLAGS) $(INCS) $(LINK_FLAGS) -o $@ -c $<
132 
133 clean:
134     rm -rf $(OBJS) $(SO)

The python setup.py install seems to have successfully completed, and all the *cpp files are compiled and I have the _pgmagick.so

........ skipping g++ compiling message ....... creating build/bdist.linux-x86_64 creating build/bdist.linux-x86_64/egg creating build/bdist.linux-x86_64/egg/pgmagick copying build/lib.linux-x86_64-2.7/pgmagick/init.py -> build/bdist.linux-x86_64/egg/pgmagick copying build/lib.linux-x86_64-2.7/pgmagick/_version.py -> build/bdist.linux-x86_64/egg/pgmagick copying build/lib.linux-x86_64-2.7/pgmagick/api.py -> build/bdist.linux-x86_64/egg/pgmagick copying build/lib.linux-x86_64-2.7/pgmagick/_pgmagick.so -> build/bdist.linux-x86_64/egg/pgmagick byte-compiling build/bdist.linux-x86_64/egg/pgmagick/init.py to init.pyc byte-compiling build/bdist.linux-x86_64/egg/pgmagick/_version.py to _version.pyc byte-compiling build/bdist.linux-x86_64/egg/pgmagick/api.py to api.pyc creating stub loader for pgmagick/_pgmagick.so byte-compiling build/bdist.linux-x86_64/egg/pgmagick/_pgmagick.py to _pgmagick.pyc creating build/bdist.linux-x86_64/egg/EGG-INFO copying pgmagick.egg-info/PKG-INFO -> build/bdist.linux-x86_64/egg/EGG-INFO copying pgmagick.egg-info/SOURCES.txt -> build/bdist.linux-x86_64/egg/EGG-INFO copying pgmagick.egg-info/dependency_links.txt -> build/bdist.linux-x86_64/egg/EGG-INFO copying pgmagick.egg-info/top_level.txt -> build/bdist.linux-x86_64/egg/EGG-INFO writing build/bdist.linux-x86_64/egg/EGG-INFO/native_libs.txt zip_safe flag not set; analyzing archive contents... creating dist creating 'dist/pgmagick-0.7.2-py2.7-linux-x86_64.egg' and adding 'build/bdist.linux-x86_64/egg' to it removing 'build/bdist.linux-x86_64/egg' (and everything under it) Processing pgmagick-0.7.2-py2.7-linux-x86_64.egg Removing /home2/s167891/.conda/envs/catmaid/lib/python2.7/site-packages/pgmagick-0.7.2-py2.7-linux-x86_64.egg Copying pgmagick-0.7.2-py2.7-linux-x86_64.egg to /home2/s167891/.conda/envs/catmaid/lib/python2.7/site-packages pgmagick 0.7.2 is already the active version in easy-install.pth

Installed /home2/s167891/.conda/envs/catmaid/lib/python2.7/site-packages/pgmagick-0.7.2-py2.7-linux-x86_64.egg Processing dependencies for pgmagick==0.7.2 Finished processing dependencies for pgmagick==0.7.2

But what I have is

$ python
Python 2.7.13 |Continuum Analytics, Inc.| (default, Dec 20 2016, 23:09:15) 
[GCC 4.4.7 20120313 (Red Hat 4.4.7-1)] on linux2
Type "help", "copyright", "credits" or "license" for more information.
Anaconda is brought to you by Continuum Analytics.
Please check out: http://continuum.io/thanks and https://anaconda.org
>>> import pgmagick
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "pgmagick/__init__.py", line 1, in <module>
    from pgmagick import _pgmagick
ImportError: pgmagick/_pgmagick.so: undefined symbol: _ZNK6Magick14DrawableAffineclEPN9MagickLib12_DrawContextE
>>> from pgmagick import gminfo
Segmentation fault

Please help.

Thanks very much

komackaj commented 6 years ago

Hi,

what shared library is your build linked against? Could you send result of ldd for your _pgmagick.so ? ldd {path_to_python_env}/pgmagick/_pgmagick*.so

This should also show us whether your BOOST_LIB is registered with ldconfig.

vigo332 commented 6 years ago

Hi, @komackaj

Thanks for replying again. Here it is.


$ ldd _pgmagick.so 
    linux-vdso.so.1 =>  (0x00007ffff7ffe000)
    libboost_python.so.1.54.0 => /apps/boost/1.54.0/lib/libboost_python.so.1.54.0 (0x00007ffff718e000)
    libGraphicsMagick.so.3 => /home2/s167891/installs/GraphicsMagick/lib/libGraphicsMagick.so.3 (0x00007ffff6c8f000)
    libstdc++.so.6 => /cm/shared/apps/gcc/5.4.0/lib64/libstdc++.so.6 (0x00007ffff6901000)
    libm.so.6 => /lib64/libm.so.6 (0x00007ffff6663000)
    libgcc_s.so.1 => /cm/shared/apps/gcc/5.4.0/lib64/libgcc_s.so.1 (0x00007ffff644c000)
    libc.so.6 => /lib64/libc.so.6 (0x00007ffff60b8000)
    libutil.so.1 => /lib64/libutil.so.1 (0x00007ffff5eb5000)
    libpthread.so.0 => /lib64/libpthread.so.0 (0x00007ffff5c97000)
    libdl.so.2 => /lib64/libdl.so.2 (0x00007ffff5a93000)
    librt.so.1 => /lib64/librt.so.1 (0x00007ffff588b000)
    libfreetype.so.6 => /usr/lib64/libfreetype.so.6 (0x00007ffff55ed000)
    libX11.so.6 => /usr/lib64/libX11.so.6 (0x00007ffff52b0000)
    libz.so.1 => /lib64/libz.so.1 (0x00007ffff509a000)
    libgomp.so.1 => /cm/shared/apps/gcc/5.4.0/lib/../lib64/libgomp.so.1 (0x00007ffff4e78000)
    /lib64/ld-linux-x86-64.so.2 (0x0000003de4a00000)
    libxcb.so.1 => /usr/lib64/libxcb.so.1 (0x00007ffff4c59000)
    libXau.so.6 => /usr/lib64/libXau.so.6 (0x00007ffff4a55000)
komackaj commented 6 years ago

So here is mine, for comparision (from Ubuntu)

$ ldd  _pgmagick.so 
    linux-vdso.so.1 =>  (0x00007ffe7cdb7000)
    libboost_python-py27.so.1.54.0 => /usr/lib/x86_64-linux-gnu/libboost_python-py27.so.1.54.0 (0x00007ff153779000)
    libGraphicsMagick.so.3 => /usr/lib/libGraphicsMagick.so.3 (0x00007ff1524de000)
    libGraphicsMagick++.so.3 => /usr/lib/libGraphicsMagick++.so.3 (0x00007ff15350e000)
    libstdc++.so.6 => /usr/lib/x86_64-linux-gnu/libstdc++.so.6 (0x00007ff15320a000)
    libm.so.6 => /lib/x86_64-linux-gnu/libm.so.6 (0x00007ff1521d8000)
    libgcc_s.so.1 => /lib/x86_64-linux-gnu/libgcc_s.so.1 (0x00007ff152ff4000)
    libc.so.6 => /lib/x86_64-linux-gnu/libc.so.6 (0x00007ff152a0d000)
    libpthread.so.0 => /lib/x86_64-linux-gnu/libpthread.so.0 (0x00007ff152dd6000)
    libdl.so.2 => /lib/x86_64-linux-gnu/libdl.so.2 (0x00007ff14fa47000)
    libfreetype.so.6 => /usr/lib/x86_64-linux-gnu/libfreetype.so.6 (0x00007ff15185f000)
    libX11.so.6 => /usr/lib/x86_64-linux-gnu/libX11.so.6 (0x00007ff150a2a000)
    libjbig.so.0 => /usr/lib/x86_64-linux-gnu/libjbig.so.0 (0x00007ff151fca000)
    liblcms2.so.2 => /usr/lib/x86_64-linux-gnu/liblcms2.so.2 (0x00007ff151d74000)
    libtiff.so.5 => /usr/lib/x86_64-linux-gnu/libtiff.so.5 (0x00007ff151b02000)
    libjasper.so.1 => /usr/lib/x86_64-linux-gnu/libjasper.so.1 (0x00007ff151608000)
    libjpeg.so.8 => /usr/lib/x86_64-linux-gnu/libjpeg.so.8 (0x00007ff1513b3000)
    libpng12.so.0 => /lib/x86_64-linux-gnu/libpng12.so.0 (0x00007ff15118d000)
    libwmflite-0.2.so.7 => /usr/lib/x86_64-linux-gnu/libwmflite-0.2.so.7 (0x00007ff150f71000)
    libXext.so.6 => /usr/lib/x86_64-linux-gnu/libXext.so.6 (0x00007ff150d5f000)
    libbz2.so.1.0 => /lib/x86_64-linux-gnu/libbz2.so.1.0 (0x00007ff15081a000)
    libxml2.so.2 => /usr/lib/x86_64-linux-gnu/libxml2.so.2 (0x00007ff1504b4000)
    libz.so.1 => /lib/x86_64-linux-gnu/libz.so.1 (0x00007ff15029b000)
    liblzma.so.5 => /lib/x86_64-linux-gnu/liblzma.so.5 (0x00007ff14fe6a000)
    libgomp.so.1 => /usr/lib/x86_64-linux-gnu/libgomp.so.1 (0x00007ff15008c000)
    /lib64/ld-linux-x86-64.so.2 (0x00007ff153ee1000)
    libxcb.so.1 => /usr/lib/x86_64-linux-gnu/libxcb.so.1 (0x00007ff14fc4b000)
    libXau.so.6 => /usr/lib/x86_64-linux-gnu/libXau.so.6 (0x00007ff14f843000)
    libXdmcp.so.6 => /usr/lib/x86_64-linux-gnu/libXdmcp.so.6 (0x00007ff14f63d000)

The main issue is, your pgmagick.so isn't linked against GM C++ library, you need to add -lGraphicsMagick++ to your LIBS in src/Makefile

Next difference is that on my system libgraphicsMagick.so loads multiple external codecs for various image formats - but maybe you have it statically linked (makes sense for sandboxed environment). I recommend to test reading / writing an common image format (e.g. PNG or JPG) after sucessfull importing python module to check the GM library build.

komackaj commented 6 years ago

@vigo332 Hi, have you been able to solve this?

vigo332 commented 6 years ago

@komackaj Yes. Adding -lGraphicsMagick++ solved the problem. Apologies for late response.