I'm starting learning C, but I seem to have failed in installing my first library. I'm using a Mac.
I found a simple tutorial to get started: writing a program to generate cryptographic keys.
It uses the secp256k1 library.
I installed the library and copied the first couple of lines from the tutorial.
#include <secp256k1.h>
static secp256k1_context *ctx = NULL;
ctx = secp256k1_context_create(
SECP256K1_CONTEXT_SIGN | SECP256K1_CONTEXT_VERIFY);;
But when I make
my C program, I get this error:
cc keyGen.c -o keyGen
Undefined symbols for architecture x86_64:
"_secp256k1_context_create", referenced from:
_main in keyGen-50d772.o
ld: symbol(s) not found for architecture x86_64
clang: error: linker command failed with exit code 1 (use -v to see invocation)
make: *** [keyGen] Error 1
Here's a breakdown of how I installed secp256k1.
$ ./autogen.sh
$ ./configure
$ make
$ make check
$ sudo make install
I get no errors with this. Only when I make
the program.
I've found a threads with the same error, but I still can't seem to get it working. Perhaps it's different for Mac (they use Linux), but more likely it's because I haven't understood what it means. They speak very generally, I'm not sure I'm inputting the specific commands correctly.
The question I linked suggested to run ./configure --enable-module-recovery
. I have also trying to install it using this, but it didn't work either.
The question then goes on to talk about defining paths and modifying CFLAGS
and LDFLAGS
, however, this for another program cgo
. I can't work out what I need to modify, as this my own program it won't work in.
If anyone could give me some suggestions what I need to do that would be great.