After an evaluation, GNOME has moved from Bugzilla to GitLab. Learn more about GitLab.
No new issues can be reported in GNOME Bugzilla anymore.
To report an issue in a GNOME project, go to GNOME GitLab.
Do not go to GNOME Gitlab for: Bluefish, Doxygen, GnuCash, GStreamer, java-gnome, LDTP, NetworkManager, Tomboy.
Bug 599770 - Math.sqrt is not proper referenced
Math.sqrt is not proper referenced
Status: RESOLVED OBSOLETE
Product: vala
Classification: Core
Component: Bindings: GLib
0.7.x
Other Linux
: Low minor
: ---
Assigned To: Vala maintainers
Vala maintainers
Depends on:
Blocks:
 
 
Reported: 2009-10-27 14:30 UTC by Lennart Weller
Modified: 2018-05-22 13:24 UTC
See Also:
GNOME target: ---
GNOME version: ---



Description Lennart Weller 2009-10-27 14:30:49 UTC
When trying to use GLib.Math.sqrt with a variable it results in an incorrect referenced C-code.
e.g. this simple code:
static void main() {
	double i = 5;
	stdout.printf("%f\n", Math.sqrt(i));
}
will result in an gcc error, where as:
static void main() {
	stdout.printf("%f\n", Math.sqrt(5));
}
would work out just fine.

The complete error code:
/tmp/ccCpbHwm.o: In function `_main':
sqrt.vala.c:(.text+0x52): undefined reference to `sqrt'
collect2: ld returned 1 exit status
error: cc exited with status 256

valac --version: 0.7.7
OS: Debian testing/unstable
Comment 1 Lennart Weller 2009-10-27 14:47:14 UTC
It seems like the libm is not included when compiling.
Using: valac -C sqrt.vala && gcc `pkg-config --libs --cflags gobject-2.0` -lm sqrt.c
works just fine.
Comment 2 Jürg Billeter 2009-10-27 16:48:35 UTC
Confirming. We will need an attribute to support specifying extra libraries to link with. You can use -X -lm for now.
Comment 3 Michael 'Mickey' Lauer 2017-11-05 21:34:23 UTC
Moreover, such a facility needs to be platform-dependent, since e.g. on macOS the provided testcase compiles just fine without libm.
Comment 4 Daniel Boles 2018-03-17 18:44:55 UTC
I think that's something the build system could handle; Meson already supports optional dependencies and will/won't link as needed/found. This is needed pretty often when using C or C++, and yes, mostly for libm.
Comment 5 GNOME Infrastructure Team 2018-05-22 13:24:56 UTC
-- GitLab Migration Automatic Message --

This bug has been migrated to GNOME's GitLab instance and has been closed from further activity.

You can subscribe and participate further through the new bug through this link to our GitLab instance: https://gitlab.gnome.org/GNOME/vala/issues/53.