Skip to content

A cross-platform C/C++ library containing various prime number utilities.

License

Notifications You must be signed in to change notification settings

franzageek/libprimes

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

29 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

libprimes

A cross-platform C/C++ library containing various prime number utilities.

Introduction - How to build - Compile against libprimes - Additional info

Introduction

libprimes is a library written in C whose aim is to provide a bunch of useful functions to allow C/C++ programmers to deal with prime numbers with more ease.

Its first version, as of July 23rd 2024, includes:

  • a primality-check function;
  • a prime factorization algorithm.

I'm planning to keep on adding more & more features to it, in the hope for it to be adopted from more & more people.

How to build

First, check that make, cmake and ctest(optional) are installed on your system.

Then, download the source code, extract it somewhere comfortable, then open a command prompt in that folder and proceed as follows:

  • If you're on Linux or macOS, first run:
$ sudo chmod +x ./configure.sh

to make the script executable, then run it like so:

$ sudo ./configure.sh
  • Or, if you run Windows, run the following command from an elevated command prompt:
> configure.bat

Warning

I haven't been able to test configure.bat yet, but it should work, cause it is pretty much the same code as configure.sh.

You can customize various properties of the build, such as the build folder path, the build configuration & whether or not to run tests before installing.

To edit these properties, simply open the configure.{sh|bat} file in a text editor and search for the property you want to edit. These properties are defined at the top of the file.

You'll just have to edit the BUILD_DIR, the BUILD_CONFIG and the RUN_TESTS variables according to your preferences. These variables will be passed to CMake when building the project.

Compile against libprimes

To compile a program that uses functions from the libprimes library, you first have to install it, then make sure your program includes the primes.h header, then you're gonna need to add the -lprimes option to your compile command.

E.G. if you're compiling with gcc, you're gonna need to run a similar command:

gcc main.c -o main.out -lprimes

Additional info

To know more about libprimes itself, please check the wiki.

To discover how to take part in the project by contributing, check CONTRIBUTING.