Linking to static libraries with a local DMD install

Henry GOuk via Digitalmars-d-learn digitalmars-d-learn at puremagic.com
Sat Aug 20 20:54:27 PDT 2016


Hi,

Due to some security limitations, I've had to install DMD in my 
home folder on one of my university computers.

When trying to build a basic vibe.d application (i.e., the one 
created by dub init test --type=vibe.d), linking fails with a 
large number of undefined references to functions in libssl, 
libcrypto, etc.

Running dub with -v shows that the command which is failing is:

dmd 
-of.dub/build/application-debug-linux.posix-x86_64-dmd_2071-9C38B44F3C839608CC3543300CB92D81/test .dub/build/application-debug-linux.posix-x86_64-dmd_2071-9C38B44F3C839608CC3543300CB92D81/test.o ../../.dub/packages/vibe-d-0.7.29/vibe-d/libvibe-d.a ../../.dub/packages/vibe-d-0.7.29/vibe-d/libvibe-d_mail.a ../../.dub/packages/vibe-d-0.7.29/vibe-d/libvibe-d_mongodb.a ../../.dub/packages/vibe-d-0.7.29/vibe-d/libvibe-d_redis.a ../../.dub/packages/vibe-d-0.7.29/vibe-d/libvibe-d_web.a ../../.dub/packages/vibe-d-0.7.29/vibe-d/libvibe-d_diet.a ../../.dub/packages/vibe-d-0.7.29/vibe-d/libvibe-d_http.a ../../.dub/packages/vibe-d-0.7.29/vibe-d/libvibe-d_core.a ../../.dub/packages/vibe-d-0.7.29/vibe-d/libvibe-d_data.a ../../.dub/packages/vibe-d-0.7.29/vibe-d/libvibe-d_utils.a -L--no-as-needed -L-levent -L-levent_pthreads -L-lssl -L-lcrypto -g

If I then execute this command manually, with -v, then I can see 
that this command is failing:

cc 
.dub/build/application-debug-linux.posix-x86_64-dmd_2071-9C38B44F3C839608CC3543300CB92D81/test.o -o .dub/build/application-debug-linux.posix-x86_64-dmd_2071-9C38B44F3C839608CC3543300CB92D81/test -g -m64 -Xlinker --no-as-needed -levent -levent_pthreads -lssl -lcrypto -L/home/hgrg1/localroot/usr/bin/../lib -Xlinker --export-dynamic ../../.dub/packages/vibe-d-0.7.29/vibe-d/libvibe-d.a ../../.dub/packages/vibe-d-0.7.29/vibe-d/libvibe-d_mail.a ../../.dub/packages/vibe-d-0.7.29/vibe-d/libvibe-d_mongodb.a ../../.dub/packages/vibe-d-0.7.29/vibe-d/libvibe-d_redis.a ../../.dub/packages/vibe-d-0.7.29/vibe-d/libvibe-d_web.a ../../.dub/packages/vibe-d-0.7.29/vibe-d/libvibe-d_diet.a ../../.dub/packages/vibe-d-0.7.29/vibe-d/libvibe-d_http.a ../../.dub/packages/vibe-d-0.7.29/vibe-d/libvibe-d_core.a ../../.dub/packages/vibe-d-0.7.29/vibe-d/libvibe-d_data.a ../../.dub/packages/vibe-d-0.7.29/vibe-d/libvibe-d_utils.a -Xlinker -Bstatic -lphobos2 -Xlinker -Bdynamic -lpthread -lm -lrt -ldl

Once again, with -v:

/usr/lib/gcc/x86_64-linux-gnu/4.8/collect2 --sysroot=/ --build-id 
--eh-frame-hdr -m elf_x86_64 --hash-style=gnu --as-needed 
-dynamic-linker /lib64/ld-linux-x86-64.so.2 -z relro -o 
.dub/build/application-debug-linux.posix-x86_64-dmd_2071-9C38B44F3C839608CC3543300CB92D81/test /usr/lib/gcc/x86_64-linux-gnu/4.8/../../../x86_64-linux-gnu/crt1.o /usr/lib/gcc/x86_64-linux-gnu/4.8/../../../x86_64-linux-gnu/crti.o /usr/lib/gcc/x86_64-linux-gnu/4.8/crtbegin.o -L/home/hgrg1/localroot/usr/bin/../lib -L/home/hgrg1/localroot/lib/../lib -L/home/hgrg1/localroot/usr/lib/../lib -L/home/hgrg1/localroot/usr/local/lib/../lib -L/usr/lib/gcc/x86_64-linux-gnu/4.8 -L/usr/lib/gcc/x86_64-linux-gnu/4.8/../../../x86_64-linux-gnu -L/usr/lib/gcc/x86_64-linux-gnu/4.8/../../../../lib -L/lib/x86_64-linux-gnu -L/lib/../lib -L/usr/lib/x86_64-linux-gnu -L/usr/lib/../lib -L/home/hgrg1/localroot/lib -L/home/hgrg1/localroot/usr/lib -L/home/hgrg1/localroot/usr/local/lib -L/usr/lib/gcc/x86_64-linux-gnu/4.8/../../.. .dub/build/application-debug-linux.posix-x86_64-dmd_2071-9C38B44F3C839608CC3543300CB92D81/stream2vec.o --no-as-needed -levent -levent_pthreads -lssl -lcrypto --export-dynamic ../../.dub/packages/vibe-d-0.7.29/vibe-d/libvibe-d.a ../../.dub/packages/vibe-d-0.7.29/vibe-d/libvibe-d_mail.a ../../.dub/packages/vibe-d-0.7.29/vibe-d/libvibe-d_mongodb.a ../../.dub/packages/vibe-d-0.7.29/vibe-d/libvibe-d_redis.a ../../.dub/packages/vibe-d-0.7.29/vibe-d/libvibe-d_web.a ../../.dub/packages/vibe-d-0.7.29/vibe-d/libvibe-d_diet.a ../../.dub/packages/vibe-d-0.7.29/vibe-d/libvibe-d_http.a ../../.dub/packages/vibe-d-0.7.29/vibe-d/libvibe-d_core.a ../../.dub/packages/vibe-d-0.7.29/vibe-d/libvibe-d_data.a ../../.dub/packages/vibe-d-0.7.29/vibe-d/libvibe-d_utils.a -Bstatic -lphobos2 -Bdynamic -lpthread -lm -lrt -ldl -lgcc --as-needed -lgcc_s --no-as-needed -lc -lgcc --as-needed -lgcc_s --no-as-needed /usr/lib/gcc/x86_64-linux-gnu/4.8/crtend.o /usr/lib/gcc/x86_64-linux-gnu/4.8/../../../x86_64-linux-gnu/crtn.o


If I try to build the same project, initialised the same way, on 
a machine with DMD and libssl, libevent, etc installed in a 
system-wide location then everything works as expected. Does 
anyone know what I've missed out when setting up DMD and the 
vibe.d dependencies?

Thanks,
Henry


More information about the Digitalmars-d-learn mailing list