Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Numpyutils-c++ unit test fails build on Centos 7 #486

Open
sharpthc opened this issue Mar 22, 2021 · 0 comments
Open

Numpyutils-c++ unit test fails build on Centos 7 #486

sharpthc opened this issue Mar 22, 2021 · 0 comments

Comments

@sharpthc
Copy link

Building CODA with CMake fails on Centos 7 due to an include order issue with Python.h.

The error I received is as follow:

...
[ 39%] Built target math.poly_test_llsq
[ 40%] Built target math.poly_test_OneD_templates
[ 40%] Built target math.poly_test_fixed
[ 40%] Built target math.poly_test_poly
[ 40%] Built target math.poly_test_inner_poly
[ 40%] Built target math.poly_test_1d_poly
[ 40%] Built target math.poly_test_2d_poly
[ 40%] Built target math.poly_test_fixed_1d_poly
[ 40%] Built target math.poly_test_fixed_2d_poly
[ 40%] Built target numpyutils-c++
[ 40%] Building CXX object externals/coda-oss/modules/c++/numpyutils/CMakeFiles/numpyutils_test_num_elements.dir/unittests/test_num_elements.cpp.o
In file included from /usr/include/python2.7/pyconfig.h:6:0,
                 from /usr/include/python2.7/Python.h:8,
                 from /home/admin/CodeProjects/six-library-SIX-3.1.3/externals/coda-oss/modules/c++/numpyutils/include/numpyutils/numpyutils.h:27,
                 from /home/admin/CodeProjects/six-library-SIX-3.1.3/externals/coda-oss/modules/c++/numpyutils/unittests/test_num_elements.cpp:24:
/usr/include/python2.7/pyconfig-64.h:1191:0: error: "_POSIX_C_SOURCE" redefined [-Werror]
 #define _POSIX_C_SOURCE 200112L
 ^
In file included from /usr/include/c++/4.8.2/x86_64-redhat-linux/bits/os_defines.h:39:0,
                 from /usr/include/c++/4.8.2/x86_64-redhat-linux/bits/c++config.h:2097,
                 from /usr/include/c++/4.8.2/cmath:41,
                 from /home/admin/CodeProjects/six-library-SIX-3.1.3/externals/coda-oss/modules/c++/include/TestCase.h:29,
                 from /home/admin/CodeProjects/six-library-SIX-3.1.3/externals/coda-oss/modules/c++/numpyutils/unittests/test_num_elements.cpp:23:
/usr/include/features.h:168:0: note: this is the location of the previous definition
 # define _POSIX_C_SOURCE 200809L
 ^
In file included from /usr/include/python2.7/pyconfig.h:6:0,
                 from /usr/include/python2.7/Python.h:8,
                 from /home/admin/CodeProjects/six-library-SIX-3.1.3/externals/coda-oss/modules/c++/numpyutils/include/numpyutils/numpyutils.h:27,
                 from /home/admin/CodeProjects/six-library-SIX-3.1.3/externals/coda-oss/modules/c++/numpyutils/unittests/test_num_elements.cpp:24:
/usr/include/python2.7/pyconfig-64.h:1213:0: error: "_XOPEN_SOURCE" redefined [-Werror]
 #define _XOPEN_SOURCE 600
 ^
In file included from /usr/include/c++/4.8.2/x86_64-redhat-linux/bits/os_defines.h:39:0,
                 from /usr/include/c++/4.8.2/x86_64-redhat-linux/bits/c++config.h:2097,
                 from /usr/include/c++/4.8.2/cmath:41,
                 from /home/admin/CodeProjects/six-library-SIX-3.1.3/externals/coda-oss/modules/c++/include/TestCase.h:29,
                 from /home/admin/CodeProjects/six-library-SIX-3.1.3/externals/coda-oss/modules/c++/numpyutils/unittests/test_num_elements.cpp:23:
/usr/include/features.h:170:0: note: this is the location of the previous definition
 # define _XOPEN_SOURCE 700
 ^
cc1plus: all warnings being treated as errors
make[2]: *** [externals/coda-oss/modules/c++/numpyutils/CMakeFiles/numpyutils_test_num_elements.dir/unittests/test_num_elements.cpp.o] Error 1
make[1]: *** [externals/coda-oss/modules/c++/numpyutils/CMakeFiles/numpyutils_test_num_elements.dir/all] Error 2
make: *** [all] Error 2

The issue can be found in

#include <TestCase.h>
#include <numpyutils/numpyutils.h>
.

This issue can be fixed by either changing the include order to:

#include <numpyutils/numpyutils.h>
#include <TestCase.h>

or by adding Python.h before the other includes:

#include <Python.h>
#include <TestCase.h>
#include <numpyutils/numpyutils.h>

This Jira post for Mongo Python Driver pointed me to the solution:
https://jira.mongodb.org/browse/PYTHON-2260

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant