digitalmars.D - using vibe listenHTTP in a library on OSX causes:
- Timothee Cour (49/49) Nov 30 2017 I get: core.sync.exception.SyncError@(0): Unable to lock mutex.
- Jacob Carlborg (4/15) Dec 01 2017 Your example doesn't link since it doesn't link with vibe.d.
I get: core.sync.exception.SyncError (0): Unable to lock mutex. when calling listenHTTP via a library. It works when compiling everything in a single application without using intermediate library. details: using: dmd:2.077 dub build dmd -ofmain -L-Ldir -L-ltest1 -Isource import/main.d ./main Listening for requests on http://[::1]:8080/ Listening for requests on http://127.0.0.1:8080/ Please open http://127.0.0.1:8080/ in your browser. core.sync.exception.SyncError (0): Unable to lock mutex. source/app.d: ``` void fun(){ import vibe.vibe; auto settings = new HTTPServerSettings; settings.port = 8080; settings.bindAddresses = ["::1", "127.0.0.1"]; static void hello(HTTPServerRequest req, HTTPServerResponse res){ res.writeBody("Hello, World!"); } listenHTTP(settings, &hello); logInfo("Please open http://127.0.0.1:8080/ in your browser."); runApplication(); } ``` dub.json: ``` { "name": "test1", "targetType": "staticLibrary", // same with dynamicLibrary "targetName": "test1", "dependencies": { "vibe-d": "==0.7.31", // same with 0.8.1 }, "description": "...", "copyright": "...", "authors": ["..."], "license": "proprietary" } ``` main.d: ``` import app; void main(){ fun; } ```
Nov 30 2017
On 2017-12-01 01:46, Timothee Cour wrote:I get: core.sync.exception.SyncError (0): Unable to lock mutex. when calling listenHTTP via a library. It works when compiling everything in a single application without using intermediate library. details: using: dmd:2.077 dub build dmd -ofmain -L-Ldir -L-ltest1 -Isource import/main.dYour example doesn't link since it doesn't link with vibe.d. -- /Jacob Carlborg
Dec 01 2017