-1

I´m trying to produce a little example code for the library libfixmath and I get the error "undefined reference to `fix16_mul' "

The code is:

#include <stdio.h>
#include "libfixmath/fixmath.h"

int main(){

    fix16_t res = fix16_mul(fix16_from_int(1), fix16_from_int(2));

    return 0;
}

The library is at the specified path and I compile just with the command

gcc -o testfix testfix.c
Sebastian E
  • 467
  • 1
  • 3
  • 15
  • You need to provide more info so that you can receive help. – machine_1 Jul 31 '18 at 12:06
  • what do you need to know? I´m sorry if the question is stupid, but I can´t find any real documentation or tutorial for the lib. – Sebastian E Jul 31 '18 at 12:10
  • What is a special option in terms of gcc? Maybe what you consider special, others would consider a requirement for building your project - add the full command(s) you're using to compile your code – Chris Turner Jul 31 '18 at 12:23

1 Answers1

1

The documentation says
To use the fixmath library, include the header <fixmath/fixmath.h>, and link the application with -lfixmath, or use pkg-config to determine the compiler and linker flags.

So change

gcc -o testfix testfix.c

to

gcc -o testfix testfix.c -lfixmath

and it should work.

Osiris
  • 2,783
  • 9
  • 17