warp-ctc icon indicating copy to clipboard operation
warp-ctc copied to clipboard

Should use C99 mode in gcc

Open Angel-Jia opened this issue 6 years ago • 3 comments

/root/anaconda3/lib/python3.6/site-packages/torch/utils/ffi/../../lib/include/TH/THMath.h: In function ‘TH_polevlf’: /root/anaconda3/lib/python3.6/site-packages/torch/utils/ffi/../../lib/include/TH/THMath.h:142:3: error: ‘for’ loop initial declarations are only allowed in C99 mode for (size_t i = 0; i <= len; i++) { ^ /root/anaconda3/lib/python3.6/site-packages/torch/utils/ffi/../../lib/include/TH/THMath.h: In function ‘TH_trigamma’: /root/anaconda3/lib/python3.6/site-packages/torch/utils/ffi/../../lib/include/TH/THMath.h:260:3: error: ‘for’ loop initial declarations are only allowed in C99 mode for (int i = 0; i < 6; ++i) { ^ /root/anaconda3/lib/python3.6/site-packages/torch/utils/ffi/../../lib/include/TH/THMath.h: In function ‘TH_trigammaf’: /root/anaconda3/lib/python3.6/site-packages/torch/utils/ffi/../../lib/include/TH/THMath.h:278:3: error: ‘for’ loop initial declarations are only allowed in C99 mode for (int i = 0; i < 6; ++i) { ^ error: command 'gcc' failed with exit status 1

Should add -std=c99 in setup.py

Angel-Jia avatar May 25 '18 12:05 Angel-Jia

same error, change -std=c++11 to -std=c99 or add std=c99 in extra_compile_args causes another error:

$ python setup.py install
generating build/warpctc_pytorch/_warp_ctc/__warp_ctc.c
regenerated: 'build/warpctc_pytorch/_warp_ctc/__warp_ctc.c'
running install
running bdist_egg
running egg_info
creating warpctc_pytorch.egg-info
writing warpctc_pytorch.egg-info/PKG-INFO
writing top-level names to warpctc_pytorch.egg-info/top_level.txt
writing dependency_links to warpctc_pytorch.egg-info/dependency_links.txt
writing manifest file 'warpctc_pytorch.egg-info/SOURCES.txt'
reading manifest file 'warpctc_pytorch.egg-info/SOURCES.txt'
writing manifest file 'warpctc_pytorch.egg-info/SOURCES.txt'
installing library code to build/bdist.linux-x86_64/egg
running install_lib
running build_py
creating build/lib.linux-x86_64-2.7
creating build/lib.linux-x86_64-2.7/warpctc_pytorch
copying warpctc_pytorch/__init__.py -> build/lib.linux-x86_64-2.7/warpctc_pytorch
creating build/lib.linux-x86_64-2.7/warpctc_pytorch/_warp_ctc
copying warpctc_pytorch/_warp_ctc/__init__.py -> build/lib.linux-x86_64-2.7/warpctc_pytorch/_warp_ctc
running build_ext
building 'warpctc_pytorch._warp_ctc.__warp_ctc' extension
creating build/temp.linux-x86_64-2.7
creating build/temp.linux-x86_64-2.7/build
creating build/temp.linux-x86_64-2.7/build/warpctc_pytorch
creating build/temp.linux-x86_64-2.7/build/warpctc_pytorch/_warp_ctc
creating build/temp.linux-x86_64-2.7/home
creating build/temp.linux-x86_64-2.7/home/hzxubinbin
creating build/temp.linux-x86_64-2.7/home/hzxubinbin/soft
creating build/temp.linux-x86_64-2.7/home/hzxubinbin/soft/github-seannaren-warp-ctc
creating build/temp.linux-x86_64-2.7/home/hzxubinbin/soft/github-seannaren-warp-ctc/pytorch_binding
creating build/temp.linux-x86_64-2.7/home/hzxubinbin/soft/github-seannaren-warp-ctc/pytorch_binding/src
gcc -pthread -fno-strict-aliasing -g -O2 -DNDEBUG -g -fwrapv -O3 -Wall -Wstrict-prototypes -fPIC -I/home/hzxubinbin/anaconda2/lib/python2.7/site-packages/torch/utils/ffi/../../lib/include -I/home/hzxubinbin/anaconda2/lib/python2.7/site-packages/torch/utils/ffi/../../lib/include/TH -I/home/hzxubinbin/anaconda2/lib/python2.7/site-packages/torch/utils/ffi/../../lib/include/THC -I/home/hzxubinbin/soft/github-seannaren-warp-ctc/include -I/home/hzxubinbin/commlibs/cuda-9.0/include/ -I/home/hzxubinbin/anaconda2/include/python2.7 -c build/warpctc_pytorch/_warp_ctc/__warp_ctc.c -o build/temp.linux-x86_64-2.7/build/warpctc_pytorch/_warp_ctc/__warp_ctc.o -fPIC -std=c++11 -std=c99 -DWARPCTC_ENABLE_GPU
cc1: warning: command line option ‘-std=c++11’ is valid for C++/ObjC++ but not for C [enabled by default]
gcc -pthread -fno-strict-aliasing -g -O2 -DNDEBUG -g -fwrapv -O3 -Wall -Wstrict-prototypes -fPIC -I/home/hzxubinbin/anaconda2/lib/python2.7/site-packages/torch/utils/ffi/../../lib/include -I/home/hzxubinbin/anaconda2/lib/python2.7/site-packages/torch/utils/ffi/../../lib/include/TH -I/home/hzxubinbin/anaconda2/lib/python2.7/site-packages/torch/utils/ffi/../../lib/include/THC -I/home/hzxubinbin/soft/github-seannaren-warp-ctc/include -I/home/hzxubinbin/commlibs/cuda-9.0/include/ -I/home/hzxubinbin/anaconda2/include/python2.7 -c /home/hzxubinbin/soft/github-seannaren-warp-ctc/pytorch_binding/src/binding.cpp -o build/temp.linux-x86_64-2.7/home/hzxubinbin/soft/github-seannaren-warp-ctc/pytorch_binding/src/binding.o -fPIC -std=c++11 -std=c99 -DWARPCTC_ENABLE_GPU
cc1plus: warning: command line option ‘-Wstrict-prototypes’ is valid for C/ObjC but not for C++ [enabled by default]
cc1plus: warning: command line option ‘-std=c99’ is valid for C/ObjC but not for C++ [enabled by default]
g++ -pthread -shared -L/home/hzxubinbin/anaconda2/lib -Wl,-rpath=/home/hzxubinbin/anaconda2/lib,--no-as-needed build/temp.linux-x86_64-2.7/build/warpctc_pytorch/_warp_ctc/__warp_ctc.o build/temp.linux-x86_64-2.7/home/hzxubinbin/soft/github-seannaren-warp-ctc/pytorch_binding/src/binding.o -L/home/hzxubinbin/commlibs/pytorch-warp-ctc/lib -L/home/hzxubinbin/anaconda2/lib -lwarpctc -lpython2.7 -o build/lib.linux-x86_64-2.7/warpctc_pytorch/_warp_ctc/__warp_ctc.so -Wl,-rpath/home/hzxubinbin/commlibs/pytorch-warp-ctc/lib
/usr/bin/ld: bad -rpath option
collect2: error: ld returned 1 exit status
error: command 'g++' failed with exit status 1

using gcc-4.9.2 and gcc-4.8.5 both fail, do not know how to fix it? can @SeanNaren or someone fix this ? thanks in advance!!!

freesouls avatar May 29 '18 08:05 freesouls

the above problem was caused by myself, the source code is extra_link_args=['-Wl,-rpath,' + os.path.realpath(warp_ctc_path)] at some point I change it to extra_link_args=['-Wl,-rpath' + os.path.realpath(warp_ctc_path)] by accident, so the compilation failed.

freesouls avatar May 30 '18 03:05 freesouls

#54

lizabelos avatar Jun 01 '18 14:06 lizabelos