Thread overview
Dynamic library loading gives error about importing a module
Feb 19, 2014
Tolga Cakiroglu
Feb 19, 2014
Ali Çehreli
Feb 20, 2014
Tolga Cakiroglu
Feb 19, 2014
cal
February 19, 2014
I have written a programme and a library under Linux. When programme is run, it tries to load the library. Both the programme code and the library imports a module as "apps.common.lib.config". Now, when I run the programme, following error is seen:

Fatal Error while loading 'dll/lib.so':
	The module 'apps.common.lib.config' is already defined in './bin/app'.
make: *** [debug] Error 139


Why am I not allowed to import same module in to different code files? Shouldn't they be separate?
February 19, 2014
On 02/19/2014 01:45 AM, Tolga Cakiroglu wrote:

> I have written a programme and a library under Linux. When programme is
> run, it tries to load the library. Both the programme code and the
> library imports a module as "apps.common.lib.config". Now, when I run
> the programme, following error is seen:
>
> Fatal Error while loading 'dll/lib.so':
>      The module 'apps.common.lib.config' is already defined in './bin/app'.
> make: *** [debug] Error 139
>
>
> Why am I not allowed to import same module in to different code files?
> Shouldn't they be separate?

Simply "import"ing should work; doing that should not bring definitions to the code. However, one side should also include the module during its build.

Have you included the module on both the program's and library's builds?

Ali

February 19, 2014
On Wednesday, 19 February 2014 at 09:45:41 UTC, Tolga Cakiroglu wrote:
> I have written a programme and a library under Linux. When programme is run, it tries to load the library. Both the programme code and the library imports a module as "apps.common.lib.config". Now, when I run the programme, following error is seen:
>
> Fatal Error while loading 'dll/lib.so':
> 	The module 'apps.common.lib.config' is already defined in './bin/app'.
> make: *** [debug] Error 139
>
>
> Why am I not allowed to import same module in to different code files? Shouldn't they be separate?

Could be this?
https://d.puremagic.com/issues/show_bug.cgi?id=11543
Workaround - compile with -release
February 20, 2014
>
> Simply "import"ing should work; doing that should not bring definitions to the code. However, one side should also include the module during its build.
>
> Have you included the module on both the program's and library's builds?
>
> Ali

Hi Ali, Both of them have normal import for that module. I actually used the import as "private import" in the DLL file in case it would be helpful, though no chance.

Also both of them have the link to that imported library. If I didn't, compiler would give error message and wouldn't compile already. So, I am sure about this.


> Could be this?
> https://d.puremagic.com/issues/show_bug.cgi?id=11543
> Workaround - compile with -release

Both library and the programme are compiled with
-w -wi -inline -O -release -noboundscheck

Martin is just suggesting to use it I think. It is no change at all.


BTW, just for information, Posix "dlOpen" function is used in this operation. But this is a system call already, and shouldn't be causing fatal/this error.