simondlevy / BreezySLAM

Simple, efficient, open-source package for Simultaneous Localization and Mapping
GNU Lesser General Public License v3.0
758 stars 251 forks source link

use option -std=c99 or -std=gnu99 to compile your code #31

Closed joelmaranhao closed 6 years ago

joelmaranhao commented 6 years ago

Getting the follow issue while compiling on Ubuntu 14.04

root@qb57:~/BreezySLAM/python# sudo python setup.py install;
running install
running build
running build_py
copying breezyslam/sensors.py -> build/lib.linux-x86_64-2.7/breezyslam
copying breezyslam/__init__.py -> build/lib.linux-x86_64-2.7/breezyslam
copying breezyslam/vehicles.py -> build/lib.linux-x86_64-2.7/breezyslam
copying breezyslam/algorithms.py -> build/lib.linux-x86_64-2.7/breezyslam
running build_ext
building 'pybreezyslam' extension
x86_64-linux-gnu-gcc -pthread -fno-strict-aliasing -DNDEBUG -g -fwrapv -O2 -Wall -Wstrict-prototypes -fPIC -I/usr/include/python2.7 -c pybreezyslam.c -o build/temp.linux-x86_64-2.7/pybreezyslam.o
pybreezyslam.c: In function 'Scan_update':
pybreezyslam.c:312:9: error: 'for' loop initial declarations are only allowed in C99 mode
         for (int k=0; k<PyList_Size(py_scan_angles_degrees); ++k)
         ^
pybreezyslam.c:312:9: note: use option -std=c99 or -std=gnu99 to compile your code
pybreezyslam.c:348:5: error: 'for' loop initial declarations are only allowed in C99 mode
     for (int k=0; k<PyList_Size(py_lidar); ++k)
     ^
error: command 'x86_64-linux-gnu-gcc' failed with exit status 1

Found this thread on stackoverflow

may be that helps resolving.

joelmaranhao commented 6 years ago

Resolved by adding suggested flag

~/BreezySLAM/python# vim setup.py

module = Extension('pybreezyslam',
    sources = SOURCES,
    extra_compile_args = ['-std=gnu99'] + SIMD_FLAGS + OPT_FLAGS
    )
root@qb57:~/BreezySLAM/python# sudo python setup.py install;
running install
running build
running build_py
running build_ext
building 'pybreezyslam' extension
x86_64-linux-gnu-gcc -pthread -fno-strict-aliasing -DNDEBUG -g -fwrapv -O2 -Wall -Wstrict-prototypes -fPIC -I/usr/include/python2.7 -c pybreezyslam.c -o build/temp.linux-x86_64-2.7/pybreezyslam.o -std=gnu99
x86_64-linux-gnu-gcc -pthread -fno-strict-aliasing -DNDEBUG -g -fwrapv -O2 -Wall -Wstrict-prototypes -fPIC -I/usr/include/python2.7 -c pyextension_utils.c -o build/temp.linux-x86_64-2.7/pyextension_utils.o -std=gnu99
x86_64-linux-gnu-gcc -pthread -fno-strict-aliasing -DNDEBUG -g -fwrapv -O2 -Wall -Wstrict-prototypes -fPIC -I/usr/include/python2.7 -c ../c/coreslam.c -o build/temp.linux-x86_64-2.7/../c/coreslam.o -std=gnu99
x86_64-linux-gnu-gcc -pthread -fno-strict-aliasing -DNDEBUG -g -fwrapv -O2 -Wall -Wstrict-prototypes -fPIC -I/usr/include/python2.7 -c ../c/coreslam_sisd.c -o build/temp.linux-x86_64-2.7/../c/coreslam_sisd.o -std=gnu99
x86_64-linux-gnu-gcc -pthread -fno-strict-aliasing -DNDEBUG -g -fwrapv -O2 -Wall -Wstrict-prototypes -fPIC -I/usr/include/python2.7 -c ../c/random.c -o build/temp.linux-x86_64-2.7/../c/random.o -std=gnu99
x86_64-linux-gnu-gcc -pthread -fno-strict-aliasing -DNDEBUG -g -fwrapv -O2 -Wall -Wstrict-prototypes -fPIC -I/usr/include/python2.7 -c ../c/ziggurat.c -o build/temp.linux-x86_64-2.7/../c/ziggurat.o -std=gnu99
x86_64-linux-gnu-gcc -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/pybreezyslam.o build/temp.linux-x86_64-2.7/pyextension_utils.o build/temp.linux-x86_64-2.7/../c/coreslam.o build/temp.linux-x86_64-2.7/../c/coreslam_sisd.o build/temp.linux-x86_64-2.7/../c/random.o build/temp.linux-x86_64-2.7/../c/ziggurat.o -o build/lib.linux-x86_64-2.7/pybreezyslam.so
running install_lib
copying build/lib.linux-x86_64-2.7/pybreezyslam.so -> /usr/local/lib/python2.7/dist-packages
copying build/lib.linux-x86_64-2.7/breezyslam/sensors.py -> /usr/local/lib/python2.7/dist-packages/breezyslam
copying build/lib.linux-x86_64-2.7/breezyslam/__init__.py -> /usr/local/lib/python2.7/dist-packages/breezyslam
copying build/lib.linux-x86_64-2.7/breezyslam/vehicles.py -> /usr/local/lib/python2.7/dist-packages/breezyslam
copying build/lib.linux-x86_64-2.7/breezyslam/algorithms.py -> /usr/local/lib/python2.7/dist-packages/breezyslam
byte-compiling /usr/local/lib/python2.7/dist-packages/breezyslam/sensors.py to sensors.pyc
byte-compiling /usr/local/lib/python2.7/dist-packages/breezyslam/__init__.py to __init__.pyc
byte-compiling /usr/local/lib/python2.7/dist-packages/breezyslam/vehicles.py to vehicles.pyc
byte-compiling /usr/local/lib/python2.7/dist-packages/breezyslam/algorithms.py to algorithms.pyc
running install_egg_info
Removing /usr/local/lib/python2.7/dist-packages/BreezySLAM-0.1.egg-info
Writing /usr/local/lib/python2.7/dist-packages/BreezySLAM-0.1.egg-info
simondlevy commented 6 years ago

Thanks, Joël. I have added this line to setup.py.