Skip to content

Commit

Permalink
Merge pull request #2 from JesusAnaya/macosx-dev
Browse files Browse the repository at this point in the history
Fixed issues compiling with Xcode 14 in MacOSX Ventura and  Intel processor.
  • Loading branch information
GustavoSilvera authored Jan 12, 2023
2 parents 470d92b + 20fb458 commit 9607eca
Show file tree
Hide file tree
Showing 5 changed files with 41 additions and 8 deletions.
3 changes: 3 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ Util/Build
Install
Plugins
!Unreal/CarlaUE4/Plugins
cmake-build-debug

/ExportedMaps
/Import/*
Expand Down Expand Up @@ -47,3 +48,5 @@ _out*
_site
core
profiler.csv
CarlaUE4.xcworkspace
OptionalModules.ini
37 changes: 35 additions & 2 deletions Docs/build_mac.md
Original file line number Diff line number Diff line change
Expand Up @@ -25,9 +25,23 @@ brew update && brew upgrade

brew install --build-from-source mono

brew install coreutils ninja wget autoconf automake curl libtool libpng aria2 libiconv
brew install coreutils ninja wget autoconf automake curl libtool aria2 libiconv

# Media libraries
brew install libpng webp libtiff little-cms2 jpeg-turbo
```

IMPORTANT FOR M1 ONLY:

Set some necessary flags to link the installed libraries from a brew with the clang compiler in the M1 architecture. This step is not required for Intel.

```
export CPATH=/opt/homebrew/include
export LIBRARY_PATH=/opt/homebrew/lib
```

And save them to your `~/.zshrc` or `~/.bashrc` configuration files.

I recommend installing python through conda on mac:
```bash
conda create --name carla python=3.8
Expand Down Expand Up @@ -59,6 +73,9 @@ cd /PATH/TO/UnrealEngine
# then finally build UE4
xcodebuild -scheme UE4 -target UE4 -UseModernBuildSystem=YES # this takes a while to complete

# for Xcode 14 do:
xcodebuild -scheme UE4 -target UE4 -UseModernBuildSystem=YES GENERATE_INFOPLIST_FILE=YES

# make sure to add the right UnrealEngine path as UE4_ROOT:
export UE4_ROOT=/PATH/TO/UnrealEngine # or add it in your .zshrc
```
Expand Down Expand Up @@ -138,4 +155,20 @@ Also, as an aside, since (almost) all the PythonAPI scripts look for a `'linux-x
export PYTHONPATH="${PYTHONPATH}:/PATH/TO/CARLA/PythonAPI/carla/dist/carla-0.9.13-py3.8-macosx-11.0-arm64.egg"
# I simply put this in my .zshrc file
```
Then you should be able to quickly `import carla` without hassle!
Then you should be able to quickly `import carla` without hassle!

After running `make package`, a building project is created. You can find this build in the path:

```
/path/to/carla/Dist/CARLA_Shipping_0.9.13-...-dirty/MacNoEditor/
```

This folder can be moved to another place if you prefer.

The build folder includes the compiled server app for Mac `CarlaUE4-Mac-Shipping.app`.

To run the server in headless mode, to be used by a client, you can run the following command in the terminal. This mode loads faster, and it delays around 20 seconds to be ready for the client:

```
open CarlaUE4-Mac-Shipping.app --args -RenderOffScreen
```
5 changes: 1 addition & 4 deletions PythonAPI/carla/setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -94,10 +94,7 @@ def walk(folder, file_filter='*'):
extra_link_args += ['-ljpeg', '-ltiff']
extra_compile_args += ['-DLIBCARLA_IMAGE_WITH_PNG_SUPPORT=false']
else:
if is_mac:
extra_link_args += ['-lpng'] # TODO: find a suitable MacOS replacement for libjpeg and libtiff
else:
extra_link_args += ['-lpng', '-ljpeg', '-ltiff']
extra_link_args += ['-lpng', '-ljpeg', '-ltiff']
extra_compile_args += ['-DLIBCARLA_IMAGE_WITH_PNG_SUPPORT=true']
# @todo Why would we need this?
# include_dirs += ['/usr/lib/gcc/x86_64-linux-gnu/7/include']
Expand Down
2 changes: 1 addition & 1 deletion Util/BuildTools/BuildCarlaUE4.sh
Original file line number Diff line number Diff line change
Expand Up @@ -161,7 +161,7 @@ if ${BUILD_CARLAUE4} ; then

log "Build CarlaUE4 project."
if ${MAC_OS}; then
xcodebuild -scheme CarlaUE4 -target CarlaUE4Editor -UseModernBuildSystem=YES
xcodebuild -scheme CarlaUE4 -target CarlaUE4Editor -UseModernBuildSystem=YES GENERATE_INFOPLIST_FILE=YES
else
make CarlaUE4Editor
fi
Expand Down
2 changes: 1 addition & 1 deletion Util/BuildTools/Setup.sh
Original file line number Diff line number Diff line change
Expand Up @@ -442,7 +442,7 @@ XERCESC_VERSION=3.2.3
XERCESC_BASENAME=xerces-c-${XERCESC_VERSION}

XERCESC_TEMP_FOLDER=${XERCESC_BASENAME}
XERCESC_REPO=https://ftp.cixug.es/apache//xerces/c/3/sources/xerces-c-${XERCESC_VERSION}.tar.gz
XERCESC_REPO=https://archive.apache.org/dist/xerces/c/3/sources/xerces-c-${XERCESC_VERSION}.tar.gz

XERCESC_SRC_DIR=${XERCESC_BASENAME}-source
XERCESC_INSTALL_DIR=${XERCESC_BASENAME}-install
Expand Down

0 comments on commit 9607eca

Please sign in to comment.