'strlen' not declared

244 views
Skip to first unread message

PrimeCenter

unread,
Oct 12, 2010, 1:43:58 AM10/12/10
to cython-users
Perhaps I should post to the pymssql board but I will try here first.
Basically I am trying to get pymssql installed on a mac. It requires
cython. There are numerous build errors associated with cython and I
tried a simple one-liner to try and isolate the problem.

File test.pyx contains:
from stdlib cimport strlen

I then run...
cython -a test.pyx

Here is the output:
warning: /Users/blank/Downloads/pymssql-1.9.908/test.pyx:1:0: 'stdlib'
is deprecated, use 'libc.stdlib'

Error converting Pyrex file to C:
------------------------------------------------------------
...
from stdlib cimport strlen
^
------------------------------------------------------------

/Users/blank/Downloads/pymssql-1.9.908/test.pyx:1:0: 'strlen.pxd' not
found

Error converting Pyrex file to C:
------------------------------------------------------------
...
from stdlib cimport strlen
^
------------------------------------------------------------

/Users/blank/Downloads/pymssql-1.9.908/test.pyx:1:20: Name 'strlen'
not declared in module 'stdlib'

I don't see strlen.pxd any where.

Any help appreciated.
Chris

Matthew Brett

unread,
Oct 12, 2010, 2:44:08 AM10/12/10
to cython...@googlegroups.com
Hi,

On Mon, Oct 11, 2010 at 10:43 PM, PrimeCenter <ch...@augmentedprime.com> wrote:
> Perhaps I should post to the pymssql board but I will try here first.
> Basically I am trying to get pymssql installed on a mac.  It requires
> cython.  There are numerous build errors associated with cython and I
> tried a simple one-liner to try and isolate the problem.
>
> File test.pyx contains:
> from stdlib cimport strlen
>
> I then run...
> cython -a test.pyx
>
> Here is the output:
> warning: /Users/blank/Downloads/pymssql-1.9.908/test.pyx:1:0: 'stdlib'
> is deprecated, use 'libc.stdlib'

I think you want:

from libc.string cimport strlen

Best,

Matthew

PrimeCenter

unread,
Oct 12, 2010, 1:11:05 PM10/12/10
to cython-users
Thanks Matthew. I made the change but it cannot find strlen.pxd. Is
this file supposed to be in the Cython distribution?

Output follows. Thanks.

Error converting Pyrex file to C:
------------------------------------------------------------
...
from libc.stdlib cimport strlen
^
------------------------------------------------------------

/Users/blank/Downloads/pymssql-1.9.908/test.pyx:1:0: 'strlen.pxd' not
found

Error converting Pyrex file to C:
------------------------------------------------------------
...
from libc.stdlib cimport strlen
^
------------------------------------------------------------

/Users/blank/Downloads/pymssql-1.9.908/test.pyx:1:25: Name 'strlen'
not declared in module 'libc.stdlib'

Stefan Behnel

unread,
Oct 12, 2010, 1:18:07 PM10/12/10
to cython...@googlegroups.com
PrimeCenter, 12.10.2010 19:11:

> Thanks Matthew. I made the change but it cannot find strlen.pxd. Is
> this file supposed to be in the Cython distribution?
>
> Output follows. Thanks.
>
> Error converting Pyrex file to C:
> ------------------------------------------------------------
> ...
> from libc.stdlib cimport strlen
> ^
> ------------------------------------------------------------
>
> /Users/blank/Downloads/pymssql-1.9.908/test.pyx:1:0: 'strlen.pxd' not
> found

Well, you stripped the part of the original mail that said

from libc.string cimport strlen

Mind the "string" bit, named after string.h which defines it.

Stefan

PrimeCenter

unread,
Oct 12, 2010, 9:43:48 PM10/12/10
to cython-users
Gosh, sorry Matthew. I've been distracted at present.

I switched to "libc.string" and it works just fine. I should be able
to use this knowledge to get pymssql working.

I appreciate your help very much!

Thanks,
Chris

PrimeCenter

unread,
Oct 13, 2010, 11:12:04 AM10/13/10
to cython-users
I thought I would provide an update that after making a series of
required changes to pymssql cython files I was able to get a good
compilation on Mac OS X Snow Leopard. I can 'import pymssql' without
issue.

The changes required were several additional changes to references
such as above as well as an additional import for type 'bool' as:
from cpython cimport bool

Thanks,
Chris

Samuel Bronson

unread,
Oct 14, 2010, 7:56:11 AM10/14/10
to cython...@googlegroups.com

I hope you sent them a patch!

Salman

unread,
Apr 11, 2012, 5:16:52 PM4/11/12
to cython...@googlegroups.com
Matthew Brett <matthew.brett <at> gmail.com> writes:

>
> Hi,
>
> On Mon, Oct 11, 2010 at 10:43 PM, PrimeCenter <chris <at> augmentedprime.com>


Hi Matt,

I am getting the same error when compiling a.pyx file though I am correctly
importing from libc as under:

from libc.stdint cimport uint8_t, uint16_t, uint32_t, int8_t, int16_t, int32_t
from libc.stdlib cimport malloc,free

Errors that I get are as follows:

from libc.stdint cimport uint8_t, uint16_t, uint32_t, int8_t, int16_t, int32_t
^
------------------------------------------------------------

/home/me/test.pyx:6:0: 'uint8_t.pxd' not found

Error converting Pyrex file to C:
------------------------------------------------------------
...

# Wierd thing about cython: defines are hard to import so we have to track the
# sizes in two places
cdef int ETH_ALEN=6
cdef int PACKET_BUFFER = 2048

from libc.stdint cimport uint8_t, uint16_t, uint32_t, int8_t, int16_t, int32_t
^
------------------------------------------------------------
/home/me/test.pyx:6:25: Name 'uint8_t' not declared in module 'libc.stdint'

Any ideas??

Stefan Behnel

unread,
Apr 12, 2012, 1:56:03 AM4/12/12
to cython...@googlegroups.com
Salman, 11.04.2012 23:16:
> Matthew Brett writes:

>> On Mon, Oct 11, 2010 at 10:43 PM, PrimeCenter wrote:
>>> Perhaps I should post to the pymssql board but I will try here first.
>>> Basically I am trying to get pymssql installed on a mac. It requires
>>> cython. There are numerous build errors associated with cython and I
>>> tried a simple one-liner to try and isolate the problem.
>>>
>>> File test.pyx contains:
>>> from stdlib cimport strlen
>>>
>>> I then run...
>>> cython -a test.pyx
>>>
>>> Here is the output:
>>> warning: /Users/blank/Downloads/pymssql-1.9.908/test.pyx:1:0: 'stdlib'
>>> is deprecated, use 'libc.stdlib'
>>
>> I think you want:
>>
>> from libc.string cimport strlen
>
> I am getting the same error when compiling a.pyx file though I am correctly
> importing from libc as under:
>
> from libc.stdint cimport uint8_t, uint16_t, uint32_t, int8_t, int16_t, int32_t
> from libc.stdlib cimport malloc,free
>
> Errors that I get are as follows:
>
> from libc.stdint cimport uint8_t, uint16_t, uint32_t, int8_t, int16_t, int32_t
> ^
> ------------------------------------------------------------
>
> /home/me/test.pyx:6:0: 'uint8_t.pxd' not found
>
> Error converting Pyrex file to C:
> ------------------------------------------------------------
> ...
> # Wierd thing about cython: defines are hard to import so we have to track the
> # sizes in two places
> cdef int ETH_ALEN=6
> cdef int PACKET_BUFFER = 2048
>
> from libc.stdint cimport uint8_t, uint16_t, uint32_t, int8_t, int16_t, int32_t
> ^
> ------------------------------------------------------------
> /home/me/test.pyx:6:25: Name 'uint8_t' not declared in module 'libc.stdint'
>
> Any ideas??

The usual question at this point: what version of Cython are you using?
Look through the file Cython/Includes/libc/stdint.pxd to see if the
declaration is in there.

Stefan

Stefan Behnel

unread,
Apr 12, 2012, 3:08:32 AM4/12/12
to cython...@googlegroups.com
> # Wierd thing about cython: defines are hard to import so we have to track the
> # sizes in two places
> cdef int ETH_ALEN=6
> cdef int PACKET_BUFFER = 2048

BTW, does anyone know what this "defines are hard to import" is supposed to
mean? I can't remember a bug report about something like this...

Stefan

Dag Sverre Seljebotn

unread,
Apr 12, 2012, 4:17:29 AM4/12/12
to cython...@googlegroups.com

I think the OP just doesn't know about this trick:

cdef extern from "myheader.h":
cdef enum:
ETH_ALEN


Dag

Vitja Makarov

unread,
Apr 12, 2012, 4:22:17 AM4/12/12
to cython...@googlegroups.com
2012/4/12 Dag Sverre Seljebotn <d.s.se...@astro.uio.no>:

The hard thing is exporting enums into python space.

--
vitja.

Reply all
Reply to author
Forward
0 new messages