gcc compiles gcc with errors 'template with C linkage' and 'template specialization with C linkage'












1















I am working with Ubuntu 14.04 LTS.
This already ships a packaged gcc 4.8.4 but I wanted to have a later version of gcc.





Using the existing version 4.8.4, I built version 4.9.4 from the source code through the recommended chain compile-build-test-install.
I have used no exotic settings for ./configure except for a prefix directory and a program-suffix. The rest is default.
All seems to have gone well. The test summary for g++ shows no FAIL and two XPASS calls only



XPASS: g++.dg/tls/thread_local-order2.C -std=c++11 execution test
XPASS: g++.dg/tls/thread_local-order2.C -std=c++1y execution test




I then wanted to build version 5.4.0 using the newly installed 4.9.4, to put the latter to the test with a minimum learning curve.
I edited the same installation script used for 4.9.4 only by specifying the make flags CC and CXX.
These flags now point to the binaries in the 4.9.4 installation directory.



The configure stage for 5.4.0 proceeds well.
I see from the files config.log and Makefile that the new binaries' paths are read in correctly.



The build stage fails though and stderr reports some 100 errors.
The earliest and most frequently recurring ones are of type



`error: template with C linkage`
`error: template specialization with C linkage`


They show up in patterns of blocks like this one:



In file included from ${installation directory for 4.9.4}/include/c++/4.9.4/bits/stringfwd.h:40:0,
from ${installation directory for 4.9.4}/include/c++/4.9.4/iosfwd:39,
from /usr/include/x86_64-linux-gnu/gmp.h:25,
from /usr/local/include/isl/val_gmp.h:4,
from ${source directory for 5-4-0}/gcc/graphite-isl-ast-to-gimple.c:35:

${installation directory for 4.9.4}/include/c++/4.9.4/bits/memoryfwd.h:63:3: error: template with C linkage
template<typename>
^
${installation directory for 4.9.4}/include/c++/4.9.4/bits/memoryfwd.h:66:3: error: template specialization with C linkage
template<>
^
${installation directory for 4.9.4}/include/c++/4.9.4/bits/memoryfwd.h:70:3: error: template with C linkage
template<typename, typename>
^


I would think that the 5.4.0 source is fine, since all information has been gathered and processed in the same way as it was for 4.9.4.
There could be an error/omission in the configure stage of either 4.9.4, or 5.4.0 or both.



Which flaws do these errors indicate? How do you fix them?



Thanks for thinking along.





A search query on StackExchange on error: template with C linkage gives about 171,000 results.
The posts that I skimmed do not seem to address this point:



https://stackoverflow.com/questions/29872494/compiling-a-program-under-windows-gives-a-bunch-of-error-template-with-c-linka



https://stackoverflow.com/questions/4115930/using-cygwin-to-build-template-with-c-linkage



Note that I am not interested in triaging the codes, but in setting up a (robustly) working compiler.










share|improve this question
















bumped to the homepage by Community 20 mins ago


This question has answers that may be good or bad; the system has marked it active so that they can be reviewed.
















  • Are you doing this just for fun, or because you need gcc-5.4? If the latter, then iirc it's available from the toolchain-r ppa

    – steeldriver
    Feb 13 '17 at 14:22











  • @steeldriver Your distinction between fun and need escapes me. I am doing it because I want to test the installation of 4.9.4 with anything. So I do it with 5.4.0 (if not 6.3.0) which I may wish to use at my earliest resolution. If you can expand on the relevance of iirc to this compilation failure, the readership will appreciate.

    – XavierStuvw
    Feb 13 '17 at 17:45











  • What I meant was if all you want is a version of gcc that is newer than that provided by the Ubuntu 14.04 repository, you can install 4.9.4, 5.4.1, and/or 6.2.0 simply by enabling the ppa I referred to in my earlier comment - no compiler compilation required

    – steeldriver
    Feb 13 '17 at 19:53











  • @steeldriver Thanks, clear. I am still interested in pinpointing the cause of this problem. In one computer this proof works well, in another it doesn't, starting from assumed equal conditions. So I would like to frame the pitfall.

    – XavierStuvw
    Feb 14 '17 at 10:55
















1















I am working with Ubuntu 14.04 LTS.
This already ships a packaged gcc 4.8.4 but I wanted to have a later version of gcc.





Using the existing version 4.8.4, I built version 4.9.4 from the source code through the recommended chain compile-build-test-install.
I have used no exotic settings for ./configure except for a prefix directory and a program-suffix. The rest is default.
All seems to have gone well. The test summary for g++ shows no FAIL and two XPASS calls only



XPASS: g++.dg/tls/thread_local-order2.C -std=c++11 execution test
XPASS: g++.dg/tls/thread_local-order2.C -std=c++1y execution test




I then wanted to build version 5.4.0 using the newly installed 4.9.4, to put the latter to the test with a minimum learning curve.
I edited the same installation script used for 4.9.4 only by specifying the make flags CC and CXX.
These flags now point to the binaries in the 4.9.4 installation directory.



The configure stage for 5.4.0 proceeds well.
I see from the files config.log and Makefile that the new binaries' paths are read in correctly.



The build stage fails though and stderr reports some 100 errors.
The earliest and most frequently recurring ones are of type



`error: template with C linkage`
`error: template specialization with C linkage`


They show up in patterns of blocks like this one:



In file included from ${installation directory for 4.9.4}/include/c++/4.9.4/bits/stringfwd.h:40:0,
from ${installation directory for 4.9.4}/include/c++/4.9.4/iosfwd:39,
from /usr/include/x86_64-linux-gnu/gmp.h:25,
from /usr/local/include/isl/val_gmp.h:4,
from ${source directory for 5-4-0}/gcc/graphite-isl-ast-to-gimple.c:35:

${installation directory for 4.9.4}/include/c++/4.9.4/bits/memoryfwd.h:63:3: error: template with C linkage
template<typename>
^
${installation directory for 4.9.4}/include/c++/4.9.4/bits/memoryfwd.h:66:3: error: template specialization with C linkage
template<>
^
${installation directory for 4.9.4}/include/c++/4.9.4/bits/memoryfwd.h:70:3: error: template with C linkage
template<typename, typename>
^


I would think that the 5.4.0 source is fine, since all information has been gathered and processed in the same way as it was for 4.9.4.
There could be an error/omission in the configure stage of either 4.9.4, or 5.4.0 or both.



Which flaws do these errors indicate? How do you fix them?



Thanks for thinking along.





A search query on StackExchange on error: template with C linkage gives about 171,000 results.
The posts that I skimmed do not seem to address this point:



https://stackoverflow.com/questions/29872494/compiling-a-program-under-windows-gives-a-bunch-of-error-template-with-c-linka



https://stackoverflow.com/questions/4115930/using-cygwin-to-build-template-with-c-linkage



Note that I am not interested in triaging the codes, but in setting up a (robustly) working compiler.










share|improve this question
















bumped to the homepage by Community 20 mins ago


This question has answers that may be good or bad; the system has marked it active so that they can be reviewed.
















  • Are you doing this just for fun, or because you need gcc-5.4? If the latter, then iirc it's available from the toolchain-r ppa

    – steeldriver
    Feb 13 '17 at 14:22











  • @steeldriver Your distinction between fun and need escapes me. I am doing it because I want to test the installation of 4.9.4 with anything. So I do it with 5.4.0 (if not 6.3.0) which I may wish to use at my earliest resolution. If you can expand on the relevance of iirc to this compilation failure, the readership will appreciate.

    – XavierStuvw
    Feb 13 '17 at 17:45











  • What I meant was if all you want is a version of gcc that is newer than that provided by the Ubuntu 14.04 repository, you can install 4.9.4, 5.4.1, and/or 6.2.0 simply by enabling the ppa I referred to in my earlier comment - no compiler compilation required

    – steeldriver
    Feb 13 '17 at 19:53











  • @steeldriver Thanks, clear. I am still interested in pinpointing the cause of this problem. In one computer this proof works well, in another it doesn't, starting from assumed equal conditions. So I would like to frame the pitfall.

    – XavierStuvw
    Feb 14 '17 at 10:55














1












1








1








I am working with Ubuntu 14.04 LTS.
This already ships a packaged gcc 4.8.4 but I wanted to have a later version of gcc.





Using the existing version 4.8.4, I built version 4.9.4 from the source code through the recommended chain compile-build-test-install.
I have used no exotic settings for ./configure except for a prefix directory and a program-suffix. The rest is default.
All seems to have gone well. The test summary for g++ shows no FAIL and two XPASS calls only



XPASS: g++.dg/tls/thread_local-order2.C -std=c++11 execution test
XPASS: g++.dg/tls/thread_local-order2.C -std=c++1y execution test




I then wanted to build version 5.4.0 using the newly installed 4.9.4, to put the latter to the test with a minimum learning curve.
I edited the same installation script used for 4.9.4 only by specifying the make flags CC and CXX.
These flags now point to the binaries in the 4.9.4 installation directory.



The configure stage for 5.4.0 proceeds well.
I see from the files config.log and Makefile that the new binaries' paths are read in correctly.



The build stage fails though and stderr reports some 100 errors.
The earliest and most frequently recurring ones are of type



`error: template with C linkage`
`error: template specialization with C linkage`


They show up in patterns of blocks like this one:



In file included from ${installation directory for 4.9.4}/include/c++/4.9.4/bits/stringfwd.h:40:0,
from ${installation directory for 4.9.4}/include/c++/4.9.4/iosfwd:39,
from /usr/include/x86_64-linux-gnu/gmp.h:25,
from /usr/local/include/isl/val_gmp.h:4,
from ${source directory for 5-4-0}/gcc/graphite-isl-ast-to-gimple.c:35:

${installation directory for 4.9.4}/include/c++/4.9.4/bits/memoryfwd.h:63:3: error: template with C linkage
template<typename>
^
${installation directory for 4.9.4}/include/c++/4.9.4/bits/memoryfwd.h:66:3: error: template specialization with C linkage
template<>
^
${installation directory for 4.9.4}/include/c++/4.9.4/bits/memoryfwd.h:70:3: error: template with C linkage
template<typename, typename>
^


I would think that the 5.4.0 source is fine, since all information has been gathered and processed in the same way as it was for 4.9.4.
There could be an error/omission in the configure stage of either 4.9.4, or 5.4.0 or both.



Which flaws do these errors indicate? How do you fix them?



Thanks for thinking along.





A search query on StackExchange on error: template with C linkage gives about 171,000 results.
The posts that I skimmed do not seem to address this point:



https://stackoverflow.com/questions/29872494/compiling-a-program-under-windows-gives-a-bunch-of-error-template-with-c-linka



https://stackoverflow.com/questions/4115930/using-cygwin-to-build-template-with-c-linkage



Note that I am not interested in triaging the codes, but in setting up a (robustly) working compiler.










share|improve this question
















I am working with Ubuntu 14.04 LTS.
This already ships a packaged gcc 4.8.4 but I wanted to have a later version of gcc.





Using the existing version 4.8.4, I built version 4.9.4 from the source code through the recommended chain compile-build-test-install.
I have used no exotic settings for ./configure except for a prefix directory and a program-suffix. The rest is default.
All seems to have gone well. The test summary for g++ shows no FAIL and two XPASS calls only



XPASS: g++.dg/tls/thread_local-order2.C -std=c++11 execution test
XPASS: g++.dg/tls/thread_local-order2.C -std=c++1y execution test




I then wanted to build version 5.4.0 using the newly installed 4.9.4, to put the latter to the test with a minimum learning curve.
I edited the same installation script used for 4.9.4 only by specifying the make flags CC and CXX.
These flags now point to the binaries in the 4.9.4 installation directory.



The configure stage for 5.4.0 proceeds well.
I see from the files config.log and Makefile that the new binaries' paths are read in correctly.



The build stage fails though and stderr reports some 100 errors.
The earliest and most frequently recurring ones are of type



`error: template with C linkage`
`error: template specialization with C linkage`


They show up in patterns of blocks like this one:



In file included from ${installation directory for 4.9.4}/include/c++/4.9.4/bits/stringfwd.h:40:0,
from ${installation directory for 4.9.4}/include/c++/4.9.4/iosfwd:39,
from /usr/include/x86_64-linux-gnu/gmp.h:25,
from /usr/local/include/isl/val_gmp.h:4,
from ${source directory for 5-4-0}/gcc/graphite-isl-ast-to-gimple.c:35:

${installation directory for 4.9.4}/include/c++/4.9.4/bits/memoryfwd.h:63:3: error: template with C linkage
template<typename>
^
${installation directory for 4.9.4}/include/c++/4.9.4/bits/memoryfwd.h:66:3: error: template specialization with C linkage
template<>
^
${installation directory for 4.9.4}/include/c++/4.9.4/bits/memoryfwd.h:70:3: error: template with C linkage
template<typename, typename>
^


I would think that the 5.4.0 source is fine, since all information has been gathered and processed in the same way as it was for 4.9.4.
There could be an error/omission in the configure stage of either 4.9.4, or 5.4.0 or both.



Which flaws do these errors indicate? How do you fix them?



Thanks for thinking along.





A search query on StackExchange on error: template with C linkage gives about 171,000 results.
The posts that I skimmed do not seem to address this point:



https://stackoverflow.com/questions/29872494/compiling-a-program-under-windows-gives-a-bunch-of-error-template-with-c-linka



https://stackoverflow.com/questions/4115930/using-cygwin-to-build-template-with-c-linkage



Note that I am not interested in triaging the codes, but in setting up a (robustly) working compiler.







ubuntu compiling gcc gnu-make






share|improve this question















share|improve this question













share|improve this question




share|improve this question








edited Feb 13 '17 at 18:29







XavierStuvw

















asked Feb 13 '17 at 10:38









XavierStuvwXavierStuvw

3391825




3391825





bumped to the homepage by Community 20 mins ago


This question has answers that may be good or bad; the system has marked it active so that they can be reviewed.







bumped to the homepage by Community 20 mins ago


This question has answers that may be good or bad; the system has marked it active so that they can be reviewed.















  • Are you doing this just for fun, or because you need gcc-5.4? If the latter, then iirc it's available from the toolchain-r ppa

    – steeldriver
    Feb 13 '17 at 14:22











  • @steeldriver Your distinction between fun and need escapes me. I am doing it because I want to test the installation of 4.9.4 with anything. So I do it with 5.4.0 (if not 6.3.0) which I may wish to use at my earliest resolution. If you can expand on the relevance of iirc to this compilation failure, the readership will appreciate.

    – XavierStuvw
    Feb 13 '17 at 17:45











  • What I meant was if all you want is a version of gcc that is newer than that provided by the Ubuntu 14.04 repository, you can install 4.9.4, 5.4.1, and/or 6.2.0 simply by enabling the ppa I referred to in my earlier comment - no compiler compilation required

    – steeldriver
    Feb 13 '17 at 19:53











  • @steeldriver Thanks, clear. I am still interested in pinpointing the cause of this problem. In one computer this proof works well, in another it doesn't, starting from assumed equal conditions. So I would like to frame the pitfall.

    – XavierStuvw
    Feb 14 '17 at 10:55



















  • Are you doing this just for fun, or because you need gcc-5.4? If the latter, then iirc it's available from the toolchain-r ppa

    – steeldriver
    Feb 13 '17 at 14:22











  • @steeldriver Your distinction between fun and need escapes me. I am doing it because I want to test the installation of 4.9.4 with anything. So I do it with 5.4.0 (if not 6.3.0) which I may wish to use at my earliest resolution. If you can expand on the relevance of iirc to this compilation failure, the readership will appreciate.

    – XavierStuvw
    Feb 13 '17 at 17:45











  • What I meant was if all you want is a version of gcc that is newer than that provided by the Ubuntu 14.04 repository, you can install 4.9.4, 5.4.1, and/or 6.2.0 simply by enabling the ppa I referred to in my earlier comment - no compiler compilation required

    – steeldriver
    Feb 13 '17 at 19:53











  • @steeldriver Thanks, clear. I am still interested in pinpointing the cause of this problem. In one computer this proof works well, in another it doesn't, starting from assumed equal conditions. So I would like to frame the pitfall.

    – XavierStuvw
    Feb 14 '17 at 10:55

















Are you doing this just for fun, or because you need gcc-5.4? If the latter, then iirc it's available from the toolchain-r ppa

– steeldriver
Feb 13 '17 at 14:22





Are you doing this just for fun, or because you need gcc-5.4? If the latter, then iirc it's available from the toolchain-r ppa

– steeldriver
Feb 13 '17 at 14:22













@steeldriver Your distinction between fun and need escapes me. I am doing it because I want to test the installation of 4.9.4 with anything. So I do it with 5.4.0 (if not 6.3.0) which I may wish to use at my earliest resolution. If you can expand on the relevance of iirc to this compilation failure, the readership will appreciate.

– XavierStuvw
Feb 13 '17 at 17:45





@steeldriver Your distinction between fun and need escapes me. I am doing it because I want to test the installation of 4.9.4 with anything. So I do it with 5.4.0 (if not 6.3.0) which I may wish to use at my earliest resolution. If you can expand on the relevance of iirc to this compilation failure, the readership will appreciate.

– XavierStuvw
Feb 13 '17 at 17:45













What I meant was if all you want is a version of gcc that is newer than that provided by the Ubuntu 14.04 repository, you can install 4.9.4, 5.4.1, and/or 6.2.0 simply by enabling the ppa I referred to in my earlier comment - no compiler compilation required

– steeldriver
Feb 13 '17 at 19:53





What I meant was if all you want is a version of gcc that is newer than that provided by the Ubuntu 14.04 repository, you can install 4.9.4, 5.4.1, and/or 6.2.0 simply by enabling the ppa I referred to in my earlier comment - no compiler compilation required

– steeldriver
Feb 13 '17 at 19:53













@steeldriver Thanks, clear. I am still interested in pinpointing the cause of this problem. In one computer this proof works well, in another it doesn't, starting from assumed equal conditions. So I would like to frame the pitfall.

– XavierStuvw
Feb 14 '17 at 10:55





@steeldriver Thanks, clear. I am still interested in pinpointing the cause of this problem. In one computer this proof works well, in another it doesn't, starting from assumed equal conditions. So I would like to frame the pitfall.

– XavierStuvw
Feb 14 '17 at 10:55










1 Answer
1






active

oldest

votes


















0














The problem has been avoided by setting the compilation switch --with-local-prefix=/usr of the configure shell script. The default is /usr/local, whereas Ubuntu appears to store the looked-for files in /usr. This has fixed the fatal errors in another compilation from source of HDF5 (see https://unix.stackexchange.com/a/346171/132913)



This setting is not recommended though. See the GCC on-line configure help:




--with-local-prefix=dirname



Specify the installation directory for local include files. The default is /usr/local. Specify this option if you want the compiler to search directory dirname/include for locally installed header files instead of /usr/local/include.



You should specify --with-local-prefix only if your site has a different convention (not /usr/local) for where to put site-specific files.



The default value for --with-local-prefix is /usr/local regardless of the value of --prefix. Specifying --prefix has no effect on which directory GCC searches for local header files. This may seem counterintuitive, but actually it is logical.



The purpose of --prefix is to specify where to install GCC. The local header files in /usr/local/include—if you put any in that directory—are not part of GCC. They are part of other programs—perhaps many others. (GCC installs its own header files in another directory which is based on the --prefix value.)



Both the local-prefix include directory and the GCC-prefix include directory are part of GCC’s “system include” directories. Although these two directories are not fixed, they need to be searched in the proper order for the correct processing of the include_next directive. The local-prefix include directory is searched before the GCC-prefix include directory. Another characteristic of system include directories is that pedantic warnings are turned off for headers in these directories.



Some autoconf macros add -I directory options to the compiler command line, to ensure that directories containing installed packages’ headers are searched. When directory is one of GCC’s system include directories, GCC will ignore the option so that system directories continue to be processed in the correct order. This may result in a search order different from what was specified but the directory will still be searched.



GCC automatically searches for ordinary libraries using GCC_EXEC_PREFIX. Thus, when the same installation prefix is used for both GCC and packages, GCC will automatically search for both headers and libraries. This provides a configuration that is easy to use. GCC behaves in a manner similar to that when it is installed as a system compiler in /usr.



Sites that need to install multiple versions of GCC may not want to use the above simple configuration. It is possible to use the --program-prefix, --program-suffix and --program-transform-name options to install multiple versions into a single directory, but it may be simpler to use different prefixes and the --with-local-prefix option to specify the location of the site-specific files for each version. It will then be necessary for users to specify explicitly the location of local site libraries (e.g., with LIBRARY_PATH).



The same value can be used for both --with-local-prefix and --prefix provided it is not /usr. This can be used to avoid the default search of /usr/local/include.



Do not specify /usr as the --with-local-prefix! The directory you use for --with-local-prefix must not contain any of the system’s standard header files. If it did contain them, certain programs would be miscompiled (including GNU Emacs, on certain targets), because this would override and nullify the header file corrections made by the fixincludes script.



Indications are that people who use this option use it based on mistaken ideas of what it is for. People use it as if it specified where to install part of GCC. Perhaps they make this assumption because installing GCC creates the directory.




I will address these inconsistencies in another post at my earliest opportunity.






share|improve this answer

























    Your Answer








    StackExchange.ready(function() {
    var channelOptions = {
    tags: "".split(" "),
    id: "106"
    };
    initTagRenderer("".split(" "), "".split(" "), channelOptions);

    StackExchange.using("externalEditor", function() {
    // Have to fire editor after snippets, if snippets enabled
    if (StackExchange.settings.snippets.snippetsEnabled) {
    StackExchange.using("snippets", function() {
    createEditor();
    });
    }
    else {
    createEditor();
    }
    });

    function createEditor() {
    StackExchange.prepareEditor({
    heartbeatType: 'answer',
    autoActivateHeartbeat: false,
    convertImagesToLinks: false,
    noModals: true,
    showLowRepImageUploadWarning: true,
    reputationToPostImages: null,
    bindNavPrevention: true,
    postfix: "",
    imageUploader: {
    brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
    contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
    allowUrls: true
    },
    onDemand: true,
    discardSelector: ".discard-answer"
    ,immediatelyShowMarkdownHelp:true
    });


    }
    });














    draft saved

    draft discarded


















    StackExchange.ready(
    function () {
    StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2funix.stackexchange.com%2fquestions%2f344595%2fgcc-compiles-gcc-with-errors-template-with-c-linkage-and-template-specializat%23new-answer', 'question_page');
    }
    );

    Post as a guest















    Required, but never shown

























    1 Answer
    1






    active

    oldest

    votes








    1 Answer
    1






    active

    oldest

    votes









    active

    oldest

    votes






    active

    oldest

    votes









    0














    The problem has been avoided by setting the compilation switch --with-local-prefix=/usr of the configure shell script. The default is /usr/local, whereas Ubuntu appears to store the looked-for files in /usr. This has fixed the fatal errors in another compilation from source of HDF5 (see https://unix.stackexchange.com/a/346171/132913)



    This setting is not recommended though. See the GCC on-line configure help:




    --with-local-prefix=dirname



    Specify the installation directory for local include files. The default is /usr/local. Specify this option if you want the compiler to search directory dirname/include for locally installed header files instead of /usr/local/include.



    You should specify --with-local-prefix only if your site has a different convention (not /usr/local) for where to put site-specific files.



    The default value for --with-local-prefix is /usr/local regardless of the value of --prefix. Specifying --prefix has no effect on which directory GCC searches for local header files. This may seem counterintuitive, but actually it is logical.



    The purpose of --prefix is to specify where to install GCC. The local header files in /usr/local/include—if you put any in that directory—are not part of GCC. They are part of other programs—perhaps many others. (GCC installs its own header files in another directory which is based on the --prefix value.)



    Both the local-prefix include directory and the GCC-prefix include directory are part of GCC’s “system include” directories. Although these two directories are not fixed, they need to be searched in the proper order for the correct processing of the include_next directive. The local-prefix include directory is searched before the GCC-prefix include directory. Another characteristic of system include directories is that pedantic warnings are turned off for headers in these directories.



    Some autoconf macros add -I directory options to the compiler command line, to ensure that directories containing installed packages’ headers are searched. When directory is one of GCC’s system include directories, GCC will ignore the option so that system directories continue to be processed in the correct order. This may result in a search order different from what was specified but the directory will still be searched.



    GCC automatically searches for ordinary libraries using GCC_EXEC_PREFIX. Thus, when the same installation prefix is used for both GCC and packages, GCC will automatically search for both headers and libraries. This provides a configuration that is easy to use. GCC behaves in a manner similar to that when it is installed as a system compiler in /usr.



    Sites that need to install multiple versions of GCC may not want to use the above simple configuration. It is possible to use the --program-prefix, --program-suffix and --program-transform-name options to install multiple versions into a single directory, but it may be simpler to use different prefixes and the --with-local-prefix option to specify the location of the site-specific files for each version. It will then be necessary for users to specify explicitly the location of local site libraries (e.g., with LIBRARY_PATH).



    The same value can be used for both --with-local-prefix and --prefix provided it is not /usr. This can be used to avoid the default search of /usr/local/include.



    Do not specify /usr as the --with-local-prefix! The directory you use for --with-local-prefix must not contain any of the system’s standard header files. If it did contain them, certain programs would be miscompiled (including GNU Emacs, on certain targets), because this would override and nullify the header file corrections made by the fixincludes script.



    Indications are that people who use this option use it based on mistaken ideas of what it is for. People use it as if it specified where to install part of GCC. Perhaps they make this assumption because installing GCC creates the directory.




    I will address these inconsistencies in another post at my earliest opportunity.






    share|improve this answer






























      0














      The problem has been avoided by setting the compilation switch --with-local-prefix=/usr of the configure shell script. The default is /usr/local, whereas Ubuntu appears to store the looked-for files in /usr. This has fixed the fatal errors in another compilation from source of HDF5 (see https://unix.stackexchange.com/a/346171/132913)



      This setting is not recommended though. See the GCC on-line configure help:




      --with-local-prefix=dirname



      Specify the installation directory for local include files. The default is /usr/local. Specify this option if you want the compiler to search directory dirname/include for locally installed header files instead of /usr/local/include.



      You should specify --with-local-prefix only if your site has a different convention (not /usr/local) for where to put site-specific files.



      The default value for --with-local-prefix is /usr/local regardless of the value of --prefix. Specifying --prefix has no effect on which directory GCC searches for local header files. This may seem counterintuitive, but actually it is logical.



      The purpose of --prefix is to specify where to install GCC. The local header files in /usr/local/include—if you put any in that directory—are not part of GCC. They are part of other programs—perhaps many others. (GCC installs its own header files in another directory which is based on the --prefix value.)



      Both the local-prefix include directory and the GCC-prefix include directory are part of GCC’s “system include” directories. Although these two directories are not fixed, they need to be searched in the proper order for the correct processing of the include_next directive. The local-prefix include directory is searched before the GCC-prefix include directory. Another characteristic of system include directories is that pedantic warnings are turned off for headers in these directories.



      Some autoconf macros add -I directory options to the compiler command line, to ensure that directories containing installed packages’ headers are searched. When directory is one of GCC’s system include directories, GCC will ignore the option so that system directories continue to be processed in the correct order. This may result in a search order different from what was specified but the directory will still be searched.



      GCC automatically searches for ordinary libraries using GCC_EXEC_PREFIX. Thus, when the same installation prefix is used for both GCC and packages, GCC will automatically search for both headers and libraries. This provides a configuration that is easy to use. GCC behaves in a manner similar to that when it is installed as a system compiler in /usr.



      Sites that need to install multiple versions of GCC may not want to use the above simple configuration. It is possible to use the --program-prefix, --program-suffix and --program-transform-name options to install multiple versions into a single directory, but it may be simpler to use different prefixes and the --with-local-prefix option to specify the location of the site-specific files for each version. It will then be necessary for users to specify explicitly the location of local site libraries (e.g., with LIBRARY_PATH).



      The same value can be used for both --with-local-prefix and --prefix provided it is not /usr. This can be used to avoid the default search of /usr/local/include.



      Do not specify /usr as the --with-local-prefix! The directory you use for --with-local-prefix must not contain any of the system’s standard header files. If it did contain them, certain programs would be miscompiled (including GNU Emacs, on certain targets), because this would override and nullify the header file corrections made by the fixincludes script.



      Indications are that people who use this option use it based on mistaken ideas of what it is for. People use it as if it specified where to install part of GCC. Perhaps they make this assumption because installing GCC creates the directory.




      I will address these inconsistencies in another post at my earliest opportunity.






      share|improve this answer




























        0












        0








        0







        The problem has been avoided by setting the compilation switch --with-local-prefix=/usr of the configure shell script. The default is /usr/local, whereas Ubuntu appears to store the looked-for files in /usr. This has fixed the fatal errors in another compilation from source of HDF5 (see https://unix.stackexchange.com/a/346171/132913)



        This setting is not recommended though. See the GCC on-line configure help:




        --with-local-prefix=dirname



        Specify the installation directory for local include files. The default is /usr/local. Specify this option if you want the compiler to search directory dirname/include for locally installed header files instead of /usr/local/include.



        You should specify --with-local-prefix only if your site has a different convention (not /usr/local) for where to put site-specific files.



        The default value for --with-local-prefix is /usr/local regardless of the value of --prefix. Specifying --prefix has no effect on which directory GCC searches for local header files. This may seem counterintuitive, but actually it is logical.



        The purpose of --prefix is to specify where to install GCC. The local header files in /usr/local/include—if you put any in that directory—are not part of GCC. They are part of other programs—perhaps many others. (GCC installs its own header files in another directory which is based on the --prefix value.)



        Both the local-prefix include directory and the GCC-prefix include directory are part of GCC’s “system include” directories. Although these two directories are not fixed, they need to be searched in the proper order for the correct processing of the include_next directive. The local-prefix include directory is searched before the GCC-prefix include directory. Another characteristic of system include directories is that pedantic warnings are turned off for headers in these directories.



        Some autoconf macros add -I directory options to the compiler command line, to ensure that directories containing installed packages’ headers are searched. When directory is one of GCC’s system include directories, GCC will ignore the option so that system directories continue to be processed in the correct order. This may result in a search order different from what was specified but the directory will still be searched.



        GCC automatically searches for ordinary libraries using GCC_EXEC_PREFIX. Thus, when the same installation prefix is used for both GCC and packages, GCC will automatically search for both headers and libraries. This provides a configuration that is easy to use. GCC behaves in a manner similar to that when it is installed as a system compiler in /usr.



        Sites that need to install multiple versions of GCC may not want to use the above simple configuration. It is possible to use the --program-prefix, --program-suffix and --program-transform-name options to install multiple versions into a single directory, but it may be simpler to use different prefixes and the --with-local-prefix option to specify the location of the site-specific files for each version. It will then be necessary for users to specify explicitly the location of local site libraries (e.g., with LIBRARY_PATH).



        The same value can be used for both --with-local-prefix and --prefix provided it is not /usr. This can be used to avoid the default search of /usr/local/include.



        Do not specify /usr as the --with-local-prefix! The directory you use for --with-local-prefix must not contain any of the system’s standard header files. If it did contain them, certain programs would be miscompiled (including GNU Emacs, on certain targets), because this would override and nullify the header file corrections made by the fixincludes script.



        Indications are that people who use this option use it based on mistaken ideas of what it is for. People use it as if it specified where to install part of GCC. Perhaps they make this assumption because installing GCC creates the directory.




        I will address these inconsistencies in another post at my earliest opportunity.






        share|improve this answer















        The problem has been avoided by setting the compilation switch --with-local-prefix=/usr of the configure shell script. The default is /usr/local, whereas Ubuntu appears to store the looked-for files in /usr. This has fixed the fatal errors in another compilation from source of HDF5 (see https://unix.stackexchange.com/a/346171/132913)



        This setting is not recommended though. See the GCC on-line configure help:




        --with-local-prefix=dirname



        Specify the installation directory for local include files. The default is /usr/local. Specify this option if you want the compiler to search directory dirname/include for locally installed header files instead of /usr/local/include.



        You should specify --with-local-prefix only if your site has a different convention (not /usr/local) for where to put site-specific files.



        The default value for --with-local-prefix is /usr/local regardless of the value of --prefix. Specifying --prefix has no effect on which directory GCC searches for local header files. This may seem counterintuitive, but actually it is logical.



        The purpose of --prefix is to specify where to install GCC. The local header files in /usr/local/include—if you put any in that directory—are not part of GCC. They are part of other programs—perhaps many others. (GCC installs its own header files in another directory which is based on the --prefix value.)



        Both the local-prefix include directory and the GCC-prefix include directory are part of GCC’s “system include” directories. Although these two directories are not fixed, they need to be searched in the proper order for the correct processing of the include_next directive. The local-prefix include directory is searched before the GCC-prefix include directory. Another characteristic of system include directories is that pedantic warnings are turned off for headers in these directories.



        Some autoconf macros add -I directory options to the compiler command line, to ensure that directories containing installed packages’ headers are searched. When directory is one of GCC’s system include directories, GCC will ignore the option so that system directories continue to be processed in the correct order. This may result in a search order different from what was specified but the directory will still be searched.



        GCC automatically searches for ordinary libraries using GCC_EXEC_PREFIX. Thus, when the same installation prefix is used for both GCC and packages, GCC will automatically search for both headers and libraries. This provides a configuration that is easy to use. GCC behaves in a manner similar to that when it is installed as a system compiler in /usr.



        Sites that need to install multiple versions of GCC may not want to use the above simple configuration. It is possible to use the --program-prefix, --program-suffix and --program-transform-name options to install multiple versions into a single directory, but it may be simpler to use different prefixes and the --with-local-prefix option to specify the location of the site-specific files for each version. It will then be necessary for users to specify explicitly the location of local site libraries (e.g., with LIBRARY_PATH).



        The same value can be used for both --with-local-prefix and --prefix provided it is not /usr. This can be used to avoid the default search of /usr/local/include.



        Do not specify /usr as the --with-local-prefix! The directory you use for --with-local-prefix must not contain any of the system’s standard header files. If it did contain them, certain programs would be miscompiled (including GNU Emacs, on certain targets), because this would override and nullify the header file corrections made by the fixincludes script.



        Indications are that people who use this option use it based on mistaken ideas of what it is for. People use it as if it specified where to install part of GCC. Perhaps they make this assumption because installing GCC creates the directory.




        I will address these inconsistencies in another post at my earliest opportunity.







        share|improve this answer














        share|improve this answer



        share|improve this answer








        edited Mar 3 '17 at 21:17

























        answered Mar 3 '17 at 9:42









        XavierStuvwXavierStuvw

        3391825




        3391825






























            draft saved

            draft discarded




















































            Thanks for contributing an answer to Unix & Linux Stack Exchange!


            • Please be sure to answer the question. Provide details and share your research!

            But avoid



            • Asking for help, clarification, or responding to other answers.

            • Making statements based on opinion; back them up with references or personal experience.


            To learn more, see our tips on writing great answers.




            draft saved


            draft discarded














            StackExchange.ready(
            function () {
            StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2funix.stackexchange.com%2fquestions%2f344595%2fgcc-compiles-gcc-with-errors-template-with-c-linkage-and-template-specializat%23new-answer', 'question_page');
            }
            );

            Post as a guest















            Required, but never shown





















































            Required, but never shown














            Required, but never shown












            Required, but never shown







            Required, but never shown

































            Required, but never shown














            Required, but never shown












            Required, but never shown







            Required, but never shown







            Popular posts from this blog

            Loup dans la culture

            How to solve the problem of ntp “Unable to contact time server” from KDE?

            Connection limited (no internet access)