Skip to content

Instantly share code, notes, and snippets.

@Alex4386
Last active April 9, 2024 09:09
Show Gist options
  • Save Alex4386/4cce275760367e9f5e90e2553d655309 to your computer and use it in GitHub Desktop.
Save Alex4386/4cce275760367e9f5e90e2553d655309 to your computer and use it in GitHub Desktop.
CodeWeavers CrossOver - How to compile from source! for macOS

[STOP] This gist is deprecated.

TL;DR

WAY MORE UP-TO-DATE GIST (and includes some setup stuff that I forgot to document): https://gist.github.com/sarimarton/471e9ff8046cc746f6ecb8340f942647
Current Development for Building Libre-version of CrossOver: https://github.com/GabLeRoux/macos-crossover-cloud-build.
For Latest Discussions: https://github.com/GabLeRoux/macos-crossover-cloud-build/issues.

Long Description

This version of gist is outdated since it was written while I was compiling CrossOver v19. and seems to be there are some breaking changes in v19.1+ and 20. Also, I think I missed some required libraries/stub files that was required in build (that I previously installed beforehand). Oops.

Please use the gist linked above for more information.

If you need compiled binary, @GabLeRoux did a fabulous job on building CD for Libre version of CrossOver using GitHub Actions at this repo.

This document will be stay here for archival purpose. Thanks for the updates! :D.

How to compile codeweavers crossover from source

If you have some money, try supporting wine development by supporting Crossover. (I did it)
They claim that they support the WineHQ project, and they seems to support the upstream WineGitRepoSearch

Installing Dependencies

To install, you need following dependencies to be installed on your Mac machine.

  • Xcode developer tools (Command Line)
  • cmake
  • gcc or clang to compile c codes.
  • bison >= 3.0 (can be upgraded via homebrew)
  • xquartz
  • flex
  • mingw-w64
  • pkgconfig

(If more dependencies are found, the list will be updated)

Getting the Source

Go to CodeWeavers CrossOver FOSS version Source and download the source.

This guide is strictly for Compiling on Mac. use command tar -xz whatever_the_filename_is.tar.gz to untar it.

Compiling LLVM

Go to llvm directory and create build directory with command mkdir build.

cd build to go there and run cmake ../ to configure build directory.
When cmake is done, you can run make to compile.
This will take a long time... Take your time and have a break.
(Build Time: 1h 25m 45s on 2018 Macbook Pro with intel Core i9 Processor)
now cd bin and add binaries to PATH via export PATH="$(pwd):$PATH".

Compiling Clang

Go to clang directory and create build directory with command mkdir build. (PATH setup from llvm required!!)

cd build to go there and run cmake ../ to configure build directory.
When cmake is done, you can run make to compile.
This will take some time... Take your time and have a break.
(Build Time: 34m 36s on 2018 Macbook Pro with intel Core i9 Processor)
now cd bin and add binaries to PATH via export PATH="$(pwd):$PATH".

Compiling Wine

The custom build of wine by codeweavers have special flag called --enable-win32on64.
Use that to when you setup with ./configure.

Use command CC="clang" CXX="clang++" ./configure --enable-win32on64
Then compile with make

@michaeldam
Copy link

Ok, thank you. Another thing is that I downloaded LLVM and Clang from the official websites, and compiled separately. Maybe that is why. I will try again.

It's literally at the top of this post 😁
"Go to CodeWeavers CrossOver FOSS version Source and download the source."
This wine build tree comes with the right LLVM and Clang.

Copy link

ghost commented Jun 7, 2020

Ok, thank you. Another thing is that I downloaded LLVM and Clang from the official websites, and compiled separately. Maybe that is why. I will try again.

It's literally at the top of this post 😁
"Go to CodeWeavers CrossOver FOSS version Source and download the source."
This wine build tree comes with the right LLVM and Clang.

As you can see in my replies, I did compile the included LLVM and Clang once specified. Since the website did not list those two as included sources, I did not think that they were custom compilers. Giving me answers to questions that have already been solved does not help.

@michaeldam
Copy link

michaeldam commented Jun 9, 2020

I compiled the bits and pieces from others and myself into a step-by-step that should work

Getting the source code

Get Codeweaver's Wine FOSS here:

https://www.codeweavers.com/products/more-information/source

untar it

Installing build prerequisites

To install brew packet manager issue (from the Brew site):

/bin/bash -c "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/master/install.sh)"

Next install the following packages:

brew install bison

The following PATH extension is required to make sure the latest bison is used over macOS' default:

export PATH=/usr/local/Cellar/bison/3.6.2/bin:$PATH
edit: ...probable better like this. Credits to @TellowKrinkle:
export PATH=$(brew --prefix bison):$PATH

brew install mingw-w64
brew install freetype

Compiling LLVM

Go to llvm directory and create build directory with command mkdir build.
cd build to go there and run cmake ../ to configure build directory.
When cmake is done, you can run make to compile.
This will take a long time... Take your time and have a break.
(Build Time: 1h 25m 45s on 2018 Macbook Pro with intel Core i9 Processor)
now cd bin and add binaries to PATH via export PATH="$(pwd):$PATH".

Compiling Clang

Go to clang directory and create build directory with command mkdir build. (PATH setup from llvm required!!)
cd build to go there and run cmake ../ to configure build directory.
When cmake is done, you can run make to compile.
This will take some time... Take your time and have a break.
(Build Time: 34m 36s on 2018 Macbook Pro with intel Core i9 Processor)
now cd bin and add binaries to PATH via export PATH="$(pwd):$PATH".

Compiling Wine

Go to wine directory

The custom build of wine by codeweavers have special flag called --enable-win32on64.
Use that too when you setup with ./configure.
Use command

CC="clang" CXX="clang++" MACOSX_DEPLOYMENT_TARGET=10.14 ./configure --enable-win32on64 -disable-winedbg --without-x --without-vulkan --disable-mscms

Then compile with

make

Cleanup

To cleanup ./configure targets issue:

make distclean

To clean up wine targets issue:

make clean

Allowing Windows apps to run

In the directory of the Windows executable issue:

sudo xattr -d com.apple.quarantine *

@AgentRG
Copy link

AgentRG commented Jun 10, 2020

@michaeldam How does disabling Mac's SIP differentiate from removing quarantine on an exe?

@TellowKrinkle
Copy link

export PATH=/usr/local/Cellar/bison/3.6.2/bin:$PATH

You can use export PATH=$(brew --prefix bison):$PATH so that even if Homebrew's bison gets updated to something higher than 3.6.2 the command will still work

How does disabling Mac's SIP differentiate from removing quarantine on an exe?

SIP prevents all applications running on your Mac from doing specific dangerous things (e.g. modifying system files)

Quarantine prevents unsigned applications downloaded from the internet from running at all. Unsurprisingly, windows applications aren't signed in a way macOS recognizes, so macOS prevents them from running. Removing the quarantine flag allows them to run. This is normally done by right-clicking, choosing Open, and then okaying the "OMG this thing could be dangerous" prompt, but since you can't run the windows application by right-clicking and choosing Open, you have to manually remove the quarantine flag.

@HarukaMa
Copy link

A few points:

For LLVM, you may add -DLLVM_TARGETS_TO_BUILD=X86 to cmake command line as most probably you only need x86 target when using this version.

For both LLVM and Clang, you may add -DCMAKE_BUILD_TYPE=Release to cmake command line to build an optimized version. Compiling those two components could be slower, but the actual compiling process should be much faster.

@kiding
Copy link

kiding commented Dec 4, 2020

Just to note: 20.0.1, 20.0.2 (and possibly later versions) do not contain the clang/llvm source codes. Use 20.0.0 or older versions.

@Molanda
Copy link

Molanda commented Dec 10, 2020

For me, brew --prefix bison returns /usr/local/opt/bison, so I had to use...

export PATH=$(brew --prefix bison)/bin:$PATH

@Molanda
Copy link

Molanda commented Dec 10, 2020

It seems the compiler is now picky about missing extern in the C code. I had to alter the configure statement to...

CROSSCFLAGS="-g -O2 -fcommon" CC="clang" CXX="clang++" MACOSX_DEPLOYMENT_TARGET=10.14 ./configure --enable-win32on64 -disable-winedbg --without-x --without-vulkan --disable-mscms

@firefinchdev
Copy link

Go to llvm directory and create build directory with command mkdir build.
cd build to go there and run cmake ../ to configure build directory.

Which one is the LLVM directory?

@ryandesign
Copy link

Which one is the LLVM directory?

The directory called "llvm" that is inside the the directory that is created when you decompress the crossover 20.0.0 tarball. As noted above, 20.0.1 and later no longer include the llvm directory so they cannot be used for this step.

@firefinchdev
Copy link

The directory called "llvm" that is inside the the directory that is created when you decompress the crossover 20.0.0 tarball. As noted above, 20.0.1 and later no longer include the llvm directory so they cannot be used for this step.

Thanks. I was using 20.0.2 (latest) and llvm directory was not there. Using 20.0.0 now.

@GabLeRoux
Copy link

GabLeRoux commented Dec 21, 2020

Based on related gists, I created this repository:
https://github.com/GabLeRoux/macos-crossover-cloud-build

The CI build fails, but script works fine (still getting build issues). There's a couple issues which you can contribute to if you want. I find it more convenient to use repositories instead of gists as it's easier to contribute.

@sarimarton
Copy link

It's a great idea, thanks @GabLeRoux

@cutie-lyta
Copy link

I may be late, but you can add something really important for speed
Instead of make
make -j4or another number, it's the number of core that make uses
It really speed up the process a lot, it take the normal time, divided by the number, almost

@Alex4386
Copy link
Author

I may be late, but you can add something really important for speed
Instead of make
make -j4or another number, it's the number of core that make uses
It really speed up the process a lot, it take the normal time, divided by the number, almost

I thought it was kind of obvious of using -j`nproc` or equivalent but kudos for you. Next time, I will add that in the future build guide.

By the way, this gist is deprecated.
Please visit the updated gist on top of this gist. Thank you!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment