<p>See <a href="https://github.com/bitcoin-core/secp256k1/blob/c6b6b8f1bb044d7d1aa065ebb674adde98a36a8e/src/basic-config.h#L26-L30" rel="nofollow noreferrer">here</a> for an example of a <code>#define</code> configuration. You may then search for those macros in the repo to see their alternatives and define the relevant ones before you <code>#include &quot;src/secp256k1.c&quot;</code></p>
<blockquote>
<p>I can't seem to find any documentation or walkthrough guide on simple usage of the library</p>
</blockquote>
<p>This library is not meant for use as a single header, as explained in the <code>README.md</code>:</p>
<blockquote>
<p>Expose only higher level interfaces to minimize the API surface and improve application security. (&quot;Be difficult to use insecurely.&quot;)</p>
</blockquote>
<p>The conventional way of using this library is compiling it and calling the linker when you compile your code with <code>libsecp256k1.a</code> for static linking (You may do <code>gcc your-code.c libsecp256k1.a</code>)</p>
<p>However, I used the library once with an <code>#include</code> only a long time ago, without any problems. That works, and as I described at the top, you just need a few <code>#define</code>s.</p>
<p><code>secp256k1.h</code> is self-explanatory. You might want to read it all similarly to reading a story. Then you should be able to find the relevant functions.</p>

CC BY-SA 4.0
2022-04-03T11:44:34.847Z
Is there another secp256k1 library that can be compiled into my code?
Vincent Alex
CC BY-SA 4.0
2022-04-03T13:16:36.467Z
What doesn't work for you with the standard one?
MCCCS
CC BY-SA 4.0
2022-04-04T09:25:34.573Z
I don't like linking in black boxes (libsecp256k1.a), for embedded system I need full transparency, control over asserts, debugging if needed.
Vincent Alex
CC BY-SA 4.0
2022-04-04T10:05:57.527Z
What I'd do is #include "secp256k1.c" however this is too hacky so maybe you should ask libsecp256k1 developers.
MCCCS
CC BY-SA 4.0
2020-12-15T15:15:21.353Z
2020-12-15T17:27:24.600Z
2020-12-15T17:27:24.600Z
MCCCS
<p>I am trying to use secp256k1 for a toy project that I am working on for learning purposes. I am using Ubuntu 20.04 and I can clone and compile the library just fine. I have tried to include it in a simple hello world c file and I get the following error: <code>secp256k1/src/num.h:19:2: error: #error &quot;Please select num implementation&quot; 19 | #error &quot;Please select num implementation&quot;</code></p>
<p>I have tried googling this but I can't seem to find anything (only <a href="https://github.com/breadwallet/breadwallet-ios/issues/60" rel="nofollow noreferrer">https://github.com/breadwallet/breadwallet-ios/issues/60</a> but not sure how it applies to my situation). All I did was use this line <code>#include &quot;src/secp256k1.c&quot;</code> in my toy C code. I can't seem to find any documentation or walkthrough guide on simple usage of the library such as generating private keys and addresses (besides <code>secp256k1.h</code>). Any help would be appreciated!</p>

CC BY-SA 4.0
2020-12-15T22:46:13.810Z
There is a work-in-progress libsecp256k1 pull request that adds usage examples: https://github.com/bitcoin-core/secp256k1/pull/748.
nickler
<bitcoin-core-development><secp256k1>
Using secp256k1 in personal project
Makis Christou
# Using secp256k1 in personal project

(Asked by: username_0 on 2020-12-15)

I am trying to use secp256k1 for a toy project that I am working on for learning purposes. I am using Ubuntu 20.04 and I can clone and compile the library just fine. I have tried to include it in a simple hello world c file and I get the following error: `secp256k1/src/num.h:19:2: error: #error "Please select num implementation" 19 | #error "Please select num implementation"`

I have tried googling this but I can't seem to find anything (only <https://github.com/breadwallet/breadwallet-ios/issues/60> but not sure how it applies to my situation). All I did was use this line `#include "src/secp256k1.c"` in my toy C code. I can't seem to find any documentation or walkthrough guide on simple usage of the library such as generating private keys and addresses (besides `secp256k1.h`). Any help would be appreciated!

**Tags:** bitcoin-core-development, secp256k1

> **Comments:**
> **username_1**: There is a work-in-progress libsecp256k1 pull request that adds usage examples: https://github.com/bitcoin-core/secp256k1/pull/748.  

---

## 1 answers

### Answer by username_2 on 2020-12-15. Score: 2 | Accepted answer

See [here](https://github.com/bitcoin-core/secp256k1/blob/c6b6b8f1bb044d7d1aa065ebb674adde98a36a8e/src/basic-config.h#L26-L30) for an example of a `#define` configuration. You may then search for those macros in the repo to see their alternatives and define the relevant ones before you `#include "src/secp256k1.c"`

> I can't seem to find any documentation or walkthrough guide on simple usage of the library

This library is not meant for use as a single header, as explained in the `README.md`:

> Expose only higher level interfaces to minimize the API surface and improve application security. ("Be difficult to use insecurely.")

The conventional way of using this library is compiling it and calling the linker when you compile your code with `libsecp256k1.a` for static linking (You may do `gcc your-code.c libsecp256k1.a`)

However, I used the library once with an `#include` only a long time ago, without any problems. That works, and as I described at the top, you just need a few `#define`s.

`secp256k1.h` is self-explanatory. You might want to read it all similarly to reading a story. Then you should be able to find the relevant functions.

> **Comments:**
> **username_3**: Is there another secp256k1 library that can be compiled into my code?  
> **username_2**: What doesn't work for you with the standard one?  
> **username_3**: I don't like linking in black boxes (libsecp256k1.a), for embedded system I need full transparency, control over asserts, debugging if needed.  
> **username_2**: What I'd do is #include "secp256k1.c" however this is too hacky so maybe you should ask libsecp256k1 developers.  

---

