UsingMathLib
UsingMathLib
h>
When you want to compile a program the includes <math.h> you will need to add another option
to your command line, -lm. This is not hard when your are using the command line but it requires
several steps to configure your VSCode to use the -lm.
After you have installed the two packages below and opened a folder in which you are working,
you will need to configure VSCode by creating and editing two files.
These files will be located in the folder you opened. If you always open your CMPT125 folder which
contains all your specific folders for assignments and labs then you will not have to make a new
copy of the two files in each folder. To create and edit these two files complete the following steps.
1. Select tha file containing the code you are developing in VSCode.
2. To create the first file, tasks.json,
a. Select “Configure Tasks” from the “Terminal” menu.
a. press the run and debug button then select to first C/C++ option in the popup window
below
b. The following tasks.json file should be created. You need to make one change.
Add one line containing the following characters (including the quotes), "-lm", after
line13. Make sure you save the edited tasks.json file.
3. Now we need to make the second file, the launch.json file. To do this
a. press the run and debug button on the left of your VSCode
screen (circled in the image below) to bring up the window below.
b. Select “create and launch a json file to get the following window
c. Press the add configuration button to give the following popup box
d. Select C/C++: (gdb) Launch. This will give you a launch.gson file containing the
following text. You must make the changes shown in bold red type.
5.
6. After you have started you code an additional window will pop up, this is the terminal for
your program. Your screen will look something like the image below when your code is
running.