Saturday, 15 May 2010

c++ - Linking g++ 4.8 to libstdc++ -


I downloaded and created GCC 4.8.1 on my desktop, running 64-bit Ubuntu 12.04. I made it out of the source, such as the document has been recommended, and with command

  ../../ gcc-4.8.1 / configure - prefix = $ HOME - the program -Configuration = -4.8 Install Make-up checks   

It seems that all the tests were passed, and I have everything to distinguish the system GCC from my home directory. / Prefix was installed in -4.8, which is version 4.6.3.

Unfortunately, when I compile a C ++ program using G ++ - 4.8, then this system connects with Liby and Libastedic ++, not new people compiled from GCC-4.8.1 Instead. I downloaded and made GCC 4.8 because I wanted to play with the new C + 11 features in the standard library, so this behavior certainly did not want me. Can I automatically link to standard libraries to get GCC-4.8 which came with it rather than system standard libraries?

When you link to your own GCC, you get additional run-time linker search path) With -Wl, -rpath, $ (PREFIX) / lib64 so that it finds a shared library corresponding to your GCC at run-time.

I usually have a cover named GCC-4.8 and G ++ - 4.8 in the same directory as GCC And G ++ and GCC-4.8 and G ++ - 4.8 , as defined:

 < Code> #! / Bin / bash exec $ {0} SUFFIX -Wl, - Rpath, PREFIX / lib64 "$ @"   

when SUFFIX is installed and PREFIX should be replaced with the passed to configure :

  CD $ {PREFIX} / bin & amp; RM-FGCC G ++ C + Gaferon Sad-A's # PREFIX # $ {PREFIX} # G 'A' S # SFFIX # $ {SUFIFS} # G 'GCC-WAPER SA & gt; $ {PREFIX} / bin / gcc chmod + x $ {PREFIX} / bin / gcc cd $ {PREFIX} / bin & amp; LN GCC G ++ End & amp; LN GCC C ++ End & amp;   

( gcc-wrapper.sh that's the Bash Snippet).


does not work with the above solution G ++ -Wl, ... -v linking due to some versions of libtool Mode assumes and fails with an error.

There is a better solution to use this. Once the specs file has been created GCC / G ++, then the linker command line ( $ {PREFIX} to add the GPC / G ++ / Lib64 change as necessary):

  G ++ - Dmax | Awk '/ ^ \ * link: / {print; get line; Print "-rpath = $ {PREFIX} / lib64", $ 0; Next} {Print} '& gt; $ (Dynamic name $ (g ++ -print-libgcc-file-name)) / specs    

No comments:

Post a Comment