# HOWTO: WINE on amd64 (faster/binary way)



## vermaden (May 8, 2010)

Since some longer time amd64 users can run WINE without a problem, but additional complete i386 environment is requied, as http://wiki.freebsd.org/Wine states, you will have to build i386 version, then build WINE and so (which of course takes time). In this guide You will learn how to install WINE on amd64 system without compiling a single file, everything will be achieved using already built packages/data sets.

Use this script below to add both i386 complete environment under /compat/i386 and wine packages along with appreciate dependencies.


```
#! /bin/sh

URL=ftp.freebsd.org/pub/FreeBSD/releases/i386/$( uname -r | egrep -o ".*-[A-Z]+[0-9]*" )/base
DIR=/compat/i386

mkdir -p ${DIR}
export DESTDIR=${DIR}
pkg_add -r wget
wget -r -c ftp://${URL}
cd ${URL}
chmod +x install.sh
yes | ./install.sh
cp /etc/resolv.conf ${DIR}/etc/

cat > ${DIR}/chroot.sh << __EOF
  /etc/rc.d/ldconfig start
  export MACHINE=i386
  export UNAME_p=i386
  export UNAME_m=i386
  pkg_add -r wine
__EOF

chroot ${DIR} /bin/sh chroot.sh
rm ${DIR}/chroot.sh
```

Just lauch it as root and it will install/do everything.

Tested, works great with Heroes ]I[ game, devfs is not needed for it, but in case some other game/application will yell about it, just mount it. 

`# mount -t devfs devfs /compat/i386/dev`

You will also have to use these aliases:


```
# alias winecfg="LD_32_LIBRARY_PATH=/compat/i386/usr/local/lib PATH=/compat/i386/usr/local/bin:$PATH /compat/i386/usr/local/bin/winecfg"
# alias wine32="LD_32_LIBRARY_PATH=/compat/i386/usr/local/lib PATH=/compat/i386/usr/local/bin:$PATH /compat/i386/usr/local/bin/wine"
```

Works for me, in case You have any problems, this thread is the place to yell


----------



## mfaridi (Jun 19, 2010)

I run this script , and it download many packages , and I think it want install all of them , So I cancel it , and I think install this packages break my system , for example this script download these packages

```
libX11-1.2.1,1.tbz... Done.
libXrender-0.9.4_1.tbz... Done.
libXt-1.0.5_1.tbz... Done.
libXfixes-4.0.3_1.tbz... Done.
libXdamage-1.1.1.tbz... Done.
libXext-1.0.5,1.tbz... Done.
libXpm-3.5.7.tbz... Done.
libXmu-1.0.4,1.tbz... Done.
libXi-1.2.1,1.tbz... Done.
libXxf86vm-1.0.2.tbz... Done.
```
Am I right ?
Do I think true ?


----------



## Jamz (Jun 20, 2010)

that's just part of the wine package install, not something specific to the script.


----------



## mfaridi (Jun 21, 2010)

Today I run this script and I see this error first


```
You are about to extract the base distribution into /compat/i386 - are you SURE you want to do this over your installed system (y/n)? 
./var/empty/: Can't set user=0/group=0 for var/empty: Operation not permitted Can't update time for var/empty: Operation not permitted
./usr/sbin/sliplogin: Could not unlink: Not a directory
./usr/lib/libkse.so.3: Could not unlink: Not a directory
./usr/lib/librt.so.1: Could not unlink: Not a directory
./usr/bin/chpass: Could not unlink: Not a directory
./usr/bin/chfn: Could not unlink: Not a directory
./usr/bin/chsh: Could not unlink: Not a directory
./usr/bin/ypchpass: Could not unlink: Not a directory
./usr/bin/ypchfn: Could not unlink: Not a directory
./usr/bin/ypchsh: Could not unlink: Not a directory
./usr/bin/login: Could not unlink: Not a directory
./usr/bin/opieinfo: Could not unlink: Not a directory
./usr/bin/opiepasswd: Could not unlink: Not a directory
./usr/bin/passwd: Could not unlink: Not a directory
./usr/bin/yppasswd: Could not unlink: Not a directory
./usr/bin/rlogin: Could not unlink: Not a directory
./usr/bin/rsh: Could not unlink: Not a directory
./usr/bin/su: Could not unlink: Not a directory
./usr/bin/crontab: Could not unlink: Not a directory
./sbin/init: Could not unlink: Not a directory
./libexec/ld-elf.so.1: Could not unlink: Not a directory
./lib/libc.so.7: Could not unlink: Not a directory
./lib/libcrypt.so.4: Could not unlink: Not a directory
./lib/libthr.so.3: Could not unlink: Not a directory
./bin/rcp: Could not unlink: Not a directory
tar: Error exit delayed from previous errors.
```
when I run this command 

```
whereis wine
```
 I see this 
	
	



```
wine: /usr/ports/emulators/wine
```
 when I type 

```
/usr/local/bin/wine
```
 I see this 
	
	



```
zsh: no such file or directory: /usr/local/bin/wine
```
 when I type 
	
	



```
/usr/local/sbin/wine
```
 I see this 
	
	



```
sh: no such file or directory: /usr/local/sbin/wine
```
I use 

```
FreeBSD 7.2-RELEASE-p8 #0: Tue May 25 17:51:43 UTC 2010     root@amd64-builder.daemonology.net:/usr/obj/usr/src/sys/GENERIC  amd64
```


----------



## vermaden (Jun 21, 2010)

@mfaridi



> Today I run this script and I see this error first


Its not the first time You can not use a HOWTO properly 

If You run it once, then extracting *base.** packages also applied various flags for the directories, check *man chflags* for details.



> when I type
> 
> ```
> /usr/local/bin/wine
> ...


You know what a *chroot(1)* is mate?


----------



## mfaridi (Jun 21, 2010)

when I run this commnad

```
/compat/i386/usr/local/bin/wine Google\ Chrome\ 4.0.295.0\ Beta.exe
```
I see this error 

```
ELF interpreter /libexec/ld-elf.so.1 not found
```
and

```
zsh: abort      /compat/i386/usr/local/bin/wine Google\ Chrome\ 4.0.295.0\ Beta.exe
```
I run these command too 

```
# alias winecfg="LD_32_LIBRARY_PATH=/compat/i386/usr/local/lib PATH=/compat/i386/usr/local/bin:$PATH /compat/i386/usr/local/bin/winecfg"
# alias wine32="LD_32_LIBRARY_PATH=/compat/i386/usr/local/lib PATH=/compat/i386/usr/local/bin:$PATH /compat/i386/usr/local/bin/wine"
```


----------



## vermaden (Jun 21, 2010)

mfaridi said:
			
		

> I run these command too
> 
> ```
> # alias winecfg="LD_32_LIBRARY_PATH=/compat/i386/usr/local/lib PATH=/compat/i386/usr/local/bin:$PATH /compat/i386/usr/local/bin/winecfg"
> ...



You know what a *alias(1)* is and what is it used for?


----------



## dralex999 (Jun 30, 2010)

I tried this script and kept getting errors. The first line of code took off the 1 from 8.1-RC1 leaving me unable to change directories properly at the remote site. Then it gave me double slashes '//' just before the base directory.  I also got the ldconfig error. Once I got it somewhat debugged, to that point at least. In short I think your script needs to be reworked a bit. I'll give it another hour or two of work, but I think your how-to isn't quite how to.... I didn't get to the point of needing aliases, just couldn't get the base.aa-zz downloaded at all. Bummer, heavy sigh. Will try an mget later on the base.* and work the script from there on.


----------



## vermaden (Jun 30, 2010)

@dralex999

I will test it on 8.1-RELEASE as it will get out (about early august I think).



			
				dralex999 said:
			
		

> In short I think your script needs to be reworked a bit.


It seems that it will work on RELEASE and STABLE but not on RC*/BETA* so the only part that needs to be changed is the regullar expression, fixed:

`% echo "8.1-RC1" | egrep -o ".*-[A-Z]+[0-9]*"
8.1-RC1`


----------



## dralex999 (Jun 30, 2010)

Nope, didn't work. I downloaded the base.* 'stuff' and ran across the same unlink problems one of the other posters had. I used the install.sh they had on the remote site instead of the script provided above. Well, anyway, I'm going to play elsewhere in the ports and forget about wine on the amd64....for now.


----------



## vermaden (Jun 30, 2010)

dralex999 said:
			
		

> Nope, didn't work. I downloaded the base.* 'stuff' and ran across the same unlink problems one of the other posters had.



Its because files in base.** tarbals have put on various flags (*man chflags* for details), so You will need to remove them first, delete all 'junk' that is left and THEN start over: 

`# find /compat/i386 -exec chflags -f 0 {} ';'`
`# rm -r -f /compat/i386`


----------



## dralex999 (Jul 1, 2010)

Ok, well something went kaflouey in my system and I had to reinstall the whole thing. I'm sure it wasn't a wine thing, but nonetheless, I'll work on that script again in a couple days and see what I get. I believe I have some files in the /compat/i386/* directories so will grab a windows disk and give it a whirl. 

Later..


----------



## vertexSymphony (Jul 20, 2010)

Anything to have into account when using nvidia-drivers ? because when I use the alias to launch an X 3D application, it just crash without being able to find an OpenGL device :\


```
err:d3d_caps:WineD3D_CreateFakeGLContext Can't find a suitable iPixelFormat.
err:d3d:InitAdapters Failed to get a gl context for default adapter
err:d3d:WineDirect3DCreate Direct3D9 is not available without opengl
```

Thanks in advance


----------



## Symbiosis (Jul 24, 2010)

You should install the SAME version of nvidia drivers into the chroot environment.

Remember that you have to set MACHINE,UNAME_p and UNAME_m to i386 again in the chroot environment.

Nvidia driver depends on xorg and linux_base (fc10 in release8.1).

PD: Sorry for my poor english


----------



## jsa@ (Jul 25, 2010)

I tried something similar on 9.0-CURRENT but with 8.0-RELEASE as my /compat/i386. My app would run because of a different shlib version in base, which also got me thinking that 64-bit base might not go over well at times with the 32-bit app.

My solution, was to prepend /compat/i386/lib:/compat/i386/usr/lib: to the LD_PATH similar to:

```
alias winecfg="LD_32_LIBRARY_PATH=/compat/i386/lib:/compat/i386/usr/lib:/compat/i386/usr/local/lib PATH=/compat/i386/usr/local/bin:$PATH /compat/i386/usr/local/bin/winecfg"
alias wine32="LD_32_LIBRARY_PATH=/compat/i386/lib:/compat/i386/usr/lib:/compat/i386/usr/local/lib PATH=/compat/i386/usr/local/bin:$PATH /compat/i386/usr/local/bin/wine"
```

I am not at that machine currently, but I will check my .zshrc later and make sure that is what I had.


----------



## BuSerD (Aug 15, 2010)

Great job. I too have not been able to resolve the ld-elf error. I am certain it's me and not the script but any assistance in correcting this is greatly appreciated;


```
%/usr/compat/i386/usr/local/bin/winecfg                                         ELF interpreter /libexec/ld-elf.so.1 not found
Abort
```

Environment

```
%uname -rip
8.1-RELEASE amd64 GENERIC
%echo $SHELL
/bin/csh
```

Details are posted at http://freebsd.pastebin.com/mLzV9LDX

I am willing to switch to sh or install zsh (not really so high on bash) if that is the only suggestion any of you have. I mention that because my first though it that my knowledge of aliases in csh is really limited and that seems like a possible source of the issue. The only reason I am installing wine on this particular box is that I'd like to keep the installed number of ports to a minimum so virtualbox is out.

Thanks guys and gals.


----------



## VdoP (Oct 9, 2010)

BuSerD said:
			
		

> ...



Hi,
Has anyone already solved the "/libexec/ld-elf.so.1 not found"-problem?
I have the same problem too. Here is what i have done:

First I ran vermaden's installscript from the first post. I got no error here.
Then I mounted the devfs also according to the first post.
Afterwards I added the aliases to my ~/.bashrc (iam using bash)
Finally i copied some of the nvidia-32-bit libs to the chroot-folder:


```
NVIDIA-FreeBSD-x86-195.36.15/obj/libnvidia-tls.so.1 -> /compat/i386/usr/local/lib/libnvidia-tls.so.1                                                            
NVIDIA-FreeBSD-x86-195.36.15/obj/libGLcore.so.1 -> /compat/i386/usr/local/lib/libGLcore.so.1                                                                    
NVIDIA-FreeBSD-x86-195.36.15/obj/libGL.so.1 -> /compat/i386/usr/local/lib/libGL.so.1
```
These files were also copied to the lib32-dir by the "patch-wine-nvidia.sh"-script, that is provided with the unofficial amd64 wine builds to improve the 3D performance. So I thought putting them in the chroot might be a good idea too.

Some info about my system:
I'm running a generic kernel
My .bashrc:

```
alias ls='ls -G'                                                                                                                                               
 alias dir='ls'                                                                                                                                                 
 alias winecfg="LD_32_LIBRARY_PATH=/compat/i386/usr/local/lib PATH=/compat/i386/usr/local/bin:$PATH /compat/i386/usr/local/bin/winecfg"                         
alias wine32="LD_32_LIBRARY_PATH=/compat/i386/usr/local/lib PATH=/compat/i386/usr/local/bin:$PATH /compat/i386/usr/local/bin/wine"                          
 PS1='\[\e[0;32m\]\u\[\e[m\] \[\e[1;34m\]\w\[\e[m\] \[\e[1;32m\]\$\[\e[m\] \[\e[1;37m\]'
```
The content of the libexec folders:

```
vdop ~ $ ls /libexec/                                                                                                                                           
ld-elf.so.1                                                                                                                                                     
vdop ~ $ ls /compat/i386/libexec/
ld-elf.so.1
```

And here is what happens when I try to run wine:

```
vdop ~ $ wine32
ELF interpreter /libexec/ld-elf.so.1 not found                                                                                                                  
Abort trap: 6                                                                                                                                                   
vdop ~ $ winecfg                                                                                                                                                
ELF interpreter /libexec/ld-elf.so.1 not found                                                                                                                  
Abort trap: 6
```

Now if I manually chroot into /compat/i386, this error does not occur:

```
root /home/vdop #  chroot /compat/i386/ /usr/local/bin/bash                                                                                                     
[root@bsdbox /]# wine                                                                                                                                           
Usage: wine PROGRAM [ARGUMENTS...]   Run the specified program                                                                                                  
       wine --help                   Display this help and exit                                                                                                 
       wine --version                Output version information and exit                                                                                        
[root@bsdbox /]# winecfg                                                                                                                                        
Application tried to create a window, but no driver could be loaded.                                                                                            
Make sure that your X server is running and that $DISPLAY is set correctly.                                                                                     
err:systray:initialize_systray Could not create tray window                                                                                                     
Application tried to create a window, but no driver could be loaded.                                                                                            
Make sure that your X server is running and that $DISPLAY is set correctly.                                                                                     
[root@bsdbox /]#
```

So there seems to be a problem with the aliases and the settings for the paths. I just can't figure out what.


Greetings,
Chris


----------



## VdoP (Oct 10, 2010)

Just in case someone is interested in the solution of this problem:
It was my fault, as there were some libs in /usr/lib32 missing!

I just fetched all the files from here ftp://ftp.freebsd.org/pub/FreeBSD/releases/amd64/8.1-RELEASE/lib32/ and ran 
	
	



```
sh install.sh
```

Then I rebuilt all of the sources again:

```
cd /usr/src; make build32 install32; ldconfig -v -m -R /usr/lib32
```

Then it worked like a charm on both ways (Your chroot/alias-solution and the unofficial wine-amd64 package)


Greetings,
Chris


----------



## El_Barto (Nov 24, 2010)

I am running 8.1 on AMD64 (I swear my next system will be Intel) I am unable to install Wine, I tried everything ..
The reason I am stuck with FreeBSD is because PCBSD disabled both my AMD64 systems after install. 
I had to unplug the HD in order to be able to boot something because the bios kept hanging (some bug) and even the F10 or DEL options were useless. (Had to plug them back in after booting Gparted).
Ok, I admit, I am a total noob, so any help of you BSD gods is appreciated ..

1) Do not know what happened with this port but it is not available

2) These builds for AMD install, but do not show up in the KDE menu, but only in search. After booting I see the Wine icon at the mouse pointer for a minute after which it stops and nothing happens

3) I tried this link

but after the first command

`# cd /usr/src && make buildworld installworld distribution TARGET=i386 DESTDIR=/compat/i386`

I wait 45 minutes after which I have the following message


```
>>> Making hierarchy
--------------------------------------------------------------
cd /usr/src; make -f Makefile.inc1 hierarchy
cd /usr/src/etc;                make distrib-dirs
mtree -eU  -f /usr/src/etc/mtree/BSD.root.dist -p /compat/i386/
mtree: /compat/i386/: No such file or directory
*** Error code 1

Stop in /usr/src/etc.
*** Error code 1

Stop in /usr/src.
*** Error code 1

Stop in /usr/src.
*** Error code 1

Stop in /usr/src.
*** Error code 1

Stop in /usr/src.
```

4) So I found this thread and tried the script in the first post above with the following somewhat similar outcome as in (3):


```
FINISHED --2010-11-24 19:49:29--
Downloaded: 43 files, 53M in 6m 56s (130 KB/s)
$ cd ${URL}
$ chmod +x install.sh
$ yes | ./install.sh
Sorry, this must be done as root.
$ cp /etc/resolv.conf ${DIR}/etc/
cp: directory /compat/i386/etc does not exist
$ 
$ cat > ${DIR}/chroot.sh << __EOF
>   /etc/rc.d/ldconfig start
>   export MACHINE=i386
>   export UNAME_p=i386
>   export UNAME_m=i386
>   pkg_add -r wine
> __EOF
cannot create /compat/i386/chroot.sh: No such file or directory
$ 
$ chroot ${DIR} /bin/sh chroot.sh
chroot: /compat/i386: No such file or directory
$ rm ${DIR}/chroot.sh
```


Is there any way how I can solve this problem? Thanks in advance


----------



## vermaden (Nov 28, 2010)

El_Barto said:
			
		

> ```
> $ yes | ./install.sh
> Sorry, this must be done as root.
> ```


This is rather self explanatory ...


----------



## El_Barto (Nov 29, 2010)

thx for the reply

I did not notice it in the message but I already ran this in root, with the necessary errors. I discovered the port wget was not configured correctly and did a make config.

I updated and upgraded all available ports, this seems to have solved the necessary errors but for some reason I am still unable to get it working. I'll keep trying till I found the source of this problem.


----------



## vermaden (Nov 29, 2010)

I used it on FreeBSD 8.0-RELEASE, I havent tried it on 8.1, maybe the guide (or WINE) is broken now ...


----------



## bigrob76 (Dec 14, 2010)

VdoP said:
			
		

> Just in case someone is interested in the solution of this problem:
> It was my fault, as there were some libs in /usr/lib32 missing!
> 
> I just fetched all the files from here ftp://ftp.freebsd.org/pub/FreeBSD/releases/amd64/8.1-RELEASE/lib32/ and ran
> ...



Pardon my ignorance, but does this have to be done outside of chroot?

I have copied the lib32 files in, put them in /compat/i386/usr/lib32 and I get the following error (in chroot) 
	
	



```
make: don't know how to make build32. Stop
*** Error code 2
```


----------



## Carpetsmoker (Jan 10, 2013)

Thank you vermaden.

Here's a version which will work on FreeBSD 9 (it will *not* work on FreeBSD 8 and earlier).


```
#! /bin/sh

URL=ftp.freebsd.org/pub/FreeBSD/releases/i386/$( uname -r | egrep -o ".*-[A-Z]+[0-9]*" )/base.txz
DIR=/usr/compat/i386

mkdir -p ${DIR}

fetch ftp://${URL}
tar xf base.txz -C ${DIR}
cp /etc/resolv.conf ${DIR}/etc/

mount -t devfs devfs /compat/i386/dev

cat > ${DIR}/chroot.sh << __EOF
  /etc/rc.d/ldconfig start
  export MACHINE=i386
  export UNAME_p=i386
  export UNAME_m=i386
  pkg_add -r wine
__EOF

chroot ${DIR} /bin/sh chroot.sh
rm ${DIR}/chroot.sh
```

I changed the install directory to /usr/compat/i386 because my rootfs isn't large enough.

(You may want to add the devfs mount to your fstab).


----------



## vermaden (Jan 24, 2013)

@Carpetsmoker

Thanks for the update.


----------



## Carpetsmoker (Jan 25, 2013)

Here are tcsh aliases by the way:


```
alias winecfg "env LD_32_LIBRARY_PATH=/compat/i386/usr/local/lib PATH=/compat/i386/usr/local/bin:$PATH /compat/i386/usr/local/bin/winecfg"
alias wine32 "env LD_32_LIBRARY_PATH=/compat/i386/usr/local/lib PATH=/compat/i386/usr/local/bin:$PATH /compat/i386/usr/local/bin/wine"
```


----------

