From 4f4fb2772afa9d77bc4063373ac3e83d20be06a4 Mon Sep 17 00:00:00 2001 From: "chris.sutcliffe" Date: Mon, 13 Dec 2021 17:05:17 +0000 Subject: fix maths linker error --- src/Compiler/ExecuteC.java | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) diff --git a/src/Compiler/ExecuteC.java b/src/Compiler/ExecuteC.java index 128f541..ede9bd6 100644 --- a/src/Compiler/ExecuteC.java +++ b/src/Compiler/ExecuteC.java @@ -70,14 +70,15 @@ public class ExecuteC { public Boolean compileC(){ try{ Process p; + // -lm to links maths library that is not included by default if (System.getProperty("os.name").equals("Linux")) { p = Runtime.getRuntime().exec(String.format( - "gcc %s/%s.c -o %s/%s", + "gcc %s/%s.c -o %s/%s -lm", buildToDir.toString(), filename, buildToDir.toString(), filename )); } else { p = Runtime.getRuntime().exec(String.format( - "cmd /C gcc %s -o %s", + "cmd /C gcc %s -o %s -lm", Paths.get(buildToDir.toString(), String.format("%s.c", filename)).toString(), Paths.get(buildToDir.toString(), String.format("%s.exe", filename)).toString() )); @@ -121,5 +122,9 @@ public class ExecuteC { } System.out.println(); return null; - } + } + + public static void main(String[] args) { + System.out.println("ExecuteC class testing"); + } } -- cgit v1.2.3