在 Solaris 上,使用 gcc 编译的库是否可以像使用 cc 生成的库一样使用?

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

我目前正在尝试在 Solaris 上编译 libxml2 。当我 运行 随源代码提供的 ./configure 脚本时,会自动使用 gcc 和 g++ 编译器。但是,我想使用 cc 和 CC 编译器。所以我 运行 :

./configure CC=cc CXX=CC

它可以工作,但是当我运行“make”时,我遇到了一些阻止生成库的错误。

当使用 gcc 和 g++ 时,一切顺利,没有错误,所以我想知道:我可以像使用 gcc/g++ 一样使用生成的库吗?如果我用 cc/CC?

连续生成它们

在 Solaris 上用 cc 生成的库和用 gcc 生成的同一个库有什么区别?

您可以交替使用 gcccc C 编译器

您可以以某些方式混合使用 g++CC C++ 编译器,但仅限于 x86 Solaris 并且如果您的 CC 编译器足够新,可以使用 -compat=g 选项。

GNU g++ 和 Solaris Studio CC C++ 编译器默认使用完全不同的 ABI 和 C++ run-time 库。在 x86 Solaris 平台上,较新的版本(自版本 12.?,如果我没记错的话)提供了一个 -compat=g 选项来使用 g++ ABI 和 run-time 库。 Studio 12.4 CC compiler adds a -std=v option 到 select 不同版本的 g++ 或 Sun C++ ABI 和 run-time 库:

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.

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.

请注意,Studio 12.4 CC 编译器使用 g++ headers 和与 CC 编译器本身捆绑提供的库。 12.3 及更早版本使用 g++ headers 和系统上安装的库 /usr/sfw.

在 SPARC Solaris 上,您必须对整个应用程序使用 g++CC