So, I'm done, thank you. I'll describe my example for those who will read this topic in future.

I'm trying other available build systems for D one after annother. Currently, I build my project with Cook, and I'll use it in my example, but it doesn't matter. The only important thing is that I need to manually specify compiler parameters and linker parameters.

So. This is what I need to pass to the compiler:

-I/path/to/vibe.d/source -I/path/to/openssl-master
-I/path/to/libevent-master -version=VibeCustomMain -version=VibeLibeventDriver

(Since I have all the packages installed with Dub, I can specify paths inside ~/.dub/packages for them.)

This is what I need to pass to the linker:

/path/to/vibe.d/libvibe-d.a -L-ldl -L-levent -L-levent_pthreads -L-lssl -L-lcrypto

Here, libvibe-d.a is the library that I have built in previous post.

For Cook, I run this command in my project's source root:

cook \
-C"-I/path/to/vibe.d/source \
  -I/path/to/openssl-master \
  -I/path/to/libevent-master \
  ...other includes... \
  -version=VibeCustomMain \
  -version=VibeLibeventDriver" \
-L"/d/Sources/vibe.d/libvibe-d.a \
  ...other libraries.a... \
  -L-ldl \
  -L-levent \
  -L-levent_pthreads \
  -L-lssl \
  -L-lcrypto" \
-o MySuperBinary

After compiling all files, this is what Cook runs to link my binary:

dmd -L-rpath -L"." -L-ldl \
  /path/to/vibe.d/libvibe-d.a \
  ...other libraries.a... \
  -L-ldl -L-levent -L-levent_pthreads -L-lssl -L-lcrypto \
  ...all the object files... \
  -ofMySuperBinary

Thanks again!

On Fri, 27 Jun 2014 15:26:20 GMT, Maaaks wrote:

For example, I don't like that there seems to be no way to add the -version=VibeCustomMain using command-line switches without modifying dub.json.

For now, I decided to compile vibe.d itself with Dub. I just modified it a little:

    ...
    "dflags": ["-version=VibeCustomMain"]
}

After it, I ran dub build and got libvibe-d.a in the directory.

(This is another reason why I don't like Dub: it always works in current directory. I prefer to have sources in one place and build results in another.)

On Fri, 27 Jun 2014 14:43:17 GMT, Sönke Ludwig wrote:

On Fri, 27 Jun 2014 14:10:53 GMT, Maaaks wrote:

All manuals say that vibe.d should be used as a dependency in Dub projects, but Dub seems not very convenient to me for a few reasons. I'm looking for a simple tutorial how to use vibe.d without Dub.

It would definitely be interesting to know if there are any things that could be improved here to make DUB more convenient!

Currently, my program compiles but doesn't link because of multiple definitions of _D4vibe7appmain12__ModuleInfoZ. I have no idea how they could appear. (The library that I'm trying to link against is libvibe-d.a found in my ~/.dub directory.)

Currently, -version=VibeCustomMain is required when building the vibe.d library to skip including the default main function of vibe.d (see source/vibe/appmain.d). This will be made the default later this year, after a deprecation phase.

dmd -lib -olibvibe-d.a -Isource -I<path/to/openssl> -I<path/to/libevent> -lssl -lcrypto -levent -levent_threads -version=VibeCustomMain -version=VibeLibeventDriver <all .d files of vibe.d>