Cython and c++

86 views
Skip to first unread message

Daniel Burchardt

unread,
Feb 2, 2016, 4:07:32 PM2/2/16
to cython-users
Hi,

I try to run v8 in python and i can't run it... :(

setup.py
from distutils.core import setup
from distutils.extension import Extension
from Cython.Build import cythonize
from Cython.Distutils import build_ext

import os
from distutils.sysconfig import get_config_vars

(opt,) = get_config_vars('OPT')
os
.environ['OPT'] = " ".join(
    flag
for flag in opt.split() if flag != '-Wstrict-prototypes'
)

setup
(
    name
= 'helloworld',
    ext_modules
= cythonize(
 
Extension(
     
"helloworld",
     
["helloworld.pyx"],
      language
= "c++",
      libraries
= ["v8", "stdc++"],
      library_dirs
= ["v8"],
      include_dirs
= ["v8/include"],
      runtime_library_dirs
= ["v8"],
      extra_compile_args
= ["-std=c++11"],
      extra_link_args
= ["-std=c++11"],
     
#cmdclass = {'build_ext': build_ext}
 
)
   
)
)

helloworld.pyx
from libcpp cimport bool

cdef
extern from "v8.h" namespace "v8":
  cdef cppclass V8
:
       
@staticmethod
       
bool InitializeICU(const char *icu_data_file)
       
#@staticmethod
       
#void InitializeExternalStartupData(const char* directory_path)

cdef
class Script:
 
def ini(self):
        cdef
char* xyz = 'bla'

       
return V8.InitializeICU(xyz)

 
def test(self):
       
self.init()

       
return "wow"

Compilation process is OK but when i try import helloworld i see:

Traceback (most recent call last):
 
File "test.py", line 1, in <module>
   
import helloworld
ImportError: /opt/cython/helloworld.so: undefined symbol: _ZN2v82V813InitializeICUEPKc



Björn Dahlgren

unread,
Feb 3, 2016, 12:55:33 PM2/3/16
to cython-users


On Tuesday, 2 February 2016 22:07:32 UTC+1, Daniel Burchardt wrote:
Hi,

I try to run v8 in python and i can't run it... :(


Shot in the dark, have you tried adding "icui18n" to libraries?

Björn Dahlgren

unread,
Feb 3, 2016, 1:00:49 PM2/3/16
to cython-users


On Wednesday, 3 February 2016 18:55:33 UTC+1, Björn Dahlgren wrote:

Shot in the dark, have you tried adding "icui18n" to libraries?

 $ pkg-config --libs icu-i18n
-licui18n -licuuc -licudata  

i.e. if v8 uses icu-i18n...

Daniel Burchardt

unread,
Feb 4, 2016, 1:42:30 AM2/4/16
to cython-users
Result

pkg-config --libs icu-i18n
Package icu-i18n was not found in the pkg-config search path.
Perhaps you should add the directory containing `icu-i18n.pc'
to the PKG_CONFIG_PATH environment variable
No package 'icu-i18n' found

:(
Reply all
Reply to author
Forward
0 new messages