Ok, I can't find a good guide online for this, and @jcm's advice helped me, so I figured I'd just post this here.
I had a similar problem to the OP. During my build I would get the error:
/usr/bin/ld: /opt/pjproject-2.2.1/pjsip/lib/libpjsua-x86_64-unknown-linux-gnu.a(pjsua_acc.o): relocation R_X86_64_32 against `.rodata' can not be used when making a shared object; recompile with -fPIC
/opt/pjproject-2.2.1/pjsip/lib/libpjsua-x86_64-unknown-linux-gnu.a: could not read symbols: Bad value
Just adding the flag wouldn't fix it.
I don't know how much of this is unncessary, but this is what worked for me. Note that you have to delete the folder and start from scratch. It's possible 'make clean' works, but deleting and re-building was easiest for me:
sudo apt-get install build-essential python-dev
sudo rm -fr pjproject-2.2.1
tar -xf pjproject-2.2.1.tar.bz2 && cd pjproject-2.2.1/
export CFLAGS="$CFLAGS -fPIC"
./configure && make dep && make
cd pjsip-apps/src/python/
sudo python setup.py install
I should also note that I did this in a virtual machine (ubuntu 14.04) because (as far as I can tell) Ubuntu 12.04's compiler has a bug that causes it to segfault:
$ sudo python setup.py install
running install
running build
running build_py
creating build
creating build/lib.linux-x86_64-2.7
copying pjsua.py -> build/lib.linux-x86_64-2.7
running build_ext
building '_pjsua' extension
creating build/temp.linux-x86_64-2.7
gcc -pthread -fno-strict-aliasing -DNDEBUG -g -fwrapv -O2 -Wall -Wstrict-prototypes -fPIC -DPJ_AUTOCONF=1 -I/home/isaac_witmer/Downloads/pjproject-2.2.1/pjlib/include -I/home/isaac_witmer/Downloads/pjproject-2.2.1/pjlib-util/include -I/home/isaac_witmer/Downloads/pjproject-2.2.1/pjnath/include -I/home/isaac_witmer/Downloads/pjproject-2.2.1/pjmedia/include -I/home/isaac_witmer/Downloads/pjproject-2.2.1/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:1202:17: warning: variable ‘status’ set but not used [-Wunused-but-set-variable]
_pjsua.c: In function ‘py_pjsua_conf_get_port_info’:
_pjsua.c:2338:9: warning: variable ‘status’ set but not used [-Wunused-but-set-variable]
_pjsua.c: In function ‘py_pjsua_get_snd_dev’:
_pjsua.c:2714:9: warning: variable ‘status’ set but not used [-Wunused-but-set-variable]
In file included from _pjsua.c:20:0:
_pjsua.h: In function ‘PyObj_pjsip_cred_info_delete’:
_pjsua.h:71:13: internal compiler error: Segmentation fault
Please submit a full bug report,
with preprocessed source if appropriate.
See <file:///usr/share/doc/gcc-4.6/README.Bugs> for instructions.
Preprocessed source stored into /tmp/ccDoI9J3.out file, please attach this to your bugreport.
error: command 'gcc' failed with exit status 1