Thread overview
Linking Trouble (Linux)
Sep 12, 2013
Craig Dillabaugh
Sep 12, 2013
Craig Dillabaugh
Sep 12, 2013
Craig Dillabaugh
Sep 13, 2013
Craig Dillabaugh
Sep 29, 2013
1100110
Sep 30, 2013
Craig Dillabaugh
September 12, 2013
I just upgraded my Linux distro (openSuse) and now when trying to
compile a project with dub I am getting linking errors.

Compilation goes OK until the linking stage, when I get the
following:

Linking...
dmd -of/home/craig/cloud/vibe-tiles/vibe
/home/craig/cloud/vibe-tiles/temp.o -L-levent_pthreads -L-levent
-L-lssl -L-lcrypto -g
/usr/lib64/gcc/x86_64-suse-linux/4.7/../../../../x86_64-suse-linux/bin/ld:
warning: libdl.so.2, needed by /usr/lib64/libcrypto.so, not found
(try using -rpath or -rpath-link)
/usr/lib64/gcc/x86_64-suse-linux/4.7/../../../../x86_64-suse-linux/bin/ld:
warning: libz.so.1, needed by /usr/lib64/libcrypto.so, not found
(try using -rpath or -rpath-link)
/usr/lib64/libcrypto.so: undefined reference to
`dlopen@GLIBC_2.2.5'
/usr/lib64/libcrypto.so: undefined reference to
`dlerror@GLIBC_2.2.5'
/usr/lib64/libcrypto.so: undefined reference to
`dlclose@GLIBC_2.2.5'
/usr/lib64/libcrypto.so: undefined reference to
`dlsym@GLIBC_2.2.5'
/usr/lib64/libcrypto.so: undefined reference to
`dladdr@GLIBC_2.2.5'

Strangely, libdl.so.2 and libz.so.1 are both there and libcrypto
is linked to them.

$ ldd /usr/lib64/libcrypto.so
         linux-vdso.so.1 (0x00007fff7d520000)
         libdl.so.2 => /lib64/libdl.so.2 (0x00007f3b2ef98000)
         libz.so.1 => /lib64/libz.so.1 (0x00007f3b2ed80000)
         libc.so.6 => /lib64/libc.so.6 (0x00007f3b2e9d0000)
         /lib64/ld-linux-x86-64.so.2 (0x00007f3b2f5a8000)

I've surfed around quite a bit and can't seem to find anything.
I solved a similar problem in the past by reinstalling glibc, but
that hasn't helped in this case. Any hints on where to look would
be appreciated.

Craig
September 12, 2013
On Thursday, 12 September 2013 at 19:46:21 UTC, Craig Dillabaugh
wrote:
> I just upgraded my Linux distro (openSuse) and now when trying to
> compile a project with dub I am getting linking errors.
>
> Compilation goes OK until the linking stage, when I get the
> following:
>
> Linking...
> dmd -of/home/craig/cloud/vibe-tiles/vibe
> /home/craig/cloud/vibe-tiles/temp.o -L-levent_pthreads -L-levent
> -L-lssl -L-lcrypto -g

clip
>
> Strangely, libdl.so.2 and libz.so.1 are both there and libcrypto
> is linked to them.
>
clip
>
> Craig

OK, so I solved my compilation problem by passing the following
as the linker command (added -L-ldl and -L-lz):

dmd -of/home/craig/cloud/vibe-tiles/vibe
/home/craig/cloud/vibe-tiles/temp.o -L-levent_pthreads -L-levent
-L-lssl -L-ldl -L-lz -L-lcrypto -g

How the GCC linker decides which libraries I need to explicitly
specify is indeed a mystery to me.

Craig
September 12, 2013
On Thursday, 12 September 2013 at 20:26:29 UTC, Craig Dillabaugh
wrote:
> On Thursday, 12 September 2013 at 19:46:21 UTC, Craig Dillabaugh
> wrote:
>> I just upgraded my Linux distro (openSuse) and now when trying to
>> compile a project with dub I am getting linking errors.
>>
>> Compilation goes OK until the linking stage, when I get the
>> following:
>>
>> Linking...
>> dmd -of/home/craig/cloud/vibe-tiles/vibe
>> /home/craig/cloud/vibe-tiles/temp.o -L-levent_pthreads -L-levent
>> -L-lssl -L-lcrypto -g
>
> clip
>>
>> Strangely, libdl.so.2 and libz.so.1 are both there and libcrypto
>> is linked to them.
>>
> clip
>>
>> Craig
>
> OK, so I solved my compilation problem by passing the following
> as the linker command (added -L-ldl and -L-lz):
>
> dmd -of/home/craig/cloud/vibe-tiles/vibe
> /home/craig/cloud/vibe-tiles/temp.o -L-levent_pthreads -L-levent
> -L-lssl -L-ldl -L-lz -L-lcrypto -g
>
> How the GCC linker decides which libraries I need to explicitly
> specify is indeed a mystery to me.
>
> Craig

For anyone who runs into a similar problem using DUB the
following package.json files solves the problem:

{
	"name": "vibe",
	"description": "My first vibe project.",
	"homepage": "http://example.org",
	"copyright": "Me",
	"authors": [
		"Craig Dillabaugh"
	],
	"dependencies": {
		"vibe-d": "~master"
	},
	"libs": ["dl", "z"]
}
September 13, 2013
On Thursday, 12 September 2013 at 20:47:46 UTC, Craig Dillabaugh
wrote:
clip
>
> For anyone who runs into a similar problem using DUB the
> following package.json files solves the problem:
>
> {
> 	"name": "vibe",
> 	"description": "My first vibe project.",
> 	"homepage": "http://example.org",
> 	"copyright": "Me",
> 	"authors": [
> 		"Craig Dillabaugh"
> 	],
> 	"dependencies": {
> 		"vibe-d": "~master"
> 	},
> 	"libs": ["dl", "z"]
> }

Hopefully starting a thread on a forum and then repeatedly
answering yourself isn't a sign of insanity, but I've found the
ultimate source of my problems and wanted to post back here in
case it might help someone else (myself?) in the future.

Anyway my suggested hacks above got my D programs to compile, but
when I tried to run anything, I would get seg faults along the
following lines:

(gdb) backtrace
#0  0x00000000004547b9 in std.stdio.__T7writelnTAyaZ.writeln() ()
#1  0x0000000000454301 in D main ()
#2  0x0000000000460958 in rt.dmain2._d_run_main() ()
#3  0x000000000046048a in rt.dmain2._d_run_main() ()
#4  0x00000000004609a8 in rt.dmain2._d_run_main() ()
#5  0x000000000046048a in rt.dmain2._d_run_main() ()
#6  0x0000000000460446 in _d_run_main ()
#7  0x0000000000460293 in main ()

It seems the source of my troubles was a broken binutils install
by openSuse. So I re-installed binutils and now everything purrs
along.

Thanks to everyone for your help :o)

September 29, 2013
https://xkcd.com/979/

Please.  You are somebodies hero.
September 30, 2013
On Sunday, 29 September 2013 at 14:16:21 UTC, 1100110 wrote:
> https://xkcd.com/979/
>
> Please.  You are somebodies hero.

Did you actually run into the same problem?  If so, glad I could help.