0

I'm using binfmtc to allow me to run a C program without performing an explicit build step. This worked fine until I started using math functions, at which point I see messages such as:

undefined reference to `sin'

The header that I use is:

/*BINFMTC: -Wall -Werror -std=c99 -lm
*/

How can I get this program to link?

Closely related: "undefined reference to `pow'" even with math.h and the library link -lm

Community
  • 1
  • 1
Brent Bradburn
  • 51,587
  • 17
  • 154
  • 173

1 Answers1

1

This isn't elegant, but it works:

Create a wrapper script gcclm.sh for the library:

#! /usr/bin/env bash
gcc $@ -lm

Invoke the C program using the wrapper:

GCC=$(pwd)/gcclm.sh ./myprogram.c
Brent Bradburn
  • 51,587
  • 17
  • 154
  • 173