www.digitalmars.com         C & C++   DMDScript  

digitalmars.D - How to link *.a file on Windows?

reply Brian <zoujiaqing gmail.com> writes:
I use cygwin build a C++ lib file:

libmemcached.a

but, how to link it to my dub project?
Sep 22 2016
next sibling parent Basile B. <b2.temp gmx.com> writes:
On Thursday, 22 September 2016 at 17:09:38 UTC, Brian wrote:
 I use cygwin build a C++ lib file:

 libmemcached.a

 but, how to link it to my dub project?
should be a .lib under windows. *.a is an archive of object files (aka a static library) for Posix systems. *.lib is the same but for Windows.
Sep 22 2016
prev sibling next sibling parent kinke <noone nowhere.com> writes:
On Thursday, 22 September 2016 at 17:09:38 UTC, Brian wrote:
 I use cygwin build a C++ lib file:

 libmemcached.a

 but, how to link it to my dub project?
You'd probably need to use the GNU linker then, but the D objects would need to match the format used for your C++ lib. You could give the GDC compiler a shot, or use clang to compile the C++ lib to MS COFF format (.lib), which can then be fed to both DMD and LDC on Windows.
Sep 22 2016
prev sibling next sibling parent Mike Parker <aldacron gmail.com> writes:
On Thursday, 22 September 2016 at 17:09:38 UTC, Brian wrote:
 I use cygwin build a C++ lib file:

 libmemcached.a

 but, how to link it to my dub project?
I don't know of any D compiler that supports Cygwin. There are older releases of LDC built on top of MinGW and GDC has had some releases for Windows, but I don't believe you'd be able to use anything generated by the Cygwin toolchain with those.
Sep 22 2016
prev sibling parent reply Brian <zoujiaqing gmail.com> writes:
On Thursday, 22 September 2016 at 17:09:38 UTC, Brian wrote:
 I use cygwin build a C++ lib file:

 libmemcached.a

 but, how to link it to my dub project?
My plan: 1.I use cygwin build libmemcached.dll 2.use def tools export libmemcached.def 3.use VS2015 dev tools convert libmemcached.dll to libmemcached.lib 4.use coffimplib convert libmemcached.lib for D compiler but, this plan must dep dll file. how to static link libmemcached.lib?
Sep 22 2016
next sibling parent Basile B. <b2.temp gmx.com> writes:
On Friday, 23 September 2016 at 06:27:20 UTC, Brian wrote:
 how to static link libmemcached.lib?
Just pass the filename to the compiler as if it's a ".d" source and put the path to the sources root with -I dmd app.d libmemcached.lib -Ipath/to/memcached/interface/
Sep 23 2016
prev sibling parent Mike Parker <aldacron gmail.com> writes:
On Friday, 23 September 2016 at 06:27:20 UTC, Brian wrote:
 On Thursday, 22 September 2016 at 17:09:38 UTC, Brian wrote:
 I use cygwin build a C++ lib file:

 libmemcached.a

 but, how to link it to my dub project?
My plan: 1.I use cygwin build libmemcached.dll 2.use def tools export libmemcached.def 3.use VS2015 dev tools convert libmemcached.dll to libmemcached.lib 4.use coffimplib convert libmemcached.lib for D compiler but, this plan must dep dll file. how to static link libmemcached.lib?
With dub, you can use the the 'libs' directive in your configuration file. See the Build Settings section a [1] if you are using JSON and [2] for SDL. If you manage to get your Cygwin-compiled libs to work with DMD successfully with this approach, please let us know. I was unable to get anything more than simple C libraries compiled by MinGW to work with DMD. [1] https://code.dlang.org/package-format?lang=json#build-settings [2] https://code.dlang.org/package-format?lang=sdl#build-settings
Sep 23 2016