digitalmars.D.learn - Dynamic library loading gives error about importing a module
- Tolga Cakiroglu (11/11) Feb 19 2014 I have written a programme and a library under Linux. When
- =?UTF-8?B?QWxpIMOHZWhyZWxp?= (7/16) Feb 19 2014 Simply "import"ing should work; doing that should not bring definitions
- Tolga Cakiroglu (13/22) Feb 19 2014 Hi Ali, Both of them have normal import for that module. I
- cal (5/16) Feb 19 2014 Could be this?
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?
Feb 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
Feb 19 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? AliHi 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 -releaseBoth 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.
Feb 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
Feb 19 2014