Thread overview
dub libs from home directory on windows
Mar 18, 2020
Abby
Mar 18, 2020
jmh530
Mar 19, 2020
evilrat
March 18, 2020
Hi there,
I'm using d2sqlite3 which has dependency on sqlite3.lib. When I'm building my app on windows I have a dub.sdl which has a line

libs "%USERPROFILE%/AppData/Local/dub/packages/d2sqlite3-0.18.3/d2sqlite3/lib/win64/sqlite3" platform="windows-x86_64-dmd"

but unless I specify full path using specific user profile name on windows like so

"c:/user/abby/AppData/Local/dub/packages/d2sqlite3-0.18.3/d2sqlite3/lib/win64/sqlite3"

I cannot build my app, so I was wondering if there is some clever way to solve this without hardcoded path to my profile name.

Thank you very much for your help.
March 18, 2020
On Wednesday, 18 March 2020 at 13:52:20 UTC, Abby wrote:
> Hi there,
> I'm using d2sqlite3 which has dependency on sqlite3.lib. When I'm building my app on windows I have a dub.sdl which has a line
>
> libs "%USERPROFILE%/AppData/Local/dub/packages/d2sqlite3-0.18.3/d2sqlite3/lib/win64/sqlite3" platform="windows-x86_64-dmd"
>
> but unless I specify full path using specific user profile name on windows like so
>
> "c:/user/abby/AppData/Local/dub/packages/d2sqlite3-0.18.3/d2sqlite3/lib/win64/sqlite3"
>
> I cannot build my app, so I was wondering if there is some clever way to solve this without hardcoded path to my profile name.
>
> Thank you very much for your help.

I see it in CairoD.
dub.json
--------
{
        ...

        "configurations": [
        {
            "name": "unittest",
            "targetType": "executable",
            "mainSourceFile": "unittest.d",
            "versions": ["CairoPNG"],
            "targetPath": "bin",
            "libs-posix": ["cairo"],
            "libs-windows-x86-dmd": ["lib/32/mars/cairo"],
            "libs-windows-x86-gdc": ["lib/32/msvc_mingw/cairo"],
            "libs-windows-x86-ldc": ["lib/32/msvc_mingw/cairo"],
            "libs-windows-x86_64": ["lib/64/cairo"],
            "copyFiles-windows-x86": ["lib/32/*.dll"],
            "copyFiles-windows-x86_64": ["lib/64/*.dll"]
        }
        ]
}


folders:
./
  lib/
     32/
       mars/
         cairo.lib
       msvc_mingw/
         cairo.lib
     64/
       cairo.lib


March 18, 2020
On Wednesday, 18 March 2020 at 13:52:20 UTC, Abby wrote:
> Hi there,
> I'm using d2sqlite3 which has dependency on sqlite3.lib. When I'm building my app on windows I have a dub.sdl which has a line
>
> libs "%USERPROFILE%/AppData/Local/dub/packages/d2sqlite3-0.18.3/d2sqlite3/lib/win64/sqlite3" platform="windows-x86_64-dmd"
>
> but unless I specify full path using specific user profile name on windows like so
>
> "c:/user/abby/AppData/Local/dub/packages/d2sqlite3-0.18.3/d2sqlite3/lib/win64/sqlite3"
>
> I cannot build my app, so I was wondering if there is some clever way to solve this without hardcoded path to my profile name.
>
> Thank you very much for your help.

Of course, you will use "sqlite3.lib" instead "cairo.lib".

March 18, 2020
On Wednesday, 18 March 2020 at 13:52:20 UTC, Abby wrote:
>
> I cannot build my app, so I was wondering if there is some clever way to solve this without hardcoded path to my profile name.
>
> Thank you very much for your help.

I see, you want without hardcoded path...

March 18, 2020
On Wednesday, 18 March 2020 at 15:10:52 UTC, Виталий Фадеев wrote:
> On Wednesday, 18 March 2020 at 13:52:20 UTC, Abby wrote:
>>
>> I cannot build my app, so I was wondering if there is some clever way to solve this without hardcoded path to my profile name.
>>
>> Thank you very much for your help.
>
> I see, you want without hardcoded path...

I usually something like ./folder/file.extension to avoid a hardcoded path.

I also recommend taking a look at some other dub files to get a sense of how others do it.
March 19, 2020
On Wednesday, 18 March 2020 at 19:53:58 UTC, jmh530 wrote:
> On Wednesday, 18 March 2020 at 15:10:52 UTC, Виталий Фадеев wrote:
>> On Wednesday, 18 March 2020 at 13:52:20 UTC, Abby wrote:
>>>
>>> I cannot build my app, so I was wondering if there is some clever way to solve this without hardcoded path to my profile name.
>>>
>>> Thank you very much for your help.
>>
>> I see, you want without hardcoded path...
>
> I usually something like ./folder/file.extension to avoid a hardcoded path.
>
> I also recommend taking a look at some other dub files to get a sense of how others do it.

Even better option is to just use "libs" section as usual(no paths, just names) and set environment variable specific to your machine prior to build.
For MS linker it is 'LIB' with semicolon as delimiter, for Linux it is 'LIBRARY_PATH'.

This way it is much more 'portable' and CI friendly, though it definitely will add confusion and 'annoyance' for first time users.

example batch:

  set LIB=C:\someproject\libs;E:\superduper\lib64
  dub build