On 8/27/21 9:21 AM, Ki Rill wrote:
I have a Raylib project on Windows using DUB. I've added raylib-d via `dub add`. But what I can't figure out is how to tell DUB to link against raylib library.

I have the following project structure:
```
-> source
---> app.d
-> libraylib.a
-> raylib.dll
-> etc...
```

I'd like to use either .a or .dll. Do you have any ideas?

I spent a lot of time trying to figure this out (someone in discord really wanted to link statically for some reason). I FINALLY got a statically linked exe, but it's not worth the effort. I had to:

1. update my msvc build tools to match what was used for the official release (alternatively, you can rebuild the raylib library with your tools, otherwise you get cryptic errors like `fatal error C1900: Il mismatch between 'P1' version '20210113' and 'P2' version '20190715'`).
2. pass in cryptic linker options like `/NODEFAULTLIB:libcmt`, etc.
3. Link against extra libraries until the linker errors disappear (google search for missing symbols to see what libraries those symbols are in).

My eventual resulting dub.json looked like (you can guess where I put things):

```json
{
    "name": "rps-explosion",
    "dependencies": {
        "jsoniopipe": "~>0.1.3",
        "enet-d": "~>0.0.1",
        "raylib-d": "~>3.1.0"
    },
"libs": ["enet", "raylib", "ws2_32", "winmm", "msvcrt", "user32", "gdi32"],
    "lflags": ["/LIBPATH:C:\\dprojects\\enet-1.3.17",
"/LIBPATH:C:\\dprojects\\raylib-3.7.0_win64_msvc16\\lib", "/NODEFAULTLIB:libcmt", "/NODEFAULTLIB:libvcruntime"]
}
```

This config also included `enet-d` so some of the linker options are for that lib.

In the end, I got it to build and run, but I'd highly recommend just linking against the `raylibdll.lib` and using the dll.

-Steve

Reply via email to