# Starting from scratch

## New project

The Vertices SDK is built to be included in any project as an external component.

The best way to achieve this is probably to make use of [git submodules](https://git-scm.com/book/en/v2/Git-Tools-Submodules).

So let's say we have a clean repository with empty directories:

* `external`: I like to have a directory keeping external libs
* `components`: provided by the SDK you are building on
* `myproject`: the source code your team is writing
* `utils`: some scripts and tools that are useful
* `build`: generated build files

```bash
mkdir porting_guide
cd porting_guide
mkdir external components myproject utils build
```

The structure is alive. Let's get the SDK.

```bash
# init directory as a git repository
git init
# clone SDK into external/c-vertices-sdk
git submodule add https://github.com/vertices-network/c-vertices-sdk external/c-vertices-sdk
# update submodules of the SDK itself
git submodule update --init --recursive
# check content of the SDK
ls external/c-vertices-sdk
```

Let's create a `main.c` file with the minimum content:

```bash
touch myproject/main.c
```

```c
#include <stdio.h>

int main(int argc, char *argv[])
{
    printf("Hello world\n");

    return 0;
}

```

## CMake

We can now init our project with two CMake files that will be used to build the entire project:

```bash
touch CMakeLists.txt myproject/CMakeLists.txt
```

Here is the minimum content of the root `CMakeLists.txt`:

```
cmake_minimum_required (3.20)
project (porting_guide)

# adding the Vertices SDK
add_subdirectory(external/c-vertices-sdk)

# adding the User code
add_subdirectory(myproject)
```

Now we can add our `main.c` file into `myproject/CMakeLists.txt`:

```
set(PROJECT_NAME myproject)
project(${PROJECT_NAME})

# add source file related to that project
set(SRC_FILES
        main.c
        )

# Add directories to include below (headers folders)
set(INC_FOLDERS
        )

include_directories(${INC_FOLDERS})
add_executable(${PROJECT_NAME} ${SRC_FILES})
```

### The missing link

Before we can start including headers from the Vertices SDK, we need to add the library into `myproject` :

At the end of `myproject/CMakeLists.txt`, append that line:

```
target_link_libraries(${PROJECT_NAME} vertices)
```

Now you can include the Vertices header in the main file:

```c
#include "vertices.h" // ready to use the Vertices SDK library
```

There are still some missing parts that will be covered in the next chapters.

{% hint style="info" %}
Follow the next step to get our implementation of those first two steps 🥳&#x20;
{% endhint %}


---

# Agent Instructions: Querying This Documentation

If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter:

```
GET https://docs.vertices.network/vertices-sdk/porting-guide/starting-from-scratch.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
