Go to main content

Oracle® Solaris 64-bit Developer's Guide

Exit Print View

Updated: March 2019

5.1 Build Environment

The build environment includes the system headers, compilation system, and libraries. These are explained in the following sections.

5.1.1 Header Files

A single set of system headers supports both 32-bit and 64-bit compilation environments. You need not specify a different include path for the 64-bit compilation environment. Starting with Oracle Solaris 11, the <system/header> is available as an IPS package that contains core C and C++ header files.

To understand the changes made to the headers to support the 64-bit environment, you should understand the various definitions in the <sys/isa_defs.h> header file. This header contains a group of well known #defines and sets these for each instruction set architecture. Inclusion of <sys/types.h> automatically includes <sys/isa_defs.h>.

The symbols in the following table are defined by the compilation environment:

Indicates any of the SPARC family of processor architectures. This includes SPARC V7, SPARC V8, and SPARC V9 architectures. The symbol sparc is a deprecated historical synonym for __sparc.
Indicates the 32-bit SPARC V8 architecture as defined by Version 8 of the SPARC Architecture Manual.
Indicates the 64-bit SPARC V9 architecture as defined by Version 9 of the SPARC Architecture Manual.
Indicates any of the x86 family of processor architectures.
Indicates the 32-bit i386 architecture.
Indicates the 64-bit amd64 architecture.

Note -  __i386 and __amd64 are mutually exclusive. The __sparcv8 and __sparcv9 symbols are mutually exclusive and are only relevant when the __sparc symbol is defined.

The following symbols are derived from a combination of the symbols defined above:

The data model where sizes of int, long, and pointer are all 32-bit.
The data model where sizes of long and pointer are all 64-bit.

Note -  The _ILP32 and _LP64 symbols are mutually exclusive.

If writing completely portable code is not possible, and specific 32-bit versus 64-bit code is required, make the code conditional by using _ILP32 or _LP64. This makes the compilation environment machine independent and maximizes the portability of the application to all 64-bit platforms.

5.1.2 32-bit and 64-bit Libraries

The Oracle Solaris operating environment provides shared libraries for both 32-bit and 64-bit compilation environments.

32-bit applications must link with 32-bit libraries, and 64-bit applications must link with 64-bit libraries. It is not possible to create or execute a 32-bit application by using 64-bit libraries. The 32-bit libraries continue to be located in /usr/lib and /lib. The 64-bit libraries are located in a subdirectory of the appropriate lib directory. Because the placement of the 32-bit libraries has not changed, 32-bit applications built on prior releases are binary compatible. Portable Makefiles should refer to any library directories by using the 64 symbolic links. The /usr/lib/64 is symbolic link to /usr/lib/sparcv9 on SPARC systems and /usr/lib/amd64 on x86 systems.

In order to build 64-bit applications, you need 64-bit libraries. The compiler and other tools such as ld, ar, and as are capable of building 64-bit programs and 32-bit programs. Of course, a 64-bit program built on a system running the 32-bit operating system cannot execute in that 32-bit environment. However, in the future releases of Oracle Solaris, 32-bit might not be the default compilation mode.