Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
C
cython
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Labels
Merge Requests
0
Merge Requests
0
Analytics
Analytics
Repository
Value Stream
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Commits
Open sidebar
nexedi
cython
Commits
36c08c89
Commit
36c08c89
authored
Jan 21, 2010
by
Robert Bradshaw
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Library linking demo.
parent
b5bcc8c4
Changes
4
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
42 additions
and
0 deletions
+42
-0
Demos/libraries/call_mymath.pyx
Demos/libraries/call_mymath.pyx
+5
-0
Demos/libraries/mymath.c
Demos/libraries/mymath.c
+5
-0
Demos/libraries/mymath.h
Demos/libraries/mymath.h
+1
-0
Demos/libraries/setup.py
Demos/libraries/setup.py
+31
-0
No files found.
Demos/libraries/call_mymath.pyx
0 → 100644
View file @
36c08c89
cdef
extern
from
"mymath.h"
:
double
sinc
(
double
)
def
call_sinc
(
x
):
return
sinc
(
x
)
Demos/libraries/mymath.c
0 → 100644
View file @
36c08c89
#include "math.h"
double
sinc
(
double
x
)
{
return
x
==
0
?
1
:
sin
(
x
)
/
x
;
}
\ No newline at end of file
Demos/libraries/mymath.h
0 → 100644
View file @
36c08c89
double
sinc
(
double
);
Demos/libraries/setup.py
0 → 100644
View file @
36c08c89
import
os
from
distutils.core
import
setup
from
distutils.extension
import
Extension
from
Cython.Distutils
import
build_ext
# For demo purposes, we build our own tiny library.
try
:
print
"building libmymath.a"
assert
os
.
system
(
"gcc -c mymath.c -o mymath.o"
)
==
0
assert
os
.
system
(
"ar rcs libmymath.a mymath.o"
)
==
0
except
:
if
not
os
.
path
.
exists
(
"libmymath.a"
):
print
"Error building external library, please create libmymath.a manually."
sys
.
exit
(
1
)
# Here is how to use the library built above.
ext_modules
=
[
Extension
(
"call_mymath"
,
sources
=
[
"call_mymath.pyx"
],
include_dirs
=
[
os
.
getcwd
()],
# path to .h file(s)
library_dirs
=
[
os
.
getcwd
()],
# path to .a or .so file(s)
libraries
=
[
'mymath'
])
]
setup
(
name
=
'Demos'
,
cmdclass
=
{
'build_ext'
:
build_ext
},
ext_modules
=
ext_modules
,
)
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment