Category: Compilation & Linking
How do I build for 64-bit platforms?
Let's start by looking at the examples. Hopefully, once you understand how the examples work, you can then get your own build to work as well. The examples are all built using Codemesh's ANT wrappers for the code generator and the C++ compilers. Many 64-bit platforms support two different runtime environments: 32-bit and 64-bit. You typically cannot mix and match modules built for different runtime environments within one process.
While the generated code is compiler- and platform-portable, the runtime libraries are not. For us, this means that for every supported compiler/platform combination, we have to supply two different versions of the runtime library: one for the 32-bit and one for the 64-bit runtime environment.
For you, this means that you have to decide how you wish to build your code. By default, our examples always build in 32-bit mode, even when you've downloaded a version of JunC++ion that supports 64-bit executables. In the ANT-based examples, the "bittedness" is determined via the build.bits variable. To build in 64-bit mode, you have to either
- modify the default value of build.bits in buildoptions.xml, or
- override its value by invoking ./build with the -Dbuild.bits=64 option.
What does build.bits do?
build.bits is responsible for setting the proper compiler options (in the case of g++ it's -m32 or -m64) and choosing the correct runtime library directory (for example cpp/linux-all-x86 vs. cpp/linux-all-x86_64).
Please be aware that you can build each example in 32-bit and 64-bit mode, but you will have to clean the project (./ant clean) between builds that target different runtime environments. That's because the runtime libraries get only copied once and will not be overwritten again when you build for a different runtime environment. This will subsequently cause link- or runtime failures unless you clean out the prior build first.
What about runtime?
This doesn't really belong here, but you'll probably want to run your application after successfully building it...
You will have to make sure that a proper JVM is configured or findable by the default search algorithm. If you have a 32-bit JRE as your default Java and you're trying to run a 64-bit application, you're out of luck because a 64-bit application can only load 64-bit libraries. To cut a long story short: configure the right JVM for the type of application you're building.