Skip to content

math.h support gone from nighlty build #2338

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
jtouch opened this issue Sep 29, 2014 · 7 comments
Closed

math.h support gone from nighlty build #2338

jtouch opened this issue Sep 29, 2014 · 7 comments
Labels
Board: Arduino Due Applies only to the Due Component: IDE The Arduino IDE Type: Bug
Milestone

Comments

@jtouch
Copy link

jtouch commented Sep 29, 2014

Hi, all,

Support for math.h functions appears to have disappeared. Previous builds supported sin(), cos(), etc., and known constants.

I haven't checked nightly builds every night, but it worked in the nightly a few weeks ago (and works fine in 1.5.6-r2 and 1.5.7, but doesn't in the current nightly.

Joe

@cmaglie
Copy link
Member

cmaglie commented Sep 29, 2014

@jtouch
just checked with the current ide-1.5.x branch and it seems to work.
May you post a test sketch? Which board you selected?

@jtouch
Copy link
Author

jtouch commented Sep 29, 2014

The board is a Due. I can't post the full code (it's proprietary), but I can post a test I wrote that also fails:

// it doesn't matter whether the following line is included or not:
// #include <math.h> 

void setup() {
  // initialize serial:
  Serial.begin(9600);
}

float a = 1.2;
float b = 0.96;

void loop() {
  float x, y;
  x = pow(10.0, a);
  y = (2.0 * acos(sqrt(b)) / M_PI);

  Serial.print(x + y);
  Serial.println();
}

Here are the errors:

mathtest.cpp.o: In function loop': C:\Users\touch\Desktop\arduino-nightly/mathtest.ino:14: warning: undefined reference topow'
C:\Users\touch\Desktop\arduino-nightly/mathtest.ino:15: warning: undefined reference to sqrt' C:\Users\touch\Desktop\arduino-nightly/mathtest.ino:15: warning: undefined reference toacos'

@cmaglie
Copy link
Member

cmaglie commented Sep 30, 2014

I see it now, it's probably a regression after this commit: 37ee800

May you try to change the recipe.c.combine.pattern definition line in your sam/platform.txt file with the following:

recipe.c.combine.pattern="{compiler.path}{compiler.c.elf.cmd}" {compiler.c.elf.flags} -mcpu={build.mcu} "-T{build.variant.path}/{build.ldscript}" "-Wl,-Map,{build.path}/{build.project_name}.map" {compiler.c.elf.extra_flags} -o "{build.path}/{build.project_name}.elf" "-L{build.path}" -mthumb -Wl,--cref -Wl,--check-sections -Wl,--gc-sections -Wl,--entry=Reset_Handler -Wl,--unresolved-symbols=report-all -Wl,--warn-common -Wl,--warn-section-align -Wl,--warn-unresolved-symbols -Wl,--start-group "{build.path}/syscalls_sam3.c.o" {object_files} "{build.variant.path}/{build.variant_system_lib}" "{build.path}/{archive_file}" -Wl,--end-group -lm -gcc

I moved the -lm -lgcc flags at the end of the command.

@cmaglie cmaglie added Board: Arduino Due Applies only to the Due Component: IDE The Arduino IDE Type: Bug labels Sep 30, 2014
@cmaglie cmaglie added this to the Release 1.5.8 milestone Sep 30, 2014
@matthijskooijman
Copy link
Collaborator

@cmaglie, huh? In the commit you referenced, you didn't touch the -lm option at all? However, you did switch from g++ to gcc, do you think that command is more picky about the ordering of link options? It seems the avr version does have -lm at the end (and has had so for as long as I can quickly see).

@cmaglie
Copy link
Member

cmaglie commented Sep 30, 2014

From my experience the command line order does matter.

I didn't checked directly but 37ee800 seems the only recent commit touching the platform.txt file and, yeah, I don't know why it was working with g++ and not with gcc.

@cmaglie
Copy link
Member

cmaglie commented Sep 30, 2014

Fix pushed for 1.5.8 and next nightly.

21939e6

@jtouch if this doesn't work for you please reopen the issue.

@cmaglie cmaglie closed this as completed Sep 30, 2014
@jtouch
Copy link
Author

jtouch commented Oct 1, 2014

It works. Thanks!

ollie1400 pushed a commit to ollie1400/Arduino that referenced this issue May 2, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Board: Arduino Due Applies only to the Due Component: IDE The Arduino IDE Type: Bug
Projects
None yet
Development

No branches or pull requests

3 participants