www.digitalmars.com         C & C++   DMDScript  

digitalmars.D - Compile a shared library

reply Nafees <nafees.hassan outlook.com> writes:
I am trying to create a shared library, I just tried to compile 
the code that Mono-D generates for an empty shared library. I 
tried to compile it, but there were errors, and this is what the 
compile log said:
<code>
Building Solution: QScr (Debug)

Building: QScr (Debug)
Performing main compilation...
Current dictionary: /home/nafees/Desktop/Projects/QScr/QScr
dmd -debug -gc "myclass.d" "dllmain.d"  "-I/usr/include/dmd" 
"-L/IMPLIB:/home/nafees/Desktop/Projects/QScr/QScr/bin/Debug/libQScr.a"
"-odobj/Debug" "-of/home/nafees/Desktop/Projects/QScr/QScr/b
n/Debug/libQScr.so" -w -vcolumns
/usr/bin/ld: cannot find 
/IMPLIB:/home/nafees/Desktop/Projects/QScr/QScr/bin/Debug/libQScr.a: No such
file or directory
collect2: error: ld returned 1 exit status
--- errorlevel 1
Exit code 1
Build complete -- 1 error, 0 warnings

---------------------- Done ----------------------

Build: 1 error, 0 warnings
</code>

see, there is that .a file missing, I've no idea what it is. And 
I'm using DMD2 on Linux (Ubuntu 14.04). Any ideas how can I 
compile it?
Apr 09 2016
parent bitwise <bitwise.pvt gmail.com> writes:
On Sunday, 10 April 2016 at 05:34:24 UTC, Nafees wrote:
 I am trying to create a shared library, I just tried to compile 
 the code that Mono-D generates for an empty shared library. I 
 tried to compile it, but there were errors, and this is what 
 the compile log said:
 <code>
 Building Solution: QScr (Debug)

 Building: QScr (Debug)
 Performing main compilation...
 Current dictionary: /home/nafees/Desktop/Projects/QScr/QScr
 dmd -debug -gc "myclass.d" "dllmain.d"  "-I/usr/include/dmd" 
 "-L/IMPLIB:/home/nafees/Desktop/Projects/QScr/QScr/bin/Debug/libQScr.a"
"-odobj/Debug" "-of/home/nafees/Desktop/Projects/QScr/QScr/b
n/Debug/libQScr.so" -w -vcolumns
 /usr/bin/ld: cannot find 
 /IMPLIB:/home/nafees/Desktop/Projects/QScr/QScr/bin/Debug/libQScr.a: No such
file or directory
 collect2: error: ld returned 1 exit status
 --- errorlevel 1
 Exit code 1
 Build complete -- 1 error, 0 warnings

 ---------------------- Done ----------------------

 Build: 1 error, 0 warnings
 </code>

 see, there is that .a file missing, I've no idea what it is. 
 And I'm using DMD2 on Linux (Ubuntu 14.04). Any ideas how can I 
 compile it?
IMPLIB is a linker flag for windows. Its possible that Mono-D is not correctly identifying the OS for some code paths. I would file a bug on github/mono-d. As far as dmd goes though, shared library support is spotty at the moment. AFAIK, shared libraries should work on linux, but I haven't tried it myself. It may be a good idea to try and build one manually to confirm. Bit
Apr 11 2016