Download Reference Manual
The Developer's Library for D
About Wiki Forums Source Search Contact

some tango problems under linux

Moderators: kris

Posted: 03/26/08 11:57:13 Modified: 04/10/08 08:31:04

I can't link some math code under linux, missing c standart lib, I suppose. How is it called, where to look for it, what to link? (can't link "asin()", it's declared in tango.stdc.math as a part of header to C99 standart lib - where to get that lib?..)

Author Message

Posted: 03/26/08 12:08:00

gcc -o bin/Debug/dtest obj/Debug/FontStuff.o obj/Debug/hello.o obj/Debug/vtm/dependent/X11/X.o obj/Debug/vtm/dependent/X11/Xatom.o obj/Debug/vtm/dependent/X11/Xkeysymdef.o obj/Debug/vtm/dependent/X11/Xlib.o obj/Debug/vtm/dependent/X11/Xlibint.o obj/Debug/vtm/dependent/X11/Xmd.o obj/Debug/vtm/dependent/X11/Xproto.o obj/Debug/vtm/dependent/X11/Xutil.o obj/Debug/vtm/dependent/X11/keysymdef.o obj/Debug/vtm/dependent/X11/pthreads.o obj/Debug/vtm/dependent/X11/xf86vmode.o obj/Debug/vtm/dependent/derelict/freetype/ft.o obj/Debug/vtm/dependent/derelict/freetype/ftfuncs.o obj/Debug/vtm/dependent/derelict/freetype/fttypes.o obj/Debug/vtm/dependent/fontstuff/src/hybrid/BoxPacker.o obj/Debug/vtm/dependent/fontstuff/src/hybrid/FontRenderer.o obj/Debug/vtm/dependent/fontstuff/src/hybrid/GlGuiRenderer.o obj/Debug/vtm/dependent/fontstuff/src/hybrid/GuiRenderer.o obj/Debug/vtm/dependent/fontstuff/src/hybrid/IconCache.o obj/Debug/vtm/dependent/fontstuff/src/hybrid/Texture.o obj/Debug/vtm/dependent/fontstuff/src/hybrid/Utils.o obj/Debug/vtm/dependent/fontstuff/src/maths/Fixed.o obj/Debug/vtm/dependent/fontstuff/src/maths/Vec.o obj/Debug/vtm/dependent/fontstuff/src/utils/Memory.o obj/Debug/vtm/dependent/fontstuff/src/utils/Singleton.o obj/Debug/vtm/dependent/fontstuff/src/utils/StructClass.o -lX11 -lopengl32 -lglu32 -lderelictutil -lc -lpthread -lm -ltango-base-dmd -ltango-user-dmd /usr/local/lib/libtango-user-dmd.a(tango.math.Math.o): In function `_D5tango4math4Math4asinFcZc': tango/math/Math.d:(.text._D5tango4math4Math4asinFcZc+0x26): undefined reference to `_Cmul' /usr/local/lib/libtango-user-dmd.a(tango.math.Math.o): In function `_D5tango4math4Math4acosFcZc': tango/math/Math.d:(.text._D5tango4math4Math4acosFcZc+0x30): undefined reference to `_Cmul'

I tried to link libgcc.a and libc.a, but it did nothing...

Posted: 03/27/08 09:32:48 -- Modified: 03/27/08 09:33:45 by

I used a workaround, all works for now. The root of the problem is tango.math.Math.o in static lib - if it is used somewhere somehow, project linking fails with same errors. I use only tango.stdc.math and don't link anything besides standart "m" system static lib. Btw, I use tango Frank with dmd 1.028 under openSUSE 10.3 and Code::Blocks. Strange problems. Has anyone ever had the same?

Posted: 03/27/08 23:24:31

Weird. I don't even see a declaration for Cmul in tango.math.Math, but perhaps I'm reading the error wrong. Which function is missing?

Posted: 03/28/08 12:54:28

I don't know. Even when I try to use something other than sin/cos/asin/acos, like sqrt, I get these two linker errors. Where exactly is Cmul - in libm.a or else - is a big big secret. I suppose this is a unique personal bug. I just use only tango.stdc.math for now, that is enough. Soon I'll move to 0.99.5, if problem will stay, maybe it's not because of tango itself...

Posted: 03/28/08 18:41:30

sean wrote:

Weird. I don't even see a declaration for Cmul in tango.math.Math, but perhaps I'm reading the error wrong. Which function is missing?

lib/compiler/dmd/cmath2.d: void _Cmul()


lib/compiler/gdc/cmath2.d: void _Cmul()

It is the implementation for multiplication of complex numbers.

Over to the error, either you have a bad runtime, libgphobos or libtango-base-dmd, (most likely), or something happens during linking. But since most errors in that regard (wrong order or missing library) would lead to many more linking errors, the latter is unlikely. I wouldn't be surprised if it is fixed in later releases, as I found a reference to the same error in an old post from mid 2007, but not later. Maybe it was due to a buggy GDC and/or more brittle build process.

Posted: 04/10/08 04:35:36 -- Modified: 04/10/08 04:40:07 by
Digited -- Modified 3 Times

Yesterday I downloaded DMD 1.028 and tango trunk zip, installed fresh dmd, builded and installed tango. Same GCC 4.2.1, opeSUSE 10.3, Code::Blocks ide. Try to build a small test app, using StopWatch?, LinkedFolder?, ZipFolder?:

dmd -g -debug -I/usr/local/include/d -c hello.d -ofobj/Debug/hello.o gcc -o bin/Debug/dtest2 obj/Debug/hello.o -lz -lpthread -lm -ltango-base-dmd -ltango-user-dmd /usr/local/lib/libtango-user-dmd.a(tango.math.Math.o): In function `_D5tango4math4Math4asinFcZc': tango/math/Math.d:(.text._D5tango4math4Math4asinFcZc+0x26): undefined reference to `_Cmul' /usr/local/lib/libtango-user-dmd.a(tango.math.Math.o): In function `_D5tango4math4Math4acosFcZc': tango/math/Math.d:(.text._D5tango4math4Math4acosFcZc+0x30): undefined reference to `_Cmul' /usr/local/lib/libtango-user-dmd.a(tango.time.Time.o):(.data._D48TypeInfo_E5tango4time4Time8TimeSpan11anonymous6initZ+0x8): undefined reference to `_D10TypeInfo_l6initZ' /usr/local/lib/libtango-user-dmd.a(tango.time.Time.o):(.data._D44TypeInfo_E5tango4time4Time4Time11anonymous6initZ+0x8): undefined reference to `_D10TypeInfo_l6initZ'

Can anyone help?

ps what's wrong with tags?..

Posted: 04/10/08 05:04:08

I'm damn' shocked. Larsivi, here's the page with build & install instructions: It says about tango-base-dmd.a and tango-user-dmd.a But says nothing about THREE more static libs: tango-gc-basic.a, tango-cc-tango.a and - finally! - tango-rt-dmd.a that contains cmath2.o with _Cmul implementation! You saw my imports lacking those three libs but said nothing?

Anyway, everything works now.

Posted: 04/10/08 05:52:02

The three static libs you mention are only used during building of libtango-base-dmd - if a symbol which should be in there fails to link, it is not because any of those three libraries should be linked in. There is no reason whatsoever to be shocked, as this only shows that something is wrong with your setup.

The possibilities are (at least the most likely ones):

  • Bad runtime - i.e. libtango-base-dmd does not have what should be in there
  • dmd.conf does not contain the proper configuration or the correct one isn't picked up by the compiler
  • But most likely, order or libraries - on *nix, with the ld linker (used by gcc), the order of the libraries to link matter . Thus the dependencies must come at the end. The command line you have shown clearly has this wrong - could it be a Code::Blocks problem?

Posted: 04/10/08 06:38:50 -- Modified: 04/10/08 06:40:08 by

Thanks, changing libs linking order seems to work: pthread, m, tango-user-dmd, tango-base-dmd, everything links.

Now I have segmentation fault when try to create a Regex using opCall.

import tango.text.Regex;

int main( char[][] args ) { auto reg = Regex( "a" ); return 0; }

call stack:

#0 0x806931e _D5tango4text5Regex11T4TDFATwZ4TDFA14epsilonClosureMFC5tango4text5Regex11T4TDFATwZ4TDFA11SubsetStateC5tango4text5Regex11T4TDFATwZ4TDFA11SubsetStateZC5tango4text5Regex11T4TDFATwZ4TDFA11SubsetState() (??:??)
#1 0x8067e08 _D5tango4text5Regex11T4TDFATwZ4TDFA5_ctorMFC5tango4text5Regex11T4TNFATwZ4TNFAZC5tango4text5Regex11T4TDFATwZ4TDFA() (??:??)
#2 0x8065e6c _D5tango4text5Regex14
T7RegExpTTaZ7RegExpT5_ctorMFAabbbZC5tango4text5Regex14T7RegExpTTaZ7RegExpT() (??:??)
#3 0x8065dee _D5tango4text5Regex14
T7RegExpTTaZ7RegExpT5_ctorMFAaAaZC5tango4text5Regex14T7RegExpTTaZ7RegExpT() (??:??)
#4 0x8065ede _D5tango4text5Regex14
T7RegExpTTaZ7RegExpT6opCallFAaAaZC5tango4text5Regex14T7RegExpTTaZ7RegExpT() (??:??)

Posted: 04/10/08 12:03:43

Copied Regex.d to app folder and included in project, called module Regex, use with Regex.Regex( pattern ), works. How can it be?..

Posted: 04/10/08 17:09:53

Most likely you hit upon #956 which should be fixed for the next release.

As for tagging - I assume you mean for this forum? Here you can markup content as elsewhere in the Trac wiki. You can use the buttons on top of the edit window to get the most common ones.

Posted: 04/11/08 04:18:08

Yes, same "epsilonClosure" bug. Still Regex works fine when added to project... What is most strange - that's the type of crash: try {} catch doesn't work and garbage collection also doesn't, so everything allocated before crash just leaks.

Posted: 04/11/08 05:41:42

You could try the latest svn revision, or wait for the next release.

Posted: 04/14/08 07:10:13

2 Larsivi I use svn rev from 11 arpil, epsilonClosure crash exists. I can't wait, so I've just added the SAME tango.text.Regex to project and compile it with other modules to an executable, and tango' regular expressions work absolutely fine, no crashes.

BTW, I'm still reading docs and sources, but already use LinkedFolder?, zip, buffers, readers/writers/formatters, logs, conversions and have to say: tango is really great. It's like a part of the D language itself, powerful and clear, useful for fast development with D's ease of use. Thanks, tango team!

Posted: 04/14/08 07:10:45 -- Modified: 04/14/08 07:15:05 by
Digited -- Modified 2 Times

(double-posted. No way to delete a post?..)