Open nicolasjinchereau opened 9 years ago
Think I found a solution.
In the file Building/CompilerPresets/dmd.xml I replaced all of "-L/IMPLIB:$lib" with -shared
This should have fixed the problem, but Mono-D global settings were not updated. Once I updated global settings D/CompilerToolchains/Debug Arguments with the above changes, everything worked.
Hmm, I really got to make the build parameterization OS-individual. I just hate the additional complexity one needs to handle e.g. in the option GUI.
Ok, I see now. It's an optlink flag which also causes dmd to magically infer the -shared flag. I understand what you mean though. I've been over the docks for XS addins, and don't remember seeing much support for platform specific behavior.
I guess you're also aware then that the shared lib starter project on windows gives a bunch of linker errors because DLLMain is not defined? ;)
I probably have to remove some of those template projects :D
You could add this(untested) code to the example dll. People can just deleted it if they don't want it. I don't have a solution for the command lines though =/
version(Windows)
{
import core.sys.windows.dll;
import core.sys.windows.windows : HINSTANCE;
extern(Windows)
bool DllMain(HINSTANCE hInstance, uint ulReason, void* reserved)
{
import core.sys.windows.windows;
switch(ulReason)
{
default: assert(0);
case DLL_PROCESS_ATTACH:
return dll_process_attach( hInstance, true );
case DLL_PROCESS_DETACH:
dll_process_detach( hInstance, true );
return true;
case DLL_THREAD_ATTACH:
return dll_thread_attach( true, true );
case DLL_THREAD_DETACH:
return dll_thread_detach( true, true );
}
}
}
good idea!
Reproduce: 1) install Mono-D 2.12.3 for Xamarin Studio on OSX Yosemite 2) create a new shared library project 3) build it
Output is:
///////////////////////////////// Building Solution: SharedTest (Debug)
Building: SharedTest (Debug) Performing main compilation... Current dictionary: /Users/Bitwise/Desktop/SharedTest dmd -debug -gc "myclass.d" "-I/usr/share/dmd/src" "-L/IMPLIB:/Users/Bitwise/Desktop/SharedTest/bin/Debug/libSharedTest.a" "-odobj/Debug" "-of/Users/Bitwise/Desktop/SharedTest/bin/Debug/libSharedTest.so" -w -vcolumns ld: file not found: /IMPLIB:/Users/Bitwise/Desktop/SharedTest/bin/Debug/libSharedTest.a clang: error: linker command failed with exit code 1 (use -v to see invocation) --- errorlevel 1 Exit code 1 Build complete -- 1 error, 0 warnings ---------------------- Done ---------------------- Build: 1 error, 0 warnings //////////////////////////////////
Where is the flag -shared? What is IMPLIB:?