我正在尝试在 ubuntu 中安装 pymedia 以使用 python 2.7 运行脚本。因此,我追踪了依赖项并安装了它们:
sudo apt-get install python-dev libogg-dev libvorbis-dev liblame-dev libfaad2-dev libasound2-dev python-pygame libmp3lame-dev libevent-dev
因此,当我完成上述安装后,在下一步构建 pymedia 时,我得到了以下内容:
Using UNIX configuration...
OGG : not found
VORBIS : not found
FAAD : not found
MP3LAME : not found
VORBISENC : not found
ALSA : not found
Continue building pymedia ? [Y,n]:y
running build
running build_py
running build_ext
building 'pymedia.audio.sound' extension
x86_64-linux-gnu-gcc -pthread -fno-strict-aliasing -DNDEBUG -g -fwrapv -O2 -Wall -Wstrict-prototypes -DBUILD_NUM=1866 -DPATH_DEV_DSP="/dev/dsp" -DPATH_DEV_MIXER="/dev/mixer" -D_FILE_OFFSET_BITS=64 -DACCEL_DETECT=1 -DHAVE_MMX=1 -DHAVE_LINUX_DVD_STRUCT=1 -DDVD_STRUCT_IN_LINUX_CDROM_H=1 -DHAVE_AV_CONFIG_H -DUDF_CACHE=1 -I/home/simran/Downloads/pymedia-1.3.7.3 -Isound/ -I/usr/include/python2.7 -c sound/sound.cpp -o build/temp.linux-x86_64-2.7/sound/sound.o
cc1plus: warning: command line option ‘-Wstrict-prototypes’ is valid for C/ObjC but not for C++ [enabled by default]
<command-line>:0:14: warning: deprecated conversion from string constant to ‘char*’ [-Wwrite-strings]
sound/audio_unix.h:54:18: note: in expansion of macro ‘PATH_DEV_DSP’
static char *dsp=PATH_DEV_DSP;
^
<command-line>:0:16: warning: deprecated conversion from string constant to ‘char*’ [-Wwrite-strings]
sound/audio_unix.h:55:15: note: in expansion of macro ‘PATH_DEV_MIXER’
char *mixer = PATH_DEV_MIXER;
^
In file included from sound/sound.cpp:33:0:
sound/audio_unix.h: In member function ‘bool Mixer::SetControlValue(int, int, int, int, int)’:
sound/audio_unix.h:838:7: warning: suggest explicit braces to avoid ambiguous ‘else’ [-Wparentheses]
if( iControl )
^
sound/sound.cpp: At global scope:
sound/sound.cpp:791:1: warning: deprecated conversion from string constant to ‘char*’ [-Wwrite-strings]
};
^
sound/sound.cpp:791:1: warning: deprecated conversion from string constant to ‘char*’ [-Wwrite-strings]
sound/sound.cpp:791:1: warning: deprecated conversion from string constant to ‘char*’ [-Wwrite-strings]
sound/sound.cpp:791:1: warning: deprecated conversion from string constant to ‘char*’ [-Wwrite-strings]
sound/sound.cpp:791:1: warning: deprecated conversion from string constant to ‘char*’ [-Wwrite-strings]
sound/sound.cpp:791:1: warning: deprecated conversion from string constant to ‘char*’ [-Wwrite-strings]
sound/sound.cpp:791:1: warning: deprecated conversion from string constant to ‘char*’ [-Wwrite-strings]
sound/sound.cpp:791:1: warning: deprecated conversion from string constant to ‘char*’ [-Wwrite-strings]
sound/sound.cpp:791:1: warning: deprecated conversion from string constant to ‘char*’ [-Wwrite-strings]
sound/sound.cpp:791:1: warning: deprecated conversion from string constant to ‘char*’ [-Wwrite-strings]
sound/sound.cpp:798:1: warning: deprecated conversion from string constant to ‘char*’ [-Wwrite-strings]
};
^
sound/sound.cpp:798:1: warning: deprecated conversion from string constant to ‘char*’ [-Wwrite-strings]
sound/sound.cpp: In function ‘void initsound()’:
sound/sound.cpp:1451:66: warning: deprecated conversion from string constant to ‘char*’ [-Wwrite-strings]
g_cErr = PyErr_NewException(MODULE_NAME".SoundError", NULL, NULL);
^
x86_64-linux-gnu-gcc -pthread -fno-strict-aliasing -DNDEBUG -g -fwrapv -O2 -Wall -Wstrict-prototypes -DBUILD_NUM=1866 -DPATH_DEV_DSP="/dev/dsp" -DPATH_DEV_MIXER="/dev/mixer" -D_FILE_OFFSET_BITS=64 -DACCEL_DETECT=1 -DHAVE_MMX=1 -DHAVE_LINUX_DVD_STRUCT=1 -DDVD_STRUCT_IN_LINUX_CDROM_H=1 -DHAVE_AV_CONFIG_H -DUDF_CACHE=1 -I/home/simran/Downloads/pymedia-1.3.7.3 -Isound/ -I/usr/include/python2.7 -c sound/resample.c -o build/temp.linux-x86_64-2.7/sound/resample.o
sound/resample.c: In function ‘fractional_resample’:
sound/resample.c:48:24: warning: variable ‘incr’ set but not used [-Wunused-but-set-variable]
unsigned int frac, incr;
^
x86_64-linux-gnu-gcc -pthread -fno-strict-aliasing -DNDEBUG -g -fwrapv -O2 -Wall -Wstrict-prototypes -DBUILD_NUM=1866 -DPATH_DEV_DSP="/dev/dsp" -DPATH_DEV_MIXER="/dev/mixer" -D_FILE_OFFSET_BITS=64 -DACCEL_DETECT=1 -DHAVE_MMX=1 -DHAVE_LINUX_DVD_STRUCT=1 -DDVD_STRUCT_IN_LINUX_CDROM_H=1 -DHAVE_AV_CONFIG_H -DUDF_CACHE=1 -I/home/simran/Downloads/pymedia-1.3.7.3 -Isound/ -I/usr/include/python2.7 -c sound/fft.cpp -o build/temp.linux-x86_64-2.7/sound/fft.o
cc1plus: warning: command line option ‘-Wstrict-prototypes’ is valid for C/ObjC but not for C++ [enabled by default]
c++ -pthread -shared -Wl,-O1 -Wl,-Bsymbolic-functions -Wl,-Bsymbolic-functions -Wl,-z,relro -fno-strict-aliasing -DNDEBUG -g -fwrapv -O2 -Wall -Wstrict-prototypes -D_FORTIFY_SOURCE=2 -g -fstack-protector --param=ssp-buffer-size=4 -Wformat -Werror=format-security build/temp.linux-x86_64-2.7/sound/sound.o build/temp.linux-x86_64-2.7/sound/resample.o build/temp.linux-x86_64-2.7/sound/fft.o -o build/lib.linux-x86_64-2.7/pymedia/audio/sound.so
/usr/bin/ld: build/temp.linux-x86_64-2.7/sound/sound.o: relocation R_X86_64_32 against `_Py_NoneStruct' can not be used when making a shared object; recompile with -fPIC
build/temp.linux-x86_64-2.7/sound/sound.o: error adding symbols: Bad value
collect2: error: ld returned 1 exit status
error: command 'c++' failed with exit status 1
从打印结果可以看出,这些软件包(尽管安装正确)被标记为“未找到”。错误行的底部对我来说看起来像是 gcc 错误。如果有人能指出这里可能出现的问题,那将非常有帮助。
答案1
很多人都遇到过这个问题 - 这很可能是由于脚本混乱造成的。
显然,64 位共享库必须使用该标志进行编译-fPIC
,而在这种情况下,sound.cpp 则不需要。
其中setup.py
有一个名为disable_fPIC()
- 的函数,您可以通过用语句替换属于它的所有代码来禁用该函数pass
。所以:
def disable_fPIC():
pass