multiple definition of `__bb_random_random'

BlitzMax Forums/BlitzMax Programming/multiple definition of `__bb_random_random'

Czar Flavius(Posted 2009) [#1]
I'd like to use two random number generators side by side! (I'm crazy like that) But I get this problem:

C:/Program Files/BlitzMax/mod/brl.mod/random.mod/random.debug.win32.x86.a(random.bmx.debug.win32.x86.o): multiple definition of `__bb_random_random'
Build Error: Failed to link H:\Astromania\Astromania.debug.exe

(I have no idea what that means either)

Here is the code I'm trying to run. It works if I remove one of the two random kinds. Considering they are both seperate modules, I can't think why it should be a problem. I'd be content with two seperate simultanious bah randoms if that would be possible!

Function sync_rand:Int(start, finish)
	Return bah.random.Rand(start, finish);
End Function

Function seed_sync(seed)
	bah.random.SeedRnd(seed);
End Function

Function misc_rand:Int(start, finish)
	Return brl.random.Rand(start, finish);
End Function

Function seed_misc(seed)
	brl.random.SeedRnd(seed);
End Function



GW(Posted 2009) [#2]
You need to alter the names of the functions in Bruceys mod.
Or do what i did and just replace the brl.ramdom with Bruceys superior one.


Czar Flavius(Posted 2009) [#3]
I'm not actually crazy - I actually need two generators. I notice that Brucey's MAPM mod comes with a generator in it too. Perhaps I will use that.


Brucey(Posted 2009) [#4]
Considering they are both seperate modules, I can't think why it should be a problem

It's a "feature" of the BlitzMax namespace - in that there is a flaw which means that two modules with the same name (for example, "Random"), but in a different namespace ( "brl" and "bah" ) actually contain references of the same name - __bb_random_random. (rather than something like __bb_brl_random, I suppose)

The workaround is to ensure you only Import one of them. BRL.Basic and BRL.Retro both link to BRL.Random, iirc, so you may want to avoid those if you intend to use BaH.Random (or a module using BaH.Random).

BaH.Random is meant to be a drop-in replacement for BRL.Random, with a much improved cross-platform seed (i.e. you will get the same results from a specific seed on all systems - this is not the case for BRL.Random).

HTH

:-)


ziggy(Posted 2009) [#5]
t's a "feature" of the BlitzMax namespace - in that there is a flaw which means that two modules with the same name (for example, "Random"), but in a different namespace ( "brl" and "bah" ) actually contain references of the same name - __bb_random_random. (rather than something like __bb_brl_random, I suppose)

The workaround is to ensure you only Import one of them. BRL.Basic and BRL.Retro both link to BRL.Random, iirc, so you may want to avoid those if you intend to use BaH.Random (or a module using BaH.Random).

Doesn't this defeat the complete purpose of namespacing on BlitzMax? I supose it's not a trivial change... but... maybe we could make Mark a suggestion to look at this whenever he has the time, or I am missing something?


Tommo(Posted 2009) [#6]
This "feature" also affects non-module codes.
For example, assume you have following files:

main.bmx
Superstrict
framework brl.blitz
import "max2d/max2d.bmx"


max2d/max2d.bmx
superstrict
import brl.max2d


If you compile main.bmx, you'll get a compile error like:
YourPath/max2d/.bmx/max2d.bmx.debug.win32.x86.s [8]:
error: symbol already defined.
Build Error: Failed to assemble 

Compiler tries to use symbol "__bb_max2d_max2d" for max2d/max2d.bmx, which is the same as the symbol brl.max2d is using, then the error is raised.

It's not a problem for general usage. But this is a flaw.


Brucey(Posted 2009) [#7]
maybe we could make Mark a suggestion to look at this whenever he has the time, or I am missing something?

Done. Several years ago. :-p
As you may surmise, there was/is no change forth-coming.

It is a known feature :-)


ziggy(Posted 2009) [#8]
It is a known feature :-)

Another one... :D Anyway, it's been there so long and it seems it has not been a sedrious problem for anyone, so...
additionally, it seems it's not happening with types, so not really an issue for me.