libraries with distutils

Glenn Pierce glennpierce at connectfree.co.uk
Wed May 11 08:41:22 EDT 2005


Hi I have a question about writing a portable setup.py script for distutils.

I have a directory structure like this.

FreeImage/
          |----------Source/
          |                    |------ FreeImage.h
          |
          |----------Dist/
          |                    |------FreeImage.lib
          |                    |------FreeImage.dll
          |
          |----------Wrapper/
                               |---------Python/
                                                   |----------build/
                                                   |
                                                   
|----------freeimagemodule.c
                                                   |----------setup.py



I want to create a setup file that works on both unix and Windows but I 
am having trouble with windows.
My setup.py file is like the following:

from distutils.core import setup, Extension

ext_module = Extension('freeimagewrapper',
                    define_macros = [('MAJOR_VERSION', '3'),
                                     ('MINOR_VERSION', '7')],
                    include_dirs = ['../../Source/'],
                    library_dirs=['../../Dist/'],
                    libraries = ['FreeImage'],     
                    sources = ['freeimagemodule.c'])

setup (name = 'freeimage',
       version = '1.0',
       author = 'Glenn Pierce',
       description = 'Python wrapper for the freeimage library',
       ext_modules = [ext_module])


I am getting link errors as vs can't seem to find ../../Dist/FreeImage.lib

The output is

running build
running build_ext
building 'freeimagewrapper' extension
C:\Program Files\Microsoft Visual Studio .NET 2003\Vc7\bin\link.exe /DLL 
/nologo
 /INCREMENTAL:NO /LIBPATH:../../Dist/ "/LIBPATH:C:\Program 
Files\Python24\libs"
"/LIBPATH:C:\Program Files\Python24\PCBuild" FreeImage.lib 
/EXPORT:initfreeimage
wrapper build\temp.win32-2.4\Release\freeimagemodule.obj 
/OUT:build\lib.win32-2.
4\freeimagewrapper.pyd 
/IMPLIB:build\temp.win32-2.4\Release\freeimagewrapper.lib

The errors are like

 Creating library build\temp.win32-2.4\Release\freeimagewrapper.lib and 
object
build\temp.win32-2.4\Release\freeimagewrapper.exp
freeimagemodule.obj : error LNK2019: unresolved external symbol 
_FreeImage_Unloa
d referenced in function _destroy

Also I guess when the python module is installed it will still need to 
find FreeImage.dll in a libray path searched by the system or will 
distutils place the actual dll and lib files where thay can be found ?

I have read the distutils guide but wasn't clear on the library section 
for ext modules.

Thanks for any help.

Glenn




More information about the Python-list mailing list