Thread overview
core.sys.windows.winldap
Mar 09, 2017
WebFreak001
Mar 09, 2017
rikki cattermole
Mar 09, 2017
WebFreak001
Mar 09, 2017
rikki cattermole
March 09, 2017
I tried using core.sys.windows.winldap (winldap.h) but I get linker errors when I try to run my code. I tried copying Wldap32.lib from my Windows Kits folder but then optlink always says Error 43 Not a Valid Library File.

I simply use `dub test` to compile, adding `"libs": ["Wldap32"]` only adds `Warning 2: File Not Found Wldap32.lib`

OPTLINK (R) for Win32  Release 8.00.17
Copyright (C) Digital Mars 1989-2013  All rights reserved.
http://www.digitalmars.com/ctg/optlink.html
.dub\build\ldap-test-library-unittest-windows-x86-dmd_2073-5D0B47894B8410C065D6A470FD54839E\ldap-test-library.obj(ldap-test-library)
 Error 42: Symbol Undefined _ldap_initW
.dub\build\ldap-test-library-unittest-windows-x86-dmd_2073-5D0B47894B8410C065D6A470FD54839E\ldap-test-library.obj(ldap-test-library)
 Error 42: Symbol Undefined _LdapGetLastError
.dub\build\ldap-test-library-unittest-windows-x86-dmd_2073-5D0B47894B8410C065D6A470FD54839E\ldap-test-library.obj(ldap-test-library)
 Error 42: Symbol Undefined _ldap_unbind_s
.dub\build\ldap-test-library-unittest-windows-x86-dmd_2073-5D0B47894B8410C065D6A470FD54839E\ldap-test-library.obj(ldap-test-library)
 Error 42: Symbol Undefined _ldap_set_optionW
.dub\build\ldap-test-library-unittest-windows-x86-dmd_2073-5D0B47894B8410C065D6A470FD54839E\ldap-test-library.obj(ldap-test-library)
 Error 42: Symbol Undefined _ldap_get_optionW
.dub\build\ldap-test-library-unittest-windows-x86-dmd_2073-5D0B47894B8410C065D6A470FD54839E\ldap-test-library.obj(ldap-test-library)
 Error 42: Symbol Undefined _ldap_msgfree
.dub\build\ldap-test-library-unittest-windows-x86-dmd_2073-5D0B47894B8410C065D6A470FD54839E\ldap-test-library.obj(ldap-test-library)
 Error 42: Symbol Undefined _ldap_search_ext_sW
.dub\build\ldap-test-library-unittest-windows-x86-dmd_2073-5D0B47894B8410C065D6A470FD54839E\ldap-test-library.obj(ldap-test-library)
 Error 42: Symbol Undefined _ldap_first_entry
.dub\build\ldap-test-library-unittest-windows-x86-dmd_2073-5D0B47894B8410C065D6A470FD54839E\ldap-test-library.obj(ldap-test-library)
 Error 42: Symbol Undefined _ldap_next_entry
.dub\build\ldap-test-library-unittest-windows-x86-dmd_2073-5D0B47894B8410C065D6A470FD54839E\ldap-test-library.obj(ldap-test-library)
 Error 42: Symbol Undefined _ldap_value_free_len
.dub\build\ldap-test-library-unittest-windows-x86-dmd_2073-5D0B47894B8410C065D6A470FD54839E\ldap-test-library.obj(ldap-test-library)
 Error 42: Symbol Undefined _ldap_memfreeW
.dub\build\ldap-test-library-unittest-windows-x86-dmd_2073-5D0B47894B8410C065D6A470FD54839E\ldap-test-library.obj(ldap-test-library)
 Error 42: Symbol Undefined _ldap_get_dnW
.dub\build\ldap-test-library-unittest-windows-x86-dmd_2073-5D0B47894B8410C065D6A470FD54839E\ldap-test-library.obj(ldap-test-library)
 Error 42: Symbol Undefined _ldap_next_attributeW
.dub\build\ldap-test-library-unittest-windows-x86-dmd_2073-5D0B47894B8410C065D6A470FD54839E\ldap-test-library.obj(ldap-test-library)
 Error 42: Symbol Undefined _ldap_get_values_lenW
.dub\build\ldap-test-library-unittest-windows-x86-dmd_2073-5D0B47894B8410C065D6A470FD54839E\ldap-test-library.obj(ldap-test-library)
 Error 42: Symbol Undefined _ldap_first_attributeW
.dub\build\ldap-test-library-unittest-windows-x86-dmd_2073-5D0B47894B8410C065D6A470FD54839E\ldap-test-library.obj(ldap-test-library)
 Error 42: Symbol Undefined _ber_free
.dub\build\ldap-test-library-unittest-windows-x86-dmd_2073-5D0B47894B8410C065D6A470FD54839E\ldap-test-library.obj(ldap-test-library)
 Error 42: Symbol Undefined _ber_bvfree
Error: linker exited with status 17

(I'm not actually logged in here right now, using guest to post this)
March 09, 2017
On 09/03/2017 11:19 PM, WebFreak001 wrote:
> I tried using core.sys.windows.winldap (winldap.h) but I get linker
> errors when I try to run my code. I tried copying Wldap32.lib from my
> Windows Kits folder but then optlink always says Error 43 Not a Valid
> Library File.
>
> I simply use `dub test` to compile, adding `"libs": ["Wldap32"]` only
> adds `Warning 2: File Not Found Wldap32.lib`
>
> OPTLINK (R) for Win32  Release 8.00.17
> Copyright (C) Digital Mars 1989-2013  All rights reserved.
> http://www.digitalmars.com/ctg/optlink.html
> .dub\build\ldap-test-library-unittest-windows-x86-dmd_2073-5D0B47894B8410C065D6A470FD54839E\ldap-test-library.obj(ldap-test-library)
>
>  Error 42: Symbol Undefined _ldap_initW
> .dub\build\ldap-test-library-unittest-windows-x86-dmd_2073-5D0B47894B8410C065D6A470FD54839E\ldap-test-library.obj(ldap-test-library)
>
>  Error 42: Symbol Undefined _LdapGetLastError
> .dub\build\ldap-test-library-unittest-windows-x86-dmd_2073-5D0B47894B8410C065D6A470FD54839E\ldap-test-library.obj(ldap-test-library)
>
>  Error 42: Symbol Undefined _ldap_unbind_s
> .dub\build\ldap-test-library-unittest-windows-x86-dmd_2073-5D0B47894B8410C065D6A470FD54839E\ldap-test-library.obj(ldap-test-library)
>
>  Error 42: Symbol Undefined _ldap_set_optionW
> .dub\build\ldap-test-library-unittest-windows-x86-dmd_2073-5D0B47894B8410C065D6A470FD54839E\ldap-test-library.obj(ldap-test-library)
>
>  Error 42: Symbol Undefined _ldap_get_optionW
> .dub\build\ldap-test-library-unittest-windows-x86-dmd_2073-5D0B47894B8410C065D6A470FD54839E\ldap-test-library.obj(ldap-test-library)
>
>  Error 42: Symbol Undefined _ldap_msgfree
> .dub\build\ldap-test-library-unittest-windows-x86-dmd_2073-5D0B47894B8410C065D6A470FD54839E\ldap-test-library.obj(ldap-test-library)
>
>  Error 42: Symbol Undefined _ldap_search_ext_sW
> .dub\build\ldap-test-library-unittest-windows-x86-dmd_2073-5D0B47894B8410C065D6A470FD54839E\ldap-test-library.obj(ldap-test-library)
>
>  Error 42: Symbol Undefined _ldap_first_entry
> .dub\build\ldap-test-library-unittest-windows-x86-dmd_2073-5D0B47894B8410C065D6A470FD54839E\ldap-test-library.obj(ldap-test-library)
>
>  Error 42: Symbol Undefined _ldap_next_entry
> .dub\build\ldap-test-library-unittest-windows-x86-dmd_2073-5D0B47894B8410C065D6A470FD54839E\ldap-test-library.obj(ldap-test-library)
>
>  Error 42: Symbol Undefined _ldap_value_free_len
> .dub\build\ldap-test-library-unittest-windows-x86-dmd_2073-5D0B47894B8410C065D6A470FD54839E\ldap-test-library.obj(ldap-test-library)
>
>  Error 42: Symbol Undefined _ldap_memfreeW
> .dub\build\ldap-test-library-unittest-windows-x86-dmd_2073-5D0B47894B8410C065D6A470FD54839E\ldap-test-library.obj(ldap-test-library)
>
>  Error 42: Symbol Undefined _ldap_get_dnW
> .dub\build\ldap-test-library-unittest-windows-x86-dmd_2073-5D0B47894B8410C065D6A470FD54839E\ldap-test-library.obj(ldap-test-library)
>
>  Error 42: Symbol Undefined _ldap_next_attributeW
> .dub\build\ldap-test-library-unittest-windows-x86-dmd_2073-5D0B47894B8410C065D6A470FD54839E\ldap-test-library.obj(ldap-test-library)
>
>  Error 42: Symbol Undefined _ldap_get_values_lenW
> .dub\build\ldap-test-library-unittest-windows-x86-dmd_2073-5D0B47894B8410C065D6A470FD54839E\ldap-test-library.obj(ldap-test-library)
>
>  Error 42: Symbol Undefined _ldap_first_attributeW
> .dub\build\ldap-test-library-unittest-windows-x86-dmd_2073-5D0B47894B8410C065D6A470FD54839E\ldap-test-library.obj(ldap-test-library)
>
>  Error 42: Symbol Undefined _ber_free
> .dub\build\ldap-test-library-unittest-windows-x86-dmd_2073-5D0B47894B8410C065D6A470FD54839E\ldap-test-library.obj(ldap-test-library)
>
>  Error 42: Symbol Undefined _ber_bvfree
> Error: linker exited with status 17
>
> (I'm not actually logged in here right now, using guest to post this)

Import libs like static libraries adhere to the same specs of PE-COFF versus OMF.

So if you want things to work without much hassle, hello -m64!
March 09, 2017
On Thursday, 9 March 2017 at 10:44:00 UTC, rikki cattermole wrote:
> On 09/03/2017 11:19 PM, WebFreak001 wrote:
>> ...
>
> Import libs like static libraries adhere to the same specs of PE-COFF versus OMF.
>
> So if you want things to work without much hassle, hello -m64!

Thanks, adding `--arch=x86_mscoff` to the dub call and then also adding `"libs": ["wldap32"]` fixed it. Is there a way to force dub to use that architecture? I could add it as dflags argument but then it outputs a warning that I should use --arch instead. I don't want users of my library to have that linker error
March 10, 2017
On 09/03/2017 11:52 PM, WebFreak001 wrote:
> On Thursday, 9 March 2017 at 10:44:00 UTC, rikki cattermole wrote:
>> On 09/03/2017 11:19 PM, WebFreak001 wrote:
>>> ...
>>
>> Import libs like static libraries adhere to the same specs of PE-COFF
>> versus OMF.
>>
>> So if you want things to work without much hassle, hello -m64!
>
> Thanks, adding `--arch=x86_mscoff` to the dub call and then also adding
> `"libs": ["wldap32"]` fixed it. Is there a way to force dub to use that
> architecture? I could add it as dflags argument but then it outputs a
> warning that I should use --arch instead. I don't want users of my
> library to have that linker error

Looks like you either have to make a .defs file manually or create/find a OMF based import lib.

I did find this[0] no idea if it'll work with Optlink without changes.

FYI .defs file is nice since Optlink will recognize it but MSVC link won't. Example[1] note that dxva2 has a .def file in same directory but it will work for all Windows builds since MSVC provides its own import lib.

[0] https://sourceforge.net/u/earnie/winapi/winapi/ci/f9fa22a4ecce88ad12a8371a40f00ef702ec3e1b/tree/lib/wldap32.def
[1] https://github.com/Devisualization/spew/blob/master/dub.json#L34