[英]How to resolve a “conflicting types” error during C++/C compilation using `python setup.py build`?
I'm trying to include the COLLADA DOM library into a program I'm working on ( PyMOL ) as an external dependency, with the ultimate goal of enabling export of 3D scenes in COLLADA (.dae) format. 我试图将COLLADA DOM库作为外部依赖项包含在我正在研究的程序( PyMOL )中,其最终目标是能够以COLLADA(.dae)格式导出3D场景。 I'm able to successfully compile everything up to the point where I add
#include <Collada14Dom/dae.h>
to the relevant source file; 我可以成功编译所有内容,直到将
#include <Collada14Dom/dae.h>
到相关源文件中#include <Collada14Dom/dae.h>
; ie if I comment-out that single line, everything builds fine. 即,如果我注释掉那一行,一切都会很好。 I'm working on a Mac running 10.8.5 with Xcode 5.
我正在使用Xcode 5运行10.8.5的Mac。
So far, I've installed the COLLADA DOM v2.2 from Sourceforge, built the DOM via make
(from within the 'dom' subdirectory), and installed the framework to /Library/Frameworks/Collada14Dom.framework via make install
. 到目前为止,我已经从Sourceforge安装了COLLADA DOM v2.2 ,通过
make
(从“ dom”子目录中)构建了DOM,并通过make install
将框架安装到了/Library/Frameworks/Collada14Dom.framework。
I've also downloaded Boost v1.55.0 and installed via ./bootstrap
, ./b2
, ./b2 install
as indicated here . 我也下载了升压v1.55.0 ,并通过安装
./bootstrap
, ./b2
, ./b2 install
指示在这里 。
The problem arises when I compile after adding the following line to my COLLADA.cpp
file. 在
COLLADA.cpp
添加到COLLADA.cpp
文件后进行编译时,会出现问题。
#include <Collada14Dom/dae.h>
Upon compilation, I get a series of "conflicting types" errors: 编译后,出现了一系列“冲突类型”错误:
$ sudo /sw/bin/python setup.py build install --home=/opt/pymol --install-lib=/opt/pymol/modules --install-scripts=/opt/pymol
Password:
running install
running build
running build_py
running build_ext
building 'pymol._cmd' extension
gcc -fno-strict-aliasing -g -O2 -DNDEBUG -g -fwrapv -O3 -Wall -Wstrict-prototypes -D_PYMOL_VMD_PLUGINS -D_PYMOL_LIBPNG -D_PYMOL_FREETYPE -D_PYMOL_INLINE -D_PYMOL_OPENGL_SHADERS -DNO_MMLIBS -D_PYMOL_CGO_DRAWARRAYS -D_PYMOL_CGO_DRAWBUFFERS -D_CGO_DRAWARRAYS -D_PYMOL_GL_CALLLISTS -DOPENGL_ES_2 -D_PYMOL_COLLADA -D_PYMOL_NUMPY -Iov/src -Ilayer0 -Ilayer1 -Ilayer2 -Ilayer3 -Ilayer4 -Ilayer5 -Imodules/cealign/src -Imodules/cealign/src/tnt -Ibuild/generated -Icontrib/uiuc/plugins/include -Icontrib/uiuc/plugins/molfile_plugin/src -I/sw/lib/python2.7/site-packages/numpy/core/include -I/usr/include -I/usr/X11/include -I/usr/X11/include/freetype2 -I/sw/include -I/sw/include/freetype2 -I/sw/include/python2.7 -c layer1/COLLADA.cpp -o build/temp.macosx-10.8-x86_64-2.7/layer1/COLLADA.o -ffast-math -funroll-loops -O3 -fcommon
In file included from layer1/COLLADA.cpp:35:
In file included from /Library/Frameworks/Collada14Dom.framework/Headers/dae.h:28:
In file included from /usr/local/include/boost/filesystem/convenience.hpp:22:
In file included from /usr/local/include/boost/filesystem/operations.hpp:25:
In file included from /usr/local/include/boost/filesystem/path.hpp:25:
In file included from /usr/local/include/boost/filesystem/path_traits.hpp:23:
In file included from /usr/local/include/boost/system/error_code.hpp:17:
In file included from /usr/local/include/boost/operators.hpp:86:
In file included from /usr/local/include/boost/iterator.hpp:17:
In file included from /usr/include/c++/4.2.1/iterator:67:
/usr/include/c++/4.2.1/bits/stl_iterator_base_funcs.h:91:5: error: conflicting types for '__distance'
__distance(_RandomAccessIterator __first, _RandomAccessIterator __last,
^
/usr/include/c++/4.2.1/bits/stl_iterator_base_funcs.h:74:5: note: previous definition is here
__distance(_InputIterator __first, _InputIterator __last,
^
/usr/include/c++/4.2.1/bits/stl_iterator_base_funcs.h:133:5: error: conflicting types for '__advance'
__advance(_BidirectionalIterator& __i, _Distance __n,
^
/usr/include/c++/4.2.1/bits/stl_iterator_base_funcs.h:123:5: note: previous definition is here
__advance(_InputIterator& __i, _Distance __n, input_iterator_tag)
^
/usr/include/c++/4.2.1/bits/stl_iterator_base_funcs.h:149:5: error: conflicting types for '__advance'
__advance(_RandomAccessIterator& __i, _Distance __n,
^
/usr/include/c++/4.2.1/bits/stl_iterator_base_funcs.h:123:5: note: previous definition is here
__advance(_InputIterator& __i, _Distance __n, input_iterator_tag)
^
In file included from layer1/COLLADA.cpp:35:
In file included from /Library/Frameworks/Collada14Dom.framework/Headers/dae.h:28:
In file included from /usr/local/include/boost/filesystem/convenience.hpp:22:
In file included from /usr/local/include/boost/filesystem/operations.hpp:25:
In file included from /usr/local/include/boost/filesystem/path.hpp:25:
In file included from /usr/local/include/boost/filesystem/path_traits.hpp:23:
In file included from /usr/local/include/boost/system/error_code.hpp:17:
In file included from /usr/local/include/boost/operators.hpp:86:
In file included from /usr/local/include/boost/iterator.hpp:17:
In file included from /usr/include/c++/4.2.1/iterator:68:
In file included from /usr/include/c++/4.2.1/bits/stl_iterator.h:69:
/usr/include/c++/4.2.1/bits/cpp_type_traits.h:92:10: error: functions that differ only in their return type cannot be
overloaded
__two& __test_type(...);
^
/usr/include/c++/4.2.1/bits/cpp_type_traits.h:90:9: note: previous declaration is here
__one __test_type(int _Tp::*);
^
In file included from layer1/COLLADA.cpp:35:
In file included from /Library/Frameworks/Collada14Dom.framework/Headers/dae.h:28:
In file included from /usr/local/include/boost/filesystem/convenience.hpp:22:
In file included from /usr/local/include/boost/filesystem/operations.hpp:25:
In file included from /usr/local/include/boost/filesystem/path.hpp:25:
In file included from /usr/local/include/boost/filesystem/path_traits.hpp:23:
In file included from /usr/local/include/boost/system/error_code.hpp:17:
In file included from /usr/local/include/boost/operators.hpp:86:
In file included from /usr/local/include/boost/iterator.hpp:17:
In file included from /usr/include/c++/4.2.1/iterator:68:
/usr/include/c++/4.2.1/bits/stl_iterator.h:282:5: error: conflicting types for 'operator=='
operator==(const reverse_iterator<_Iterator>& __x,
^
/usr/include/c++/4.2.1/bits/stl_pair.h:96:5: note: previous definition is here
operator==(const pair<_T1, _T2>& __x, const pair<_T1, _T2>& __y)
^
In file included from layer1/COLLADA.cpp:35:
In file included from /Library/Frameworks/Collada14Dom.framework/Headers/dae.h:28:
In file included from /usr/local/include/boost/filesystem/convenience.hpp:22:
In file included from /usr/local/include/boost/filesystem/operations.hpp:25:
In file included from /usr/local/include/boost/filesystem/path.hpp:25:
In file included from /usr/local/include/boost/filesystem/path_traits.hpp:23:
In file included from /usr/local/include/boost/system/error_code.hpp:17:
In file included from /usr/local/include/boost/operators.hpp:86:
In file included from /usr/local/include/boost/iterator.hpp:17:
In file included from /usr/include/c++/4.2.1/iterator:68:
/usr/include/c++/4.2.1/bits/stl_iterator.h:288:5: error: conflicting types for 'operator<'
operator<(const reverse_iterator<_Iterator>& __x,
^
/usr/include/c++/4.2.1/bits/stl_pair.h:102:5: note: previous definition is here
operator<(const pair<_T1, _T2>& __x, const pair<_T1, _T2>& __y)
^
In file included from layer1/COLLADA.cpp:35:
In file included from /Library/Frameworks/Collada14Dom.framework/Headers/dae.h:28:
In file included from /usr/local/include/boost/filesystem/convenience.hpp:22:
In file included from /usr/local/include/boost/filesystem/operations.hpp:25:
In file included from /usr/local/include/boost/filesystem/path.hpp:25:
In file included from /usr/local/include/boost/filesystem/path_traits.hpp:23:
In file included from /usr/local/include/boost/system/error_code.hpp:17:
In file included from /usr/local/include/boost/operators.hpp:86:
In file included from /usr/local/include/boost/iterator.hpp:17:
In file included from /usr/include/c++/4.2.1/iterator:68:
/usr/include/c++/4.2.1/bits/stl_iterator.h:294:5: error: conflicting types for 'operator!='
operator!=(const reverse_iterator<_Iterator>& __x,
^
/usr/include/c++/4.2.1/bits/stl_pair.h:109:5: note: previous definition is here
operator!=(const pair<_T1, _T2>& __x, const pair<_T1, _T2>& __y)
^
In file included from layer1/COLLADA.cpp:35:
In file included from /Library/Frameworks/Collada14Dom.framework/Headers/dae.h:28:
In file included from /usr/local/include/boost/filesystem/convenience.hpp:22:
In file included from /usr/local/include/boost/filesystem/operations.hpp:25:
In file included from /usr/local/include/boost/filesystem/path.hpp:25:
In file included from /usr/local/include/boost/filesystem/path_traits.hpp:23:
In file included from /usr/local/include/boost/system/error_code.hpp:17:
In file included from /usr/local/include/boost/operators.hpp:86:
In file included from /usr/local/include/boost/iterator.hpp:17:
In file included from /usr/include/c++/4.2.1/iterator:68:
/usr/include/c++/4.2.1/bits/stl_iterator.h:300:5: error: conflicting types for 'operator>'
operator>(const reverse_iterator<_Iterator>& __x,
^
/usr/include/c++/4.2.1/bits/stl_pair.h:115:5: note: previous definition is here
operator>(const pair<_T1, _T2>& __x, const pair<_T1, _T2>& __y)
^
In file included from layer1/COLLADA.cpp:35:
In file included from /Library/Frameworks/Collada14Dom.framework/Headers/dae.h:28:
In file included from /usr/local/include/boost/filesystem/convenience.hpp:22:
In file included from /usr/local/include/boost/filesystem/operations.hpp:25:
In file included from /usr/local/include/boost/filesystem/path.hpp:25:
In file included from /usr/local/include/boost/filesystem/path_traits.hpp:23:
In file included from /usr/local/include/boost/system/error_code.hpp:17:
In file included from /usr/local/include/boost/operators.hpp:86:
In file included from /usr/local/include/boost/iterator.hpp:17:
In file included from /usr/include/c++/4.2.1/iterator:68:
/usr/include/c++/4.2.1/bits/stl_iterator.h:306:5: error: conflicting types for 'operator<='
operator<=(const reverse_iterator<_Iterator>& __x,
^
/usr/include/c++/4.2.1/bits/stl_pair.h:121:5: note: previous definition is here
operator<=(const pair<_T1, _T2>& __x, const pair<_T1, _T2>& __y)
^
In file included from layer1/COLLADA.cpp:35:
In file included from /Library/Frameworks/Collada14Dom.framework/Headers/dae.h:28:
In file included from /usr/local/include/boost/filesystem/convenience.hpp:22:
In file included from /usr/local/include/boost/filesystem/operations.hpp:25:
In file included from /usr/local/include/boost/filesystem/path.hpp:25:
In file included from /usr/local/include/boost/filesystem/path_traits.hpp:23:
In file included from /usr/local/include/boost/system/error_code.hpp:17:
In file included from /usr/local/include/boost/operators.hpp:86:
In file included from /usr/local/include/boost/iterator.hpp:17:
In file included from /usr/include/c++/4.2.1/iterator:68:
/usr/include/c++/4.2.1/bits/stl_iterator.h:312:5: error: conflicting types for 'operator>='
operator>=(const reverse_iterator<_Iterator>& __x,
^
/usr/include/c++/4.2.1/bits/stl_pair.h:127:5: note: previous definition is here
operator>=(const pair<_T1, _T2>& __x, const pair<_T1, _T2>& __y)
^
In file included from layer1/COLLADA.cpp:35:
In file included from /Library/Frameworks/Collada14Dom.framework/Headers/dae.h:28:
In file included from /usr/local/include/boost/filesystem/convenience.hpp:22:
In file included from /usr/local/include/boost/filesystem/operations.hpp:25:
In file included from /usr/local/include/boost/filesystem/path.hpp:25:
In file included from /usr/local/include/boost/filesystem/path_traits.hpp:23:
In file included from /usr/local/include/boost/system/error_code.hpp:17:
In file included from /usr/local/include/boost/operators.hpp:86:
In file included from /usr/local/include/boost/iterator.hpp:17:
In file included from /usr/include/c++/4.2.1/iterator:68:
/usr/include/c++/4.2.1/bits/stl_iterator.h:332:5: error: conflicting types for 'operator=='
operator==(const reverse_iterator<_IteratorL>& __x,
^
/usr/include/c++/4.2.1/bits/stl_pair.h:96:5: note: previous definition is here
operator==(const pair<_T1, _T2>& __x, const pair<_T1, _T2>& __y)
^
In file included from layer1/COLLADA.cpp:35:
In file included from /Library/Frameworks/Collada14Dom.framework/Headers/dae.h:28:
In file included from /usr/local/include/boost/filesystem/convenience.hpp:22:
In file included from /usr/local/include/boost/filesystem/operations.hpp:25:
In file included from /usr/local/include/boost/filesystem/path.hpp:25:
In file included from /usr/local/include/boost/filesystem/path_traits.hpp:23:
In file included from /usr/local/include/boost/system/error_code.hpp:17:
In file included from /usr/local/include/boost/operators.hpp:86:
In file included from /usr/local/include/boost/iterator.hpp:17:
In file included from /usr/include/c++/4.2.1/iterator:68:
/usr/include/c++/4.2.1/bits/stl_iterator.h:338:5: error: conflicting types for 'operator<'
operator<(const reverse_iterator<_IteratorL>& __x,
^
/usr/include/c++/4.2.1/bits/stl_pair.h:102:5: note: previous definition is here
operator<(const pair<_T1, _T2>& __x, const pair<_T1, _T2>& __y)
^
In file included from layer1/COLLADA.cpp:35:
In file included from /Library/Frameworks/Collada14Dom.framework/Headers/dae.h:28:
In file included from /usr/local/include/boost/filesystem/convenience.hpp:22:
In file included from /usr/local/include/boost/filesystem/operations.hpp:25:
In file included from /usr/local/include/boost/filesystem/path.hpp:25:
In file included from /usr/local/include/boost/filesystem/path_traits.hpp:23:
In file included from /usr/local/include/boost/system/error_code.hpp:17:
In file included from /usr/local/include/boost/operators.hpp:86:
In file included from /usr/local/include/boost/iterator.hpp:17:
In file included from /usr/include/c++/4.2.1/iterator:68:
/usr/include/c++/4.2.1/bits/stl_iterator.h:344:5: error: conflicting types for 'operator!='
operator!=(const reverse_iterator<_IteratorL>& __x,
^
/usr/include/c++/4.2.1/bits/stl_pair.h:109:5: note: previous definition is here
operator!=(const pair<_T1, _T2>& __x, const pair<_T1, _T2>& __y)
^
In file included from layer1/COLLADA.cpp:35:
In file included from /Library/Frameworks/Collada14Dom.framework/Headers/dae.h:28:
In file included from /usr/local/include/boost/filesystem/convenience.hpp:22:
In file included from /usr/local/include/boost/filesystem/operations.hpp:25:
In file included from /usr/local/include/boost/filesystem/path.hpp:25:
In file included from /usr/local/include/boost/filesystem/path_traits.hpp:23:
In file included from /usr/local/include/boost/system/error_code.hpp:17:
In file included from /usr/local/include/boost/operators.hpp:86:
In file included from /usr/local/include/boost/iterator.hpp:17:
In file included from /usr/include/c++/4.2.1/iterator:68:
/usr/include/c++/4.2.1/bits/stl_iterator.h:350:5: error: conflicting types for 'operator>'
operator>(const reverse_iterator<_IteratorL>& __x,
^
/usr/include/c++/4.2.1/bits/stl_pair.h:115:5: note: previous definition is here
operator>(const pair<_T1, _T2>& __x, const pair<_T1, _T2>& __y)
^
In file included from layer1/COLLADA.cpp:35:
In file included from /Library/Frameworks/Collada14Dom.framework/Headers/dae.h:28:
In file included from /usr/local/include/boost/filesystem/convenience.hpp:22:
In file included from /usr/local/include/boost/filesystem/operations.hpp:25:
In file included from /usr/local/include/boost/filesystem/path.hpp:25:
In file included from /usr/local/include/boost/filesystem/path_traits.hpp:23:
In file included from /usr/local/include/boost/system/error_code.hpp:17:
In file included from /usr/local/include/boost/operators.hpp:86:
In file included from /usr/local/include/boost/iterator.hpp:17:
In file included from /usr/include/c++/4.2.1/iterator:68:
/usr/include/c++/4.2.1/bits/stl_iterator.h:356:5: error: conflicting types for 'operator<='
operator<=(const reverse_iterator<_IteratorL>& __x,
^
/usr/include/c++/4.2.1/bits/stl_pair.h:121:5: note: previous definition is here
operator<=(const pair<_T1, _T2>& __x, const pair<_T1, _T2>& __y)
^
In file included from layer1/COLLADA.cpp:35:
In file included from /Library/Frameworks/Collada14Dom.framework/Headers/dae.h:28:
In file included from /usr/local/include/boost/filesystem/convenience.hpp:22:
In file included from /usr/local/include/boost/filesystem/operations.hpp:25:
In file included from /usr/local/include/boost/filesystem/path.hpp:25:
In file included from /usr/local/include/boost/filesystem/path_traits.hpp:23:
In file included from /usr/local/include/boost/system/error_code.hpp:17:
In file included from /usr/local/include/boost/operators.hpp:86:
In file included from /usr/local/include/boost/iterator.hpp:17:
In file included from /usr/include/c++/4.2.1/iterator:68:
/usr/include/c++/4.2.1/bits/stl_iterator.h:362:5: error: conflicting types for 'operator>='
operator>=(const reverse_iterator<_IteratorL>& __x,
^
/usr/include/c++/4.2.1/bits/stl_pair.h:127:5: note: previous definition is here
operator>=(const pair<_T1, _T2>& __x, const pair<_T1, _T2>& __y)
^
In file included from layer1/COLLADA.cpp:35:
In file included from /Library/Frameworks/Collada14Dom.framework/Headers/dae.h:28:
In file included from /usr/local/include/boost/filesystem/convenience.hpp:22:
In file included from /usr/local/include/boost/filesystem/operations.hpp:25:
In file included from /usr/local/include/boost/filesystem/path.hpp:25:
In file included from /usr/local/include/boost/filesystem/path_traits.hpp:23:
In file included from /usr/local/include/boost/system/error_code.hpp:17:
In file included from /usr/local/include/boost/operators.hpp:86:
In file included from /usr/local/include/boost/iterator.hpp:17:
In file included from /usr/include/c++/4.2.1/iterator:68:
/usr/include/c++/4.2.1/bits/stl_iterator.h:368:5: error: conflicting types for 'operator-'
operator-(const reverse_iterator<_IteratorL>& __x,
^
/usr/include/c++/4.2.1/bits/stl_iterator.h:318:5: note: previous definition is here
operator-(const reverse_iterator<_Iterator>& __x,
^
/usr/include/c++/4.2.1/bits/stl_iterator.h:738:5: error: conflicting types for 'operator=='
operator==(const __normal_iterator<_Iterator, _Container>& __lhs,
^
/usr/include/c++/4.2.1/bits/stl_iterator.h:732:5: note: previous definition is here
operator==(const __normal_iterator<_IteratorL, _Container>& __lhs,
^
/usr/include/c++/4.2.1/bits/stl_iterator.h:750:5: error: conflicting types for 'operator!='
operator!=(const __normal_iterator<_Iterator, _Container>& __lhs,
^
/usr/include/c++/4.2.1/bits/stl_iterator.h:744:5: note: previous definition is here
operator!=(const __normal_iterator<_IteratorL, _Container>& __lhs,
^
fatal error: too many errors emitted, stopping now [-ferror-limit=]
20 errors generated.
error: command 'gcc' failed with exit status 1
Clearly GCC is having issues with the C++ headers, but I'm not sure how to resolve this. 显然,GCC在C ++标头中存在问题,但是我不确定如何解决此问题。
One important consideration is that there is no other C++ code in the project codebase. 一个重要的考虑因素是项目代码库中没有其他C ++代码。 (There is no C-based COLLADA library, and I really don't want to reinvent the wheel here.) So it seems likely that there is some configuration that needs to happen--some setting in setup.py, perhaps.
(没有基于C的COLLADA库,我真的不想在这里重新发明轮子。)因此,似乎需要进行一些配置-可能是setup.py中的某些设置。 Is there any way to tell
setup.py
to use something other than GCC to compile? 有没有办法告诉
setup.py
使用GCC以外的其他工具进行编译?
For what it's worth, I can fully reproduce the problem (after installing COLLADA DOM and Boost) with the following: 对于它的价值,我可以使用以下方法完全重现该问题(在安装COLLADA DOM和Boost之后):
sscce.cpp: sscce.cpp:
#ifdef __cplusplus
extern "C" {
#endif
#include <Collada14Dom/dae.h>
int main(){
return 0
}
#ifdef __cplusplus
} // END extern "C"
#endif
which, if I try to build using gcc sscce.cpp
, yields the same kinds of "conflicting types" errors as with the full program. 如果我尝试使用
gcc sscce.cpp
进行构建, gcc sscce.cpp
产生与整个程序相同类型的“冲突类型”错误。 Oddly (to me, anyway), I also get the same errors using g++ sscce.cpp
so I guess it may not be strictly a GCC problem. 奇怪的是(无论如何对我而言),使用
g++ sscce.cpp
也会出现相同的错误,因此我想这可能并不是严格意义上的GCC问题。
What am I missing? 我想念什么? Hopefully someone has seen this kind of thing before, and you won't actually have to install COLLADA DOM and Boost to be able to offer suggestions, as both libraries take some time to build.
希望有人以前见过这种情况,并且您实际上不必安装COLLADA DOM和Boost就能提供建议,因为这两个库都需要一些时间来构建。 As always, any help would be much appreciated.
一如既往,任何帮助将不胜感激。
Thanks! 谢谢!
Functions in this C++ file needs to be callable by other C code in the project, so I was under the impression I needed to enclose the C++ code in extern "C" blocks to avoid name mangling.
这个C ++文件中的函数必须可由项目中的其他C代码调用,因此给我的印象是,我需要将C ++代码放在外部的“ C”块中,以避免名称修饰。 Is that not the case?
不是吗?
extern "C"
blocks allow C declarations to be embedded in C++ code, while you want the reverse; extern "C"
块允许将C声明嵌入C ++代码中,而您想要相反的话; no provision exists for that. 没有为此准备。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.