1

I'm trying to make a shared library, in Linux, which is a *.so. My DMD version is 2, latest. I'm just trying yo compile a simple empty shared library, with the code that Mono-D(plugin for MonoDevelop) creates. When I try to compile it, it tells me to check the build log, this is what's in the build log:

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/bin/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

This is what dllmain contains:

module dllmain;

And in myclass.d:

module myclass;

class MyClass
{
    //TODO: Enter class code here
}

export:
extern(D):

MyClass createMyClass()
{
    return new MyClass();
}

I have no idea what is that a file, I'm still fairly new to D, and Linux. How do I get it to compile? And could someone explain to me what is an .a file?

EDIT: No, it's not a duplicate, I'm trying to compile, while that question is about loading libraries.

EDIT2: I checked the directory, the .a file doesn't exist.

Nafees
  • 509
  • 4
  • 16
  • Possible duplicate of [Linux error while loading shared libraries: cannot open shared object file: No such file or directory](http://stackoverflow.com/questions/480764/linux-error-while-loading-shared-libraries-cannot-open-shared-object-file-no-s) – t0mm13b Apr 09 '16 at 12:37
  • @t0mm13b No, not a duplicate. – Vladimir Panteleev Apr 09 '16 at 12:43
  • 1
    A .a file is typically a static library. These are usually created with the `ar` utility. For example, see `man ar`. – rkersh Apr 12 '16 at 04:11

2 Answers2

1

/usr/bin/ld: cannot find /IMPLIB:/home/nafees/Desktop/Projects/QScr/QScr/bin/Debug/libQScr.a: No such file or directory

/IMPLIB is a Windows linker switch. Your IDE is misconfigured (or just buggy).

Try changing the project settings in the IDE or filing a bug against the IDE.

Vladimir Panteleev
  • 24,651
  • 6
  • 70
  • 114
1

Few things.

  1. extern(D) would not be needed for free functions since it is default
  2. You don't need createMyClass function at all, new will work fine
  3. -shared must be passed to dmd for it to create a shared library

In case you didn't know, you will be passing the files in the shared library as import files when compiling the host binary.