Opened 18 years ago

Last modified 15 years ago

#346 closed Support Requests

Error: Template with C linkage — at Version 6

Reported by: nobody Owned by: Douglas Gregor
Milestone: Component: None
Version: None Severity: Problem
Keywords: Cc: valeika@…

Description (last modified by Douglas Gregor)

My email:
valeika@email.unc.edu

I'm a C++ noob, so thanks for looking this over.  I am
trying to use the boost graph library for an infection
transmission project.  However, I can't get the BGL to
work.  In even a simple program that just has:

#include <boost\graph\xxxx.hpp>

will not compile.  I get hundreds of template with c
linkage errors.  I'm not sure where to go from here.  I
am using a Mac G5 and am using xcode to edit, build,
compile and run my code.  Xcode uses the gcc 3.3.

Thanks,
Steve

Change History (6)

comment:1 by Jonathan Turkanis, 18 years ago

Logged In: YES 
user_id=811799

There's no file named boost\graph\xxxx.hpp.

Seriously, you need to say what file caused the error, and
provide at least some of the error messages.

Also, you should use forward slashes.

Jonathan Turkanis

comment:2 by pulco-citron, 18 years ago

Logged In: YES 
user_id=625189

I'm having the same kind of errors, I think.

I'm using a powerpc with darwin 7.8.0, compiling with gcc
3.3 (apple build) and gcc 3.4.3.

Not a single boost source file compiles, in fact: every time
a boost .hpp refers to some STL header, tons of "error:
template with C linkage" come up. g++ mistakenly assumes
that such included files have C linkage.

IMHO, that can be corrected with the adequate compiler flag
(which one ?)

comment:3 by stevehartwell, 18 years ago

Logged In: YES 
user_id=962957

I have determined one way this problem can occur, and it's unrelated to 
boost.  (I've googled and searched the boost archives but I haven't found a 
resolution for this problem yet).

It seems that with gcc 3.3 (the MacOS X version I'm using), if any headers 
are found in the paths found by -isystem parameters, those header files 
will be compiled with C linkage, regardless of the source language being 
compiled (e.g. g++ or /usr/bin/gcc-3.3 -x c++ ...)

Here's a transcript of a terminal session showing the problem:

$ mkdir /tmp/sys
$ ed
a
template <class T> inline void foo(T& t) { }
.
w /tmp/sys/foo.hpp
45
q
$ ed
a
/* */
#include "foo.hpp"

int main(int argc, char **argv) { return 0; }
.
w foo.cpp
72
q
$ cc -isystem /tmp/sys foo.cpp
In file included from foo.cpp:2:
/tmp/sys/foo.hpp:1: error: template with C linkage
~
$ g++ -isystem /tmp/sys foo.cpp
In file included from foo.cpp:2:
/tmp/sys/foo.hpp:1: error: template with C linkage
$

comment:4 by david_abrahams, 16 years ago

Status: assignedclosed
Logged In: YES 
user_id=52572
Originator: NO

Closing because the Graph developers use MacOSX and presumably it works for them.  Feel free to reopen if this is inappropriate.

comment:5 by anonymous, 15 years ago

Resolution: Works For Me
Status: closedreopened

same problems.

gcc-4.0 i686-apple-darwin8-g++-4.0.1

error: g++ -g -Wall -Wno-unused -I. -I/usr/include/libxml2 -I/usr/local/include -c main.cc -o main.o /usr/include/c++/4.0.0/bits/stl_relops.h:118: error: template with C linkage /usr/include/c++/4.0.0/bits/stl_relops.h:131: error: template with C linkage /usr/include/boost/checked_delete.hpp:29: error: template with C linkage

I installed boost to prefix /usr, had to make a symbolic link ln -s boost-1_34_1 boost

in reply to:  5 comment:6 by Douglas Gregor, 15 years ago

Cc: valeika@… added
Description: modified (diff)
Severity: Problem

Which version Mac OS X are you using?

Does a simple program including just <vector> compile?

Steve Hartwell seems to have found the same problem on Mac OS X, and in his case it was unrelated to Boost.

Note: See TracTickets for help on using tickets.