mve icon indicating copy to clipboard operation
mve copied to clipboard

mve fails on compile (error: template with C linkage)

Open zyl1223582136 opened this issue 1 year ago • 3 comments

when i compile the code, errors occured. i don't know why, it seems the "util" package went wrong.

/usr/include/c++/11/bits/stl_tempbuf.h:225:3: error: template specialization with C linkage
  225 |   template<>
      |   ^~~~~~~~
In file included from /usr/include/features.h:461,
                 from /usr/include/x86_64-linux-gnu/c++/11/bits/os_defines.h:39,
                 from /usr/include/x86_64-linux-gnu/c++/11/bits/c++config.h:571,
                 from /usr/include/c++/11/iostream:38,
                 from file_system.cc:10:
/usr/include/string.h:28:1: note: ‘extern "C"’ linkage started here
   28 | __BEGIN_DECLS
      | ^~~~~~~~~~~~~
In file included from /usr/include/c++/11/bits/stl_algo.h:62,
                 from /usr/include/c++/11/algorithm:62,
                 from ./strings.h:17,
                 from /usr/include/string.h:432,
                 from /usr/include/c++/11/cstring:42,
                 from file_system.cc:15:
/usr/include/c++/11/bits/stl_tempbuf.h:243:3: error: template with C linkage
  243 |   template<typename _Pointer, typename _ForwardIterator>
      |   ^~~~~~~~
In file included from /usr/include/features.h:461,
                 from /usr/include/x86_64-linux-gnu/c++/11/bits/os_defines.h:39,
                 from /usr/include/x86_64-linux-gnu/c++/11/bits/c++config.h:571,
                 from /usr/include/c++/11/iostream:38,
                 from file_system.cc:10:
/usr/include/string.h:28:1: note: ‘extern "C"’ linkage started here
   28 | __BEGIN_DECLS
      | ^~~~~~~~~~~~~
In file included from /usr/include/c++/11/bits/stl_algo.h:62,
                 from /usr/include/c++/11/algorithm:62,
                 from ./strings.h:17,
                 from /usr/include/string.h:432,
                 from /usr/include/c++/11/cstring:42,
                 from file_system.cc:15:
/usr/include/c++/11/bits/stl_tempbuf.h:256:3: error: template with C linkage
  256 |   template<typename _ForwardIterator, typename _Tp>
      |   ^~~~~~~~
In file included from /usr/include/features.h:461,
                 from /usr/include/x86_64-linux-gnu/c++/11/bits/os_defines.h:39,
                 from /usr/include/x86_64-linux-gnu/c++/11/bits/c++config.h:571,
                 from /usr/include/c++/11/iostream:38,
                 from file_system.cc:10:
/usr/include/string.h:28:1: note: ‘extern "C"’ linkage started here
   28 | __BEGIN_DECLS
      | ^~~~~~~~~~~~~
In file included from /usr/include/c++/11/bits/stl_algo.h:66,
                 from /usr/include/c++/11/algorithm:62,
                 from ./strings.h:17,
                 from /usr/include/string.h:432,
                 from /usr/include/c++/11/cstring:42,
                 from file_system.cc:15:
/usr/include/c++/11/bits/uniform_int_dist.h:63:5: error: template with C linkage
   63 |     template<typename _Tp>
      |     ^~~~~~~~
In file included from /usr/include/features.h:461,
                 from /usr/include/x86_64-linux-gnu/c++/11/bits/os_defines.h:39,
                 from /usr/include/x86_64-linux-gnu/c++/11/bits/c++config.h:571,
                 from /usr/include/c++/11/iostream:38,
                 from file_system.cc:10:
/usr/include/string.h:28:1: note: ‘extern "C"’ linkage started here
   28 | __BEGIN_DECLS
      | ^~~~~~~~~~~~~
In file included from /usr/include/c++/11/bits/stl_algo.h:66,
                 from /usr/include/c++/11/algorithm:62,
                 from ./strings.h:17,
                 from /usr/include/string.h:432,
                 from /usr/include/c++/11/cstring:42,
                 from file_system.cc:15:
/usr/include/c++/11/bits/uniform_int_dist.h:76:3: error: template with C linkage
   76 |   template<typename _IntType = int>
      |   ^~~~~~~~
In file included from /usr/include/features.h:461,
                 from /usr/include/x86_64-linux-gnu/c++/11/bits/os_defines.h:39,
                 from /usr/include/x86_64-linux-gnu/c++/11/bits/c++config.h:571,
                 from /usr/include/c++/11/iostream:38,
                 from file_system.cc:10:
/usr/include/string.h:28:1: note: ‘extern "C"’ linkage started here
   28 | __BEGIN_DECLS
      | ^~~~~~~~~~~~~
In file included from /usr/include/c++/11/bits/stl_algo.h:66,
                 from /usr/include/c++/11/algorithm:62,
                 from ./strings.h:17,
                 from /usr/include/string.h:432,
                 from /usr/include/c++/11/cstring:42,
                 from file_system.cc:15:
/usr/include/c++/11/bits/uniform_int_dist.h:273:3: error: template with C linkage
  273 |   template<typename _IntType>
      |   ^~~~~~~~
In file included from /usr/include/features.h:461,
                 from /usr/include/x86_64-linux-gnu/c++/11/bits/os_defines.h:39,
                 from /usr/include/x86_64-linux-gnu/c++/11/bits/c++config.h:571,
                 from /usr/include/c++/11/iostream:38,
                 from file_system.cc:10:
/usr/include/string.h:28:1: note: ‘extern "C"’ linkage started here
   28 | __BEGIN_DECLS
      | ^~~~~~~~~~~~~
In file included from /usr/include/c++/11/bits/stl_algo.h:66,
                 from /usr/include/c++/11/algorithm:62,
                 from ./strings.h:17,
                 from /usr/include/string.h:432,
                 from /usr/include/c++/11/cstring:42,
                 from file_system.cc:15:
/usr/include/c++/11/bits/uniform_int_dist.h:364:3: error: template with C linkage
  364 |   template<typename _IntType>
      |   ^~~~~~~~
In file included from /usr/include/features.h:461,
                 from /usr/include/x86_64-linux-gnu/c++/11/bits/os_defines.h:39,
                 from /usr/include/x86_64-linux-gnu/c++/11/bits/c++config.h:571,
                 from /usr/include/c++/11/iostream:38,
                 from file_system.cc:10:
/usr/include/string.h:28:1: note: ‘extern "C"’ linkage started here
   28 | __BEGIN_DECLS
      | ^~~~~~~~~~~~~
In file included from /usr/include/c++/11/algorithm:62,
                 from ./strings.h:17,
                 from /usr/include/string.h:432,
                 from /usr/include/c++/11/cstring:42,
                 from file_system.cc:15:
/usr/include/c++/11/bits/stl_algo.h:76:3: error: template with C linkage
   76 |   template<typename _Iterator, typename _Compare>
      |   ^~~~~~~~
In file included from /usr/include/features.h:461,
                 from /usr/include/x86_64-linux-gnu/c++/11/bits/os_defines.h:39,
                 from /usr/include/x86_64-linux-gnu/c++/11/bits/c++config.h:571,
                 from /usr/include/c++/11/iostream:38,
                 from file_system.cc:10:
/usr/include/string.h:28:1: note: ‘extern "C"’ linkage started here
   28 | __BEGIN_DECLS
      | ^~~~~~~~~~~~~
In file included from /usr/include/c++/11/algorithm:62,
                 from ./strings.h:17,
                 from /usr/include/string.h:432,
                 from /usr/include/c++/11/cstring:42,
                 from file_system.cc:15:
/usr/include/c++/11/bits/stl_algo.h:100:3: error: template with C linkage
  100 |   template<typename _InputIterator, typename _Predicate>
      |   ^~~~~~~~
In file included from /usr/include/features.h:461,
                 from /usr/include/x86_64-linux-gnu/c++/11/bits/os_defines.h:39,
                 from /usr/include/x86_64-linux-gnu/c++/11/bits/c++config.h:571,
                 from /usr/include/c++/11/iostream:38,
                 from file_system.cc:10:
/usr/include/string.h:28:1: note: ‘extern "C"’ linkage started here
   28 | __BEGIN_DECLS
      | ^~~~~~~~~~~~~
In file included from /usr/include/c++/11/algorithm:62,
                 from ./strings.h:17,
                 from /usr/include/string.h:432,
                 from /usr/include/c++/11/cstring:42,
                 from file_system.cc:15:
/usr/include/c++/11/bits/stl_algo.h:114:3: error: template with C linkage
  114 |   template<typename _InputIterator, typename _Predicate, typename _Distance>
      |   ^~~~~~~~
In file included from /usr/include/features.h:461,
                 from /usr/include/x86_64-linux-gnu/c++/11/bits/os_defines.h:39,
                 from /usr/include/x86_64-linux-gnu/c++/11/bits/c++config.h:571,
                 from /usr/include/c++/11/iostream:38,
                 from file_system.cc:10:
/usr/include/string.h:28:1: note: ‘extern "C"’ linkage started here
   28 | __BEGIN_DECLS
      | ^~~~~~~~~~~~~
In file included from /usr/include/c++/11/algorithm:62,
                 from ./strings.h:17,
                 from /usr/include/string.h:432,
                 from /usr/include/c++/11/cstring:42,
                 from file_system.cc:15:
/usr/include/c++/11/bits/stl_algo.h:138:3: error: template with C linkage
  138 |   template<typename _ForwardIterator1, typename _ForwardIterator2,
      |   ^~~~~~~~
In file included from /usr/include/features.h:461,
                 from /usr/include/x86_64-linux-gnu/c++/11/bits/os_defines.h:39,
                 from /usr/include/x86_64-linux-gnu/c++/11/bits/c++config.h:571,
                 from /usr/include/c++/11/iostream:38,
                 from file_system.cc:10:
/usr/include/string.h:28:1: note: ‘extern "C"’ linkage started here
   28 | __BEGIN_DECLS
      | ^~~~~~~~~~~~~
In file included from /usr/include/c++/11/algorithm:62,
                 from ./strings.h:17,
                 from /usr/include/string.h:432,
                 from /usr/include/c++/11/cstring:42,
                 from file_system.cc:15:
/usr/include/c++/11/bits/stl_algo.h:190:3: error: template with C linkage
  190 |   template<typename _ForwardIterator, typename _Integer,
      |   ^~~~~~~~
In file included from /usr/include/features.h:461,
                 from /usr/include/x86_64-linux-gnu/c++/11/bits/os_defines.h:39,
                 from /usr/include/x86_64-linux-gnu/c++/11/bits/c++config.h:571,
                 from /usr/include/c++/11/iostream:38,
                 from file_system.cc:10:
/usr/include/string.h:28:1: note: ‘extern "C"’ linkage started here
   28 | __BEGIN_DECLS
      | ^~~~~~~~~~~~~
In file included from /usr/include/c++/11/algorithm:62,
                 from ./strings.h:17,
                 from /usr/include/string.h:432,
                 from /usr/include/c++/11/cstring:42,
                 from file_system.cc:15:
/usr/include/c++/11/bits/stl_algo.h:223:3: error: template with C linkage
  223 |   template<typename _RandomAccessIter, typename _Integer,
      |   ^~~~~~~~
In file included from /usr/include/features.h:461,
                 from /usr/include/x86_64-linux-gnu/c++/11/bits/os_defines.h:39,
                 from /usr/include/x86_64-linux-gnu/c++/11/bits/c++config.h:571,
                 from /usr/include/c++/11/iostream:38,
                 from file_system.cc:10:
/usr/include/string.h:28:1: note: ‘extern "C"’ linkage started here
   28 | __BEGIN_DECLS
      | ^~~~~~~~~~~~~
In file included from /usr/include/c++/11/algorithm:62,
                 from ./strings.h:17,
                 from /usr/include/string.h:432,
                 from /usr/include/c++/11/cstring:42,
                 from file_system.cc:15:
/usr/include/c++/11/bits/stl_algo.h:254:3: error: template with C linkage
  254 |   template<typename _ForwardIterator, typename _Integer,
      |   ^~~~~~~~
In file included from /usr/include/features.h:461,
                 from /usr/include/x86_64-linux-gnu/c++/11/bits/os_defines.h:39,
                 from /usr/include/x86_64-linux-gnu/c++/11/bits/c++config.h:571,
                 from /usr/include/c++/11/iostream:38,
                 from file_system.cc:10:
/usr/include/string.h:28:1: note: ‘extern "C"’ linkage started here
   28 | __BEGIN_DECLS
      | ^~~~~~~~~~~~~
In file included from /usr/include/c++/11/algorithm:62,
                 from ./strings.h:17,
                 from /usr/include/string.h:432,
                 from /usr/include/c++/11/cstring:42,
                 from file_system.cc:15:
/usr/include/c++/11/bits/stl_algo.h:273:3: error: template with C linkage
  273 |   template<typename _ForwardIterator1, typename _ForwardIterator2,
      |   ^~~~~~~~
In file included from /usr/include/features.h:461,
                 from /usr/include/x86_64-linux-gnu/c++/11/bits/os_defines.h:39,
                 from /usr/include/x86_64-linux-gnu/c++/11/bits/c++config.h:571,
                 from /usr/include/c++/11/iostream:38,
                 from file_system.cc:10:
/usr/include/string.h:28:1: note: ‘extern "C"’ linkage started here
   28 | __BEGIN_DECLS
      | ^~~~~~~~~~~~~
In file included from /usr/include/c++/11/algorithm:62,
                 from ./strings.h:17,
                 from /usr/include/string.h:432,
                 from /usr/include/c++/11/cstring:42,
                 from file_system.cc:15:
/usr/include/c++/11/bits/stl_algo.h:302:3: error: template with C linkage
  302 |   template<typename _BidirectionalIterator1, typename _BidirectionalIterator2,
      |   ^~~~~~~~
In file included from /usr/include/features.h:461,
                 from /usr/include/x86_64-linux-gnu/c++/11/bits/os_defines.h:39,
                 from /usr/include/x86_64-linux-gnu/c++/11/bits/c++config.h:571,
                 from /usr/include/c++/11/iostream:38,
                 from file_system.cc:10:
/usr/include/string.h:28:1: note: ‘extern "C"’ linkage started here
   28 | __BEGIN_DECLS
      | ^~~~~~~~~~~~~
In file included from /usr/include/c++/11/algorithm:62,
                 from ./strings.h:17,
                 from /usr/include/string.h:432,
                 from /usr/include/c++/11/cstring:42,
                 from file_system.cc:15:
/usr/include/c++/11/bits/stl_algo.h:364:3: error: template with C linkage
  364 |   template<typename _ForwardIterator1, typename _ForwardIterator2>
      |   ^~~~~~~~
In file included from /usr/include/features.h:461,
                 from /usr/include/x86_64-linux-gnu/c++/11/bits/os_defines.h:39,
                 from /usr/include/x86_64-linux-gnu/c++/11/bits/c++config.h:571,
                 from /usr/include/c++/11/iostream:38,
                 from file_system.cc:10:
/usr/include/string.h:28:1: note: ‘extern "C"’ linkage started here
   28 | __BEGIN_DECLS
      | ^~~~~~~~~~~~~
In file included from /usr/include/c++/11/algorithm:62,
                 from ./strings.h:17,
                 from /usr/include/string.h:432,
                 from /usr/include/c++/11/cstring:42,
                 from file_system.cc:15:
/usr/include/c++/11/bits/stl_algo.h:413:3: error: template with C linkage
  413 |   template<typename _ForwardIterator1, typename _ForwardIterator2,
      |   ^~~~~~~~
In file included from /usr/include/features.h:461,
                 from /usr/include/x86_64-linux-gnu/c++/11/bits/os_defines.h:39,
                 from /usr/include/x86_64-linux-gnu/c++/11/bits/c++config.h:571,
                 from /usr/include/c++/11/iostream:38,
                 from file_system.cc:10:
/usr/include/string.h:28:1: note: ‘extern "C"’ linkage started here
   28 | __BEGIN_DECLS
      | ^~~~~~~~~~~~~
In file included from /usr/include/c++/11/algorithm:62,
                 from ./strings.h:17,
                 from /usr/include/string.h:432,
                 from /usr/include/c++/11/cstring:42,
                 from file_system.cc:15:
/usr/include/c++/11/bits/stl_algo.h:449:3: error: template with C linkage
  449 |   template<typename _InputIterator, typename _Predicate>
      |   ^~~~~~~~
In file included from /usr/include/features.h:461,
                 from /usr/include/x86_64-linux-gnu/c++/11/bits/os_defines.h:39,
                 from /usr/include/x86_64-linux-gnu/c++/11/bits/c++config.h:571,
                 from /usr/include/c++/11/iostream:38,
                 from file_system.cc:10:
/usr/include/string.h:28:1: note: ‘extern "C"’ linkage started here
   28 | __BEGIN_DECLS
      | ^~~~~~~~~~~~~
In file included from /usr/include/c++/11/algorithm:62,
                 from ./strings.h:17,
                 from /usr/include/string.h:432,
                 from /usr/include/c++/11/cstring:42,
                 from file_system.cc:15:
/usr/include/c++/11/bits/stl_algo.h:467:3: error: template with C linkage
  467 |   template<typename _InputIterator, typename _Predicate>
      |   ^~~~~~~~
In file included from /usr/include/features.h:461,
                 from /usr/include/x86_64-linux-gnu/c++/11/bits/os_defines.h:39,
                 from /usr/include/x86_64-linux-gnu/c++/11/bits/c++config.h:571,
                 from /usr/include/c++/11/iostream:38,
                 from file_system.cc:10:
/usr/include/string.h:28:1: note: ‘extern "C"’ linkage started here
   28 | __BEGIN_DECLS
      | ^~~~~~~~~~~~~
In file included from /usr/include/c++/11/algorithm:62,
                 from ./strings.h:17,
                 from /usr/include/string.h:432,
                 from /usr/include/c++/11/cstring:42,
                 from file_system.cc:15:
/usr/include/c++/11/bits/stl_algo.h:486:3: error: template with C linkage
  486 |   template<typename _InputIterator, typename _Predicate>
      |   ^~~~~~~~
In file included from /usr/include/features.h:461,
                 from /usr/include/x86_64-linux-gnu/c++/11/bits/os_defines.h:39,
                 from /usr/include/x86_64-linux-gnu/c++/11/bits/c++config.h:571,
                 from /usr/include/c++/11/iostream:38,
                 from file_system.cc:10:
/usr/include/string.h:28:1: note: ‘extern "C"’ linkage started here
   28 | __BEGIN_DECLS
      | ^~~~~~~~~~~~~
In file included from /usr/include/c++/11/algorithm:62,
                 from ./strings.h:17,
                 from /usr/include/string.h:432,
                 from /usr/include/c++/11/cstring:42,
                 from file_system.cc:15:
/usr/include/c++/11/bits/stl_algo.h:502:3: error: template with C linkage
  502 |   template<typename _InputIterator, typename _Predicate>
      |   ^~~~~~~~
In file included from /usr/include/features.h:461,
                 from /usr/include/x86_64-linux-gnu/c++/11/bits/os_defines.h:39,
                 from /usr/include/x86_64-linux-gnu/c++/11/bits/c++config.h:571,
                 from /usr/include/c++/11/iostream:38,
                 from file_system.cc:10:
/usr/include/string.h:28:1: note: ‘extern "C"’ linkage started here
   28 | __BEGIN_DECLS
      | ^~~~~~~~~~~~~
In file included from /usr/include/c++/11/algorithm:62,
                 from ./strings.h:17,
                 from /usr/include/string.h:432,
                 from /usr/include/c++/11/cstring:42,
                 from file_system.cc:15:
/usr/include/c++/11/bits/stl_algo.h:527:3: error: template with C linkage
  527 |   template<typename _InputIterator, typename _Predicate>
      |   ^~~~~~~~
In file included from /usr/include/features.h:461,
                 from /usr/include/x86_64-linux-gnu/c++/11/bits/os_defines.h:39,
                 from /usr/include/x86_64-linux-gnu/c++/11/bits/c++config.h:571,
                 from /usr/include/c++/11/iostream:38,
                 from file_system.cc:10:
/usr/include/string.h:28:1: note: ‘extern "C"’ linkage started here
   28 | __BEGIN_DECLS
      | ^~~~~~~~~~~~~
In file included from /usr/include/c++/11/algorithm:62,
                 from ./strings.h:17,
                 from /usr/include/string.h:432,
                 from /usr/include/c++/11/cstring:42,
                 from file_system.cc:15:
/usr/include/c++/11/bits/stl_algo.h:549:3: error: template with C linkage
  549 |   template<typename _ForwardIterator, typename _Predicate>
      |   ^~~~~~~~
In file included from /usr/include/features.h:461,
                 from /usr/include/x86_64-linux-gnu/c++/11/bits/os_defines.h:39,
                 from /usr/include/x86_64-linux-gnu/c++/11/bits/c++config.h:571,
                 from /usr/include/c++/11/iostream:38,
                 from file_system.cc:10:
/usr/include/string.h:28:1: note: ‘extern "C"’ linkage started here
   28 | __BEGIN_DECLS
      | ^~~~~~~~~~~~~
In file included from /usr/include/c++/11/algorithm:62,
                 from ./strings.h:17,
                 from /usr/include/string.h:432,
                 from /usr/include/c++/11/cstring:42,
                 from file_system.cc:15:
make[2]: *** [../../Makefile.inc:29:file_system.o] 错误 1
make[2]: 离开目录“/home/ylzhang/文档/github/mvs-texturing/mve/libs/util”
make[1]: *** [Makefile:3:all] 错误 2
make[1]: 离开目录“/home/ylzhang/文档/github/mvs-texturing/mve/libs”
make: *** [Makefile:3:all] 错误 2

zyl1223582136 avatar Aug 24 '23 13:08 zyl1223582136

Sorry, I have never seen this error before, and don't know what it means.

simonfuhrmann avatar Aug 28 '23 11:08 simonfuhrmann

Have you solved it?

CHANGXU12 avatar Nov 21 '23 13:11 CHANGXU12

@zyl1223582136, @CHANGXU12, could you please provide some more information such as the operating system and compiler version?

andre-schulz avatar Nov 23 '23 20:11 andre-schulz

For someone encounters this compilation error. The root cause is that somehow the compiler tries to include utils/strings.h from string.h in C library, casing mixing C and C++ without closing the extern C part. The solution is to rename utils/strings.h to something else like utils/mve_strings.h

from ./strings.h:17, from /usr/include/string.h:432,

homee-dennis avatar Jul 26 '24 12:07 homee-dennis

Thanks for the comment. It seems we should rename utils/strings.h to something like utils/string_utils.h then to avoid this problem.

simonfuhrmann avatar Jul 31 '24 18:07 simonfuhrmann