Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 0 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -35,4 +35,3 @@ who want the safety guarantees of a modern language without actually having to
rewrite their entire codebase in Rust. It compiles down to a standard static or
dynamic C library (`.a`, `.so`, `.dylib`, or `.dll`) and links identically t
o any standard C dependency.

52 changes: 45 additions & 7 deletions src/getting-started/installation.md
Original file line number Diff line number Diff line change
Expand Up @@ -10,29 +10,51 @@ Here is how to get your environment set up in under two minutes.

Before installing, ensure your system has the required build tools:

1. **Rust & Cargo**: To compile the safe backend.
1. **Rust & Cargo**: To compile the safe back end. Run the official installer in
your terminal:

```bash
curl --proto '=https' --tlsv1.2 -sSf https://sh.rustup.rs | sh
```

*👉 **Note for beginners:** The script will pause. Press `1` and hit `Enter`
to proceed with the default installation.*

> [!IMPORTANT] > Once the installation finishes, you must tell your current
terminal where Rust is installed. Run this command:

```bash
source $HOME/.cargo/env
```

*(Alternatively, you can just close your terminal and open a new one).*
2. **GCC or Clang**: For the C front-end and macro expansion.
3. **Make**: For build automation.

---

## Step 1: Clone the Repository

Grab the latest version of the NextStd source code from GitHub:

```bash
git clone https://github.com/NextStd/NextStd.git
cd NextStd
git clone https://github.com/NextStd/nextstd.git
cd nextstd
```

## Step 2: System-Wide Installation (Recommended)

To make NextStd available to all your C projects, run the install command. This
builds the highly optimized Rust release binaries and copies them, along with
the C headers, into your system's standard `/usr/local` directories.
To make NextStd available to all your C projects, you need to build the
optimized Rust binaries and install them globally.

First, build the core libraries (this runs safely as your normal user):

```bash
make rust
```

Then, install the headers and static archives into your system's standard
`/usr/local` directories (this requires root privileges to copy the files):

```bash
sudo make install
Expand All @@ -48,6 +70,8 @@ sudo make install
*(To completely remove the library from your system later, simply run `sudo make
uninstall` from the repository root).*

---

## Step 3: Linking in Your Projects

Now that NextStd is installed globally, you can include it in any standalone C
Expand All @@ -73,10 +97,13 @@ gcc main.c -lns_data -lns_io -lns_string -lns_error -lpthread -ldl -lm -o my_saf
* **`-lpthread`, `-ldl`, `-lm`**: Standard system libraries required by the Rust
backend on standard Linux/macOS environments.

---

## Alternative: Local Testing

If you want to test the library, develop new modules, or run the built-in
examples without installing it system-wide, you can build the backend locally:
examples without installing it system-wide, you can build the backend locally
without `sudo`:

```bash
make rust
Expand All @@ -85,6 +112,17 @@ make rust
Then, run one of the pre-configured examples (do not include the `.c`
extension):

To list all the examples use:

```bash
make list
```

And then you can use the example names as given below.

> [!NOTE]
> Note the absence of the `.c` extension

```bash
make 01_print_integer
```
Expand Down