I'd like to use math.h
in C++ Builder 10.1.2.
Unfortunately, there is a linker error when I try to call one of math.h
's functions.
What I do already know is, that (for historical reasons) the linker must be explicitly set to link to use the math lib.
See here.
In gcc this can be done via the -lm
flag.
But what do I have to enter for C++ Builder in the Project options => C++ Linker =>Advanced options field to make this work?
EDIT:
So here is an example: Create a new VCL project and change the Form1 code like that:
//---------------------------------------------------------------------------
#include <vcl.h>
#pragma hdrstop
#include "Unit1.h"
#include <math.h>
//-------------------------------------------------------------------------- -
#pragma package(smart_init)
#pragma resource "*.dfm"
TForm1 *Form1;
//---------------------------------------------------------------------------
__fastcall TForm1::TForm1(TComponent* Owner)
: TForm(Owner)
{
float a = floorf(0.0f);
}
//---------------------------------------------------------------------------
That will give you the linker error
[ilink32 Error] Error: Unresolved external '_floorf' referenced by C:\USERS\FLKO\DOCUMENTS\EMBARCADERO\STUDIO\PROJECTS\WIN32\DEBUG\UNIT1.OBJ
So I need to tell the linker to link with the math
lib.
But how?