如何获得python pjsua?
$ wget http://www.pjsip.org/release/2.1/pjproject-2.1.tar.bz2
$ tar xvfj pjproject-2.1.tar.bz2
$ cd pjproject-2.1.0
$ ./configure
$ make dep && make
$ make install
$ ldconfig
$ ldconfig -p | grep pj
$ cd ./pjsip-apps/src/python
$ python setup.py install
running install
running build
running build_py
running build_ext
building '_pjsua' extension
gcc -pthread -fno-strict-aliasing -DNDEBUG -g -fwrapv -O2 -Wall -Wstrict-prototypes -fPIC -DPJ_AUTOCONF=1 -I-DPJ_IS_BIG_ENDIAN=0 -I-DPJ_IS_LITTLE_ENDIAN=1 -I/home/sun/Downloads/pjproject-2.1.0/pjlib/include -I/home/sun/Downloads/pjproject-2.1.0/pjlib-util/include -I/home/sun/Downloads/pjproject-2.1.0/pjnath/include -I/home/sun/Downloads/pjproject-2.1.0/pjmedia/include -I/home/sun/Downloads/pjproject-2.1.0/pjsip/include -I/usr/include/python2.7 -c _pjsua.c -o build/temp.linux-x86_64-2.7/_pjsua.o
_pjsua.c: In function ‘py_pjsua_enum_transports’:
_pjsua.c:1201:17: warning: variable ‘status’ set but not used [-Wunused-but-set-variable]
_pjsua.c: In function ‘py_pjsua_conf_get_port_info’:
_pjsua.c:2337:9: warning: variable ‘status’ set but not used [-Wunused-but-set-variable]
_pjsua.c: In function ‘py_pjsua_get_snd_dev’:
_pjsua.c:2713:9: warning: variable ‘status’ set but not used [-Wunused-but-set-variable]
_pjsua.c: In function ‘py_pjsua_call_make_call’:
_pjsua.c:3139:7: warning: passing argument 3 of ‘pjsua_call_make_call’ makes pointer from integer without a cast [enabled by default]
In file included from _pjsua.h:27:0,
from _pjsua.c:20:
/home/sun/Downloads/pjproject-2.1.0/pjsip/include/pjsua-lib/pjsua.h:4234:22: note: expected ‘const struct pjsua_call_setting *’ but argument is of type ‘unsigned int’
gcc -pthread -shared -Wl,-O1 -Wl,-Bsymbolic-functions -Wl,-Bsymbolic-functions -Wl,-z,relro build/temp.linux-x86_64-2.7/_pjsua.o -L/home/sun/Downloads/pjproject-2.1.0/pjlib/lib -L/home/sun/Downloads/pjproject-2.1.0/pjlib-util/lib -L/home/sun/Downloads/pjproject-2.1.0/pjnath/lib -L/home/sun/Downloads/pjproject-2.1.0/pjmedia/lib -L/home/sun/Downloads/pjproject-2.1.0/pjsip/lib -L/home/sun/Downloads/pjproject-2.1.0/third_party/lib -lpjsua-x86_64-unknown-linux-gnu -lpjsip-ua-x86_64-unknown-linux-gnu -lpjsip-simple-x86_64-unknown-linux-gnu -lpjsip-x86_64-unknown-linux-gnu -lpjmedia-codec-x86_64-unknown-linux-gnu -lpjmedia-videodev-x86_64-unknown-linux-gnu -lpjmedia-x86_64-unknown-linux-gnu -lpjmedia-audiodev-x86_64-unknown-linux-gnu -lpjnath-x86_64-unknown-linux-gnu -lpjlib-util-x86_64-unknown-linux-gnu -lresample-x86_64-unknown-linux-gnu -lmilenage-x86_64-unknown-linux-gnu -lsrtp-x86_64-unknown-linux-gnu -lgsmcodec-x86_64-unknown-linux-gnu -lspeex-x86_64-unknown-linux-gnu -lilbccodec-x86_64-unknown-linux-gnu -lg7221codec-x86_64-unknown-linux-gnu -lportaudio-x86_64-unknown-linux-gnu -lpj-x86_64-unknown-linux-gnu -lm -lnsl -lrt -lpthread -lcrypto -lssl -o build/lib.linux-x86_64-2.7/_pjsua.so
/usr/bin/ld: /home/sun/Downloads/pjproject-2.1.0/pjsip/lib/libpjsua-x86_64-unknown-linux-gnu.a(pjsua_acc.o): relocation R_X86_64_32S against `.rodata.str1.1' can not be used when making a shared object; recompile with -fPIC
/home/sun/Downloads/pjproject-2.1.0/pjsip/lib/libpjsua-x86_64-unknown-linux-gnu.a: could not read symbols: Bad value
collect2: error: ld returned 1 exit status
error: command 'gcc' failed with exit status 1
$ python
Python 2.7.3 (default, Apr 10 2013, 05:13:16)
[GCC 4.7.2] on linux2
Type "help", "copyright", "credits" or "license" for more information.
>>> import pjsua
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
ImportError: No module named pjsua
编辑:
p2p | registration | call
$ python sip_hello.py sip:localhost:5080
18:22:21.607 os_core_unix.c !pjlib 2.1 for POSIX initialized
18:22:21.608 sip_endpoint.c .Creating endpoint instance...
18:22:21.608 pjlib .select() I/O Queue created (0x131b9f0)
18:22:21.608 sip_endpoint.c .Module "mod-msg-print" registered
18:22:21.608 sip_transport. .Transport manager created.
18:22:21.608 pjsua_core.c .PJSUA state changed: NULL --> CREATED
18:22:21.622 pjsua_core.c .pjsua version 2.1 for Linux-3.5.0.17/x86_64/glibc-2.15 initialized
18:22:21.625 pjsua_aud.c ..Error retrieving default audio device parameters: Unable to find default audio device (PJMEDIA_EAUD_NODEFDEV) [status=420006]
Exception: Object: {Account <sip:192.168.1.15:57717>}, operation=make_call(), error=Unable to find default audio device (PJMEDIA_EAUD_NODEFDEV)
最佳答案
setup.py
试图通过动态链接 pjsip 的库来创建共享库 build/lib.linux-x86_64-2.7/_pjsua.so
,但是,这些库不提供 global offsets table(GOT)(检查链接以了解为什么需要这样做)。
问题是 ./configure
不提供 gcc 的 -fPIC
选项,我建议创建一个 configure-linux
脚本,如:
#!/bin/sh
#
export CFLAGS="$CFLAGS -fPIC"
./configure
关于Python - 如何获得导入 pjsua?不提供名为 pjsua 的模块,我们在Stack Overflow上找到一个类似的问题:https://stackoverflow.com/questions/20195542/