You are a lifesaver! version "VibeDefaultMain" is exactly what was missing. Things seem to be working as expected now.

Thank you!

On Fri, 17 Mar 2017 21:06:38 +0100, Sönke Ludwig wrote:

Am 17.03.2017 um 20:39 schrieb cloutiy:

Hi all, I originally posted in the dlang forum, but someone suggested I may want to try over here.

I'd like to try making a simple web app using vibrant.d, however I don't think I'm using it correctly since I'm getting a linking error when compiling.

Below is my SDL with added vibrant.d dependency:

name "cvmaker"
description "A simple vibe.d server application."
authors "drifter"
copyright "Copyright © 2017, drifter"
license "proprietary"
dependency "vibrant-d" version="~>0.1.6"

I modified the default app.d created by dub init --type=vibe.d to:

import vibrant.d;

shared static this()
{
    with(Vibrant)
    {
        Get("/hello", (req, res) => "Hello World!");
    }
}

However I get a linking error when running the command dub in my project folder:

Linking...
/usr/lib/gcc/x86_64-pc-linux-gnu/6.3.1/../../../../lib/crt1.o: In function `_start':
(.text+0x20): undefined reference to `main'
collect2: error: ld returned 1 exit status
Error: linker exited with status 1
dmd failed with exit code 1.

I haven't been using d for very long yet and realize I may not be using external packages properly. I suspect it's a simple error on my part.

The shared static this shortcut requires version "VibeDefaultMain"
in dub.sdl since a while, so that the default main() function of
vibe.d actually gets included.

Alternatively, you can define an own main function (untested):

import vibrant.d;
import vibe.core.core : runApplication;

void main()
{
     with(Vibrant)
     {
         Get("/hello", (req, res) => "Hello World!");
     }

     runApplication();
}