Prerequisites
Before compiling Giac, you need to install the required development packages:The prebuilt source tree includes static versions of GMP and MPFR for various platforms. If you use the default CMake configuration, you don’t need to install these libraries separately.
Building with Gradle
The simplest way to build and run Giac on Linux is using the included Gradle wrapper.Run the Gradle build
- Compile all necessary source files
- Link the executable
- Launch the interactive Giac terminal
Building with CMake
For more control over the build process, you can use CMake directly.Configure the project
src/jni/prebuilt/linux/x86-64/.Compile the project
minigiac: Command-line executablejavagiac: Shared library for JNI integration
Using System Libraries
If you prefer to use dynamically linked system libraries instead of the prebuilt static versions:CMakeLists.txt
Build Configuration
The CMake build uses the following compiler flags:Compiler Flags
Preprocessor Definitions
Key definitions used during compilation:| Definition | Purpose |
|---|---|
HAVE_NO_HOME_DIRECTORY | Disable home directory detection |
GIAC_GGB | Enable GeoGebra integration features |
IN_GIAC | Mark compilation as internal to Giac |
HAVE_LIB_PTHREAD | Enable pthread support |
GIAC_GENERIC_CONSTANTS | Use generic constant definitions |
TIMEOUT | Enable timeout functionality |
HAVE_LIBMPFR | MPFR library is available |
HAVE_UNISTD_H | POSIX unistd.h is available |
HAVE_SYS_TIMES_H | sys/times.h is available |
SIZEOF_VOID_P=8 | Pointer size (64-bit) |
Troubleshooting
Android SDK Dependency
If you encounter errors related to the Android SDK during Gradle builds:Remove Android from settings.gradle
Open Alternatively, delete the file completely:
settings.gradle and remove the line:Git Symlink Issue
If you cloned the source using git, you may need to create a symlink:Library Not Found Errors
If CMake cannot find the prebuilt libraries:- Verify the prebuilt directory exists and contains
libgmp.aandlibmpfr.a - Try using system libraries instead (see “Using System Libraries” above)
- Install libraries manually:
sudo apt-get install libgmp-dev libmpfr-dev
Debugging in an IDE
CLion Setup
Giac supports debugging with CLion (or other CMake-compatible IDEs):Configure build settings
CLion will automatically detect the CMake configuration. Ensure the build directory is set to
build/.Set breakpoints
Open
src/minigiac/cpp/minigiac.cc or any other source file and set breakpoints by clicking in the left margin.Building Specific Targets
Command-line Executable Only
JNI Shared Library Only
build/libs/javagiac/shared/linux64/libjavagiac.so.
Static Linking
The build system automatically links GMP and MPFR statically with the following flags:Linker Flags
Testing the Build
Run the regression test suite:src/test/ and verify the build is working correctly.
Performance Optimization
The default build uses-O2 optimization. For maximum performance:
Higher optimization levels may increase compilation time significantly.
