On Solaris, are libraries compiled with gcc usable the same way as for libs generated with cc?

被刻印的时光 ゝ 提交于 2019-12-12 18:26:45

问题


I am currently trying to compile libxml2 on Solaris. When I run the ./configure script provided with the sources, the gcc and g++ compilers are automatically used. However, I would like to use cc and CC compilers. So I run :

./configure CC=cc CXX=CC

It works but then, when I run "make", I get some errors which prevent the libraries to be generated.

When gcc and g++ are used, everything goes well with no errors, so I was wondering: can I use the librairies generated with gcc/g++ the same way I would have used them if I had successively generated them with cc/CC?

What are the differences between a lib generated with cc and the same lib generated with gcc on Solaris?


回答1:


You can use either the gcc or cc C compilers pretty much interchangeably.

You can mix the g++ and CC C++ compilers in certain ways, but only on x86 Solaris and if your CC compiler is new enough to have the -compat=g option available.

The GNU g++ and the Solaris Studio CC C++ compilers default to completely different ABIs and C++ run-time libraries. On x86 Solaris platforms, newer versions (since version 12.?, if I remember correctly) provide a -compat=g option to use the g++ ABI and run-time libraries. The Studio 12.4 CC compiler adds a -std=v option to select different versions of the g++ or Sun C++ ABI and run-time libraries:

c++03 (zero-3, not oh-3)

Equivalent to the -compat=g option. It selects C++ 03 dialect and g++ ABI; it is binary compatible with g++ on Solaris and Linux It sets the __SUNPRO_CC_COMPAT preprocessor macro to 'G'.

c++11

Selects C++ 11 dialect and g++ binary compatibility. It sets the __SUNPRO_CC_COMPAT preprocessor macro to 'G'.

c++0x (zero-x, not oh-x)

Equivalent to c++11.

and

The -std=c++03 provides compatibility with the gcc/g++ compiler on all Oracle Solaris and Linux platforms.

With -std=c++03, binary compatibility extends only to shared (dynamic or .so) libraries, not to individual .o files or archive (.a) libraries. The gcc headers and libraries used are those provided with the compiler, rather than the version of gcc installed on the system.

Note that the Studio 12.4 CC compiler uses the g++ headers and libraries supplied bundled with the CC compiler itself. 12.3 and earlier use the g++ headers and libraries installed on the system under /usr/sfw.

On SPARC Solaris, you have to use either g++ or CC for the entire application.



来源:https://stackoverflow.com/questions/38260829/on-solaris-are-libraries-compiled-with-gcc-usable-the-same-way-as-for-libs-gene

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!