Nafees
Nafees

Reputation: 529

Shared Library won't compile, *.a file missing

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.

Upvotes: 1

Views: 349

Answers (2)

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.

Upvotes: 1

Vladimir Panteleev
Vladimir Panteleev

Reputation: 25187

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

Upvotes: 1

Related Questions