RejectedSoftware Forums

Sign up

Resolving linker errors when trying to use vibe for raw tcp

Hi,

I have a problem building an application that uses the vibe.d framework. If I follow the First steps tutorial in the documentation, I can successfully run the server and access it via a browser. However when I try to build my app without the 'vibe' command, I hit the wall hard. What parameters does the dmd need to successfully build an app that uses vibe.d?

App:
import vibe.vibe;
void main() {}

System:
Debian linux
DMD 2.060
vibe.d downloaded via apt

Errors:
server.o:(.data+0x3e0): undefined reference to _D4vibe4vibe12__ModuleInfoZ'<br>server.o: In function D4vibe4core14connectionpool67T16LockedConnectionTC4vibe2db5mongo10connection15MongoConnectionZ16LockedConnection10postblitMFZv':
server.d:(.text.
D4vibe4core14connectionpool67T16LockedConnectionTC4vibe2db5mongo10connection15MongoConnectionZ16LockedConnection10postblitMFZv+0x30): undefined reference to `D4vibe4core14connectionpool8_assertFiZv'
...
collect2: ld returned 1 exit status

Thanks,
Martin

Re: Resolving linker errors when trying to use vibe for raw tcp

On Wed, 07 Nov 2012 22:26:14 GMT, Martin Drasar wrote:

Hi,

I have a problem building an application that uses the vibe.d framework. If I follow the First steps tutorial in the documentation, I can successfully run the server and access it via a browser. However when I try to build my app without the 'vibe' command, I hit the wall hard. What parameters does the dmd need to successfully build an app that uses vibe.d?

You also need to put all vibe.d source files on the command line. The fastest way should be something like:

cd /path/to/project
find /opt/vibe/source/vibe/ -type f > files.txt
dmd -ofapp -I/opt/vibe/source @files.txt source/app.d -L-levent_pthreads -L-levent -L-lssl -L-lcrypto
./app

Re: Resolving linker errors when trying to use vibe for raw tcp

On Thu, 08 Nov 2012 20:23:08 GMT, Sönke Ludwig wrote:

You also need to put all vibe.d source files on the command line. The fastest way should be something like:

cd /path/to/project
find /opt/vibe/source/vibe/ -type f > files.txt
dmd -ofapp -I/opt/vibe/source @files.txt source/app.d -L-levent_pthreads -L-levent -L-lssl -L-lcrypto
./app

Hi,

thanks. I was thinking this was the last resort solution, but if it is the way it should be, then be it :-)

I am still having problem building it, though. I have removed appmain.d and d.d from the list of files to get rid of duplicate main error, but there still seems to be problem with libevent.

app.o: In function `ev_default_loop':
server.d:(.text.ev_default_loop+0x1d): undefined reference to `ev_default_loop_init'
collect2: ld returned 1 exit status

I am obviously missing some small bit, but I am not sure which one...
Any ideas?

Re: Resolving linker errors when trying to use vibe for raw tcp

app.o: In function `ev_default_loop':
server.d:(.text.ev_default_loop+0x1d): undefined reference to `ev_default_loop_init'
collect2: ld returned 1 exit status

I think you included the source/deimos files, but only the source/vibe ones should be compiled.

Of course it would also be possible to compile the vibe files as a static library to avoid the huge command line, but because of the big number of operating systems, architectures and compiler versions shipping a precompiled library would be quite problematic.

Another alternative is to use rdmd instead of plain dmd. In that case this is sufficient:

rdmd --compile-only -ofapp -I/opt/vibe/source -Isource source/app.d -L-levent_pthreads -L-levent -L-lssl -L-lcrypto 

Re: Resolving linker errors when trying to use vibe for raw tcp

On Thu, 08 Nov 2012 23:25:46 GMT, Sönke Ludwig wrote:

I think you included the source/deimos files, but only the source/vibe ones should be compiled.

Spot on! Excluding deimos from file list did the trick.

Of course it would also be possible to compile the vibe files as a static library to avoid the huge command line, but because of the big number of operating systems, architectures and compiler versions shipping a precompiled library would be quite problematic.

Ok, I understand this. After all, with dmd's fast compilation times, this is a non-issue once you write the build script.

Thanks for your help.

Martin

Re: Resolving linker errors when trying to use vibe for raw tcp

On Thu, 08 Nov 2012 23:25:46 GMT
"Sönke Ludwig" sludwig@rejectedsoftware.com wrote:

app.o: In function `ev_default_loop':
server.d:(.text.ev_default_loop+0x1d): undefined reference to
`ev_default_loop_init' collect2: ld returned 1 exit status

I think you included the source/deimos files, but only the
source/vibe ones should be compiled.

Of course it would also be possible to compile the vibe files as a
static library to avoid the huge command line, but because of the big
number of operating systems, architectures and compiler versions
shipping a precompiled library would be quite problematic.

Another alternative is to use rdmd instead of plain dmd. In that case
this is sufficient:

rdmd --compile-only -ofapp -I/opt/vibe/source -Isource source/app.d
-L-levent_pthreads -L-levent -L-lssl -L-lcrypto ```

If you're using rdmd, the app.d file needs to be the last arg, like
this:

rdmd --compile-only -ofapp -I/opt/vibe/source -Isource
-L-levent_pthreads -L-levent -L-lssl -L-lcrypto source/app.d ```




Re: Resolving linker errors when trying to use vibe for raw tcp

On Fri, 9 Nov 2012 05:08:56 -0500
Nick Sabalausky SeeWebsiteToContactMe@semitwist.com wrote:

On Thu, 08 Nov 2012 23:25:46 GMT
"Sönke Ludwig" sludwig@rejectedsoftware.com wrote:

rdmd --compile-only -ofapp -I/opt/vibe/source -Isource source/app.d
-L-levent_pthreads -L-levent -L-lssl -L-lcrypto ```

If you're using rdmd, the app.d file needs to be the last arg, like
this:

rdmd --compile-only -ofapp -I/opt/vibe/source -Isource
-L-levent_pthreads -L-levent -L-lssl -L-lcrypto source/app.d ```

Oh, and it's "--build-only", not "--compile-only"