WINEDLLPATH weirdness

Open forum for end-user questions about Wine. Before asking questions, check out the Wiki as a first step.
Forum Rules
Locked
Erik de Castro Lopo

WINEDLLPATH weirdness

Post by Erik de Castro Lopo »

Hi all,

I'm using the Linux to MinGW cross compiler toolchain to build
windows binaries for one of my libraries. I'm also trying to
run the cross-compiled binaries that make up the test suite
under wine version 0.9.58 from ubuntu hardy heron.

The DLL for my library gets built as:

/home/erikd/Bzr/libsndfile-mingw/src/.libs/libsndfile-1.dll

and the test suite binaries get built in:

/home/erikd/Bzr/libsndfile-mingw/tests

If I go into that directory and run the following script:

#!/bin/bash

dll=libsndfile-1.dll
dlldir=/home/erikd/Bzr/libsndfile-mingw/src/.libs

if [ ! -f "$dlldir/$dll" ]; then
echo "Can't find DLL."
exit 1
fi

export WINEDLLPATH="$dlldir:$WINEDLLPATH"
exe=.libs/floating_point_test.exe

if [ -f $exe ]; then
exec $exe
fi

I get the following error message:

err:module:import_dll Library libsndfile-1.dll (which is needed
by L"Z:\\home\\erikd\\Bzr\\libsndfile-mingw\\tests\\.libs\\floating_point_test.exe")
not found
err:module:LdrInitializeThunk Main exe initialization for
L"Z:\\home\\erikd\\Bzr\\libsndfile-mingw\\tests\\.libs\\floating_point_test.exe"
failed, status c0000135

However, if I add a symbolic link in the current directory that links
to the DLL:

ln -s ../src/.libs/libsndfile-1.dll libsndfile-1.dll

it works.

Can anybody explain why the WINEDLLPATH doesn't seem to get picked
up?

Cheers,
Erik
--
-----------------------------------------------------------------
Erik de Castro Lopo
-----------------------------------------------------------------
"C makes it easy to shoot yourself in the foot. C++ makes it
harder, but when you do, you blow away your whole leg!"
-- Bjarne Stroustrup
vitamin
Moderator
Moderator
Posts: 6605
Joined: Sat Feb 23, 2008 2:29 pm

Re: WINEDLLPATH weirdness

Post by vitamin »

What happens if you do?

Code: Select all

if [ -f $exe ]; then
exec wine $exe
fi
Erik de Castro Lopo

WINEDLLPATH weirdness

Post by Erik de Castro Lopo »

vitamin wrote:
What happens if you do?

Code:
if [ -f $exe ]; then
exec wine $exe
fi
Wow! It works just like its supposed to. Thanks. Unfortunately
now I need to understand why.

The problem is that the script I posted is a very much cut
down version of the wrapper script generated by libtool.
If at all possible I'd like to be able to solve this problem
in a way that allows the libtool generated script to work.

Cheers,
Erik
--
-----------------------------------------------------------------
Erik de Castro Lopo
-----------------------------------------------------------------
"The beauty of religious mania is that it has the power to
explain everything. Once God (or Satan) is accepted as the first
cause of everything which happens in the mortal world, nothing
is left to chance...logic can be happily tossed out the window."
- Stephen King
vitamin
Moderator
Moderator
Posts: 6605
Joined: Sat Feb 23, 2008 2:29 pm

Re: WINEDLLPATH weirdness

Post by vitamin »

Erik de Castro Lopo wrote:vitamin wrote:
What happens if you do?

Code:
if [ -f $exe ]; then
exec wine $exe
fi
Wow! It works just like its supposed to. Thanks. Unfortunately
now I need to understand why.
I'm guessing that binfmt won't use your environment for the security reasons.
Erik de Castro Lopo

WINEDLLPATH weirdness

Post by Erik de Castro Lopo »

vitamin wrote:
I'm guessing that binfmt won't use your environment for the
security reasons.
Ah, of course, if I exec wine, the environment is preserved
while if I try to execute the windows exe directly it has to
go through the binfmt kernel module which has all sorts of
good reasons for not trusting the existing environment.

Looks like I've goot some libtool hacking ahead of me.

Thanks for the help.

Cheers,
Erik
--
-----------------------------------------------------------------
Erik de Castro Lopo
-----------------------------------------------------------------
"If I were on life-support, I'd rather have it run by a Gameboy
than a Windows box."
-- Cliff Wells in comp.lang.python
Erik de Castro Lopo

WINEDLLPATH weirdness

Post by Erik de Castro Lopo »

Erik de Castro Lopo wrote:
vitamin wrote:
What happens if you do?

Code:
if [ -f $exe ]; then
exec wine $exe
fi
Wow! It works just like its supposed to. Thanks. Unfortunately
now I need to understand why.
Sorry, that was a mistake, I still had a symlink in the local
directory which pointed to the DLL.

I've updated my test script as follows:

#!/bin/bash

exe=`pwd`/.libs/floating_point_test.exe
dll=libsndfile-1.dll
dlldir=/home/erikd/Bzr/libsndfile-mingw/src/.libs

if [ ! -f $exe ]; then
echo "No exe. Stopping."
exit 1
fi

if [ ! -f "$dlldir/$dll" ]; then
echo "Can't find DLL."
exit 1
fi

echo "Trying with symlink"
ln -s "$dlldir/$dll" $dll

if [ -f $exe ]; then
wine $exe
fi

echo "Trying without symlink"
export WINEDLLPATH="$dlldir:$WINEDLLPATH"

if [ -f libsndfile-1.dll ]; then
echo "Deleting DLL symlink."
rm -f libsndfile-1.dll
fi

if [ -f $exe ]; then
wine $exe
fi

The first invocation of wine when the symlink is present works,
the second where I just try to rely on WINEDLLPATH doesn't.

Is it possible that wine is ignoring WINEDLLPATH?

Erik
--
-----------------------------------------------------------------
Erik de Castro Lopo
-----------------------------------------------------------------
Linux, the UNIX defragmentation tool.
Locked