Modify g++ library path

前端 未结 1 994
遇见更好的自我
遇见更好的自我 2021-01-28 08:01

I recently installed gcc 4.9.2 and found a problem when linking with libs.

The output for search path:

install: /usr/lib/gcc/x86_64-unknown-linux-gnu/4.9         


        
1条回答
  •  粉色の甜心
    2021-01-28 08:25

    You could have a new (or modify the existing) GCC specs file, documentation is here.

    AFAIK, the specs file is in your "install" dir, so for you would be in
    /usr/lib/gcc/x86_64-unknown-linux-gnu/4.9.2/specs (which you could create if it does not exist).

    AFAIK there is some built-in default, but you could configure your system to have an explicit one.

    Read also about the debugging options of GCC. You may want to use -dumpspecs to get the built-in default spec.

    Details may be highly specific to your system, especially if you compiled GCC from its source code.

    I am not familiar enough with specs files to give a reliable solution for your particular issue. You might ask on gcc-help@gcc.gnu.org for details.


    NB: I would tend to believe that configuring a gcc with --prefix=/usr (and not a non-system prefix like the default --prefix=/usr/local/ or some --prefix=/opt/ etc...) is a mistake (or at least use also --program-suffix=-4.9). You are likely to mix up your gcc with the system gcc; If you want to replace your system gcc (which is probably dangerous) you should configure your new gcc with the same arguments as your system gcc had. Notice that /usr/bin/gcc -v tells you how was your system gcc configured (to be done before overwriting it).

    When compiling a recent GCC 4.9 on some older system I generally would recommend to configure it with --prefix=/usr/local/ and --program-suffix=-4.9 then add /usr/local/bin/ to your $PATH, and use make CC=gcc-4.9 CXX=g++-4.9 for building programs with it.

    0 讨论(0)
提交回复
热议问题