User forums > Using Code::Blocks

Math.h "linker error" doesn't deal with variables or loops.

(1/2) > >>

e.dacougnia:
Good evening everyone,

-1 I have a problem with some of math.h functions like sin, cos or sqrt who are acting like if they could only handle "const double". Impossible to pass them thru a loop, it gives me a linker error.
   It doesn't want to build. Aren't they supposed to deal with variables in "C"?
   I work with Ubuntu 20.04 LTS

-2 Also, it is very very hard to get log on the forum and to go from one page to another. Each step cost me 50 try at least and dozens of minutes.
Thanks in advance!? :)

stahta01:
If you are talking about the Wiki pages it is a known issue; I have no problem with the forums.

You should post the error because we have no psychic on this website to help you.

Tim S.

Miguel Gimenez:
The installed version of Simple Mchines Forum does not work with IPv6 connections, see this thread

The linker error may be because you need to link explicitly the math library.

e.dacougnia:
Thank you for answering!

I haven't got to the wiki yet, just the forum.
I have shut IPv6, but might have to reconnect to see the difference, will tell you anyway. Thanks! :)

When you say "explicitly linked the math library" do you mean #include <math.h> or something else? Because that's done.
I didn't try every function in math.h, but I assume that some are working since the "round" function seems OK.
I'm able to find another way, but that won't be very efficient. If you have another hint for me, I'll take it?

Thanks to the both of you!
Have a nice day :)

Miguel Gimenez:
Read this link. Some compilers (specially those for embedded systems) require explicit linking with the libm.a library if you use functions like cos().

Linking with libm.a requires going to Project -> Build options -> Linker settings -> Link libraries and add libm.a there. If this does not work, post the full build log in code tags.

Navigation

[0] Message Index

[#] Next page

Go to full version