Home
Reading
Searching
Subscribe
Sponsors
Statistics
Posting
Contact
Spam
Lists
Links
About
Hosting
Filtering
Features Download
Marketing
Archives
FAQ
Blog
 
Gmane
From: =?ISO-8859-1?Q?Nahuel_Defoss=E9?= <nahuel.defosse <at> gmail.com>
Subject: Re: Linking against static library in specific path
Newsgroups: gmane.comp.python.cython.user
Date: Monday 13th December 2010 14:29:23 UTC (over 6 years ago)
I found the answer, I had to add extra_objects to the Extension call, like
this:

setup(
  name = 'ipcbus',
  ext_modules=[
    Extension("ipcbus",
              sources=["ipcbus.pyx", "../lib/ipcbus/ipcbus_message.cpp"], #
Note, you can link against a c++ library instead of including the source
              include_dirs=["../lib/ipcbus"],
              libraries = ["../lib/ipcbus.a",],
              language="c++",
              extra_objects=["../lib/libipcbus.a"],),
    ],
  cmdclass = {'build_ext': build_ext},

)

I found the answer in Stackoverflow:
http://stackoverflow.com/questions/2105508/wrap-c-lib-with-cython

Sorry for bothering you


2010/12/13 Nahuel Defossé 

> I'm trying to wrap some existing C++ code which is compiled and bundled
in
> static .a libraries.
> I've followed the guide exposed at
> http://wiki.cython.org/WrappingCPlusPlus
and I wrote down this
> setup.py file:
>
> from distutils.core import setup
> from distutils.extension import Extension
> from Cython.Distutils import build_ext
>
> setup(
>   name = 'ipcbus',
>   ext_modules=[
>     Extension("ipcbus",
>               sources=["ipcbus.pyx", "../lib/ipcbus/ipcbus_message.cpp"],
#
> Note, you can link against a c++ library instead of including the source
>               include_dirs=["../lib/ipcbus"],
>               libraries = ["../lib/ipcbus.a",],
>               #extra_link_args = ["../lib/libipcbus.a",],
>               language="c++"),
>     ],
>   cmdclass = {'build_ext': build_ext},
>
> )
>
> Am I getting something wrong? libipcbus.a is a static lib, and though it
> compiles fine, I get some undefined symbols errors.
>
> The library, as the above text shows is located in ../lib/.
>
> Thanks
>
 
CD: 9ms