mintyfresh / vibrant.d

A light framework on top of vibe.d
MIT License
11 stars 0 forks source link

Error compiling vibrant.d project #2

Closed cloutiy closed 7 years ago

cloutiy commented 7 years ago

Hi Mihail-K, 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 dubbing:

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.

p.s. Have you written any tutorials of any kind for D? Your code is very clean, even compared to some D books I'm currently reading. You make D seem effortless. Where in Ontario are you located? I'm in Ottawa.

cloutiy commented 7 years ago

After posting on the vibe.d forum, someone immediately pointed that I needed to add versions "VibeDefaultMain" to my SDL in order for the shared static (this) to work.

Things compile and link now :)