FaceGen SDK Manual - Compile

Windows

Visual Studio:

~sdk/source/VisualStudio2019.sln
~sdk/source/VisualStudio2022.sln

Linux

Make a copy of the appropriate file below as just 'Makefile'. Make any desired modifications (eg. specific architecture flags such as those for AVX or NEON) then 'make':

~sdk/source/Makefile_linux_arm8_clang_*
~sdk/source/Makefile_linux_arm8_gcc_*
~sdk/source/Makefile_linux_arm8_icpc_*
~sdk/source/Makefile_linux_x64_clang_*
~sdk/source/Makefile_linux_x64_gcc_*
~sdk/source/Makefile_linux_x64_icpc_*

MacOS

Ensure Xcode Command Line Tools are installed.

Make a copy of the appropriate file below as just 'Makefile'. Make any desired modifications then 'make':

~sdk/source/Makefile_macos_x64_clang_debug
~sdk/source/Makefile_macos_x64_clang_release

CMake

CMake files are included for integration into other build systems.

~sdk/source/CMakeLists.txt
~sdk/source/*/CMakeLists.txt

Android

Using Android Studio, on any platform:

  1. Create a project prj with native C++17 (or greater) support
  2. From a clean copy of the FaceGen SDK, copy each of the following library directories from ~sdk/source/
  3. And paste into your Android project C++ directory: ~prj/app/src/main/cpp/
  4. Edit ~prj/app/src/main/cpp/CMakeLists.txt
    • After project(...) , add the following line for each library directory above, in the given order:
      • add_subdirectory(LibXXX)
    • After add_library(prj ...) , add the line:
      • target_include_directories(prj PUBLIC LibFgXXX)
    • Where LibFgXXX is one of:
      • LibFgBase (open source)
      • LibFg3Main (main SDK)
      • LibFg3Full (full SDK)
    • Also add LibFgXXX to the list of target_link_libraries(prj ...)
  5. Create an assets folder: File -> New -> Folder -> Assets Folder -> main
  6. Within that directory ( ~prj/app/src/main/assets ) create a facegen subdirectory. Into that, copy the data you need from ~sdk/data (see Deployment), preserving the subdirectory structure.
  7. Since Android asset files cannot be accessed via standard filesystem calls, make a local filesystem copy of this facegen subdirectory when your app first runs (example code at ~sdk/source/android/AssetLoaderKotlin.kt ). This code returns the full path to the local filesystem copy of the FaceGen data. Pass that path to Fg::setDataDir() before using the SDK (example code at ~sdk/source/android/native-lib.cpp ).
  8. Since FaceGen uses C++ exceptions, you should bracket use of FaceGen with try / catch.

iOS

Using Xcode:

  1. Create a new iOS App project ~prj
  2. Select the target (~prj/prj) and File -> 'Add Files to' to add each of the following directories from ~sdk/source, making sure to deselect all 'add to targets' checkboxes:
    • LibTpEigen
    • LibTpStb
    • LibFgBase
    • LibFg3Main (main SDK)
    • LibFg3Photofit (full SDK)
    • LibFg3Full (full SDK)
  3. For the prj target -> Build Settings -> Search Paths -> System Header Search Paths add:
    • ${SRCROOT}/prj/LibTpEigen/
    • ${SRCROOT}/prj/LibTpStb/
    • ${SRCROOT}/prj/LibFgBase/src/
    • ${SRCROOT}/prj/LibFg3Main/ (main SDK)
    • ${SRCROOT}/prj/LibFg3Photofit/ (full SDK)
    • ${SRCROOT}/prj/LibFg3Full/ (full SDK)
  4. For the prj target -> Build Phases -> Compile Sources, add from ~prj/prj/ :
    • LibFgBase/src/*
    • LibFgBase/src/nix/*
    • LibFg3Main/*.cpp *.hpp *.h (main SDK)
    • LibFg3Photofit/*.cpp *.hpp *.h (full SDK)
    • LibFg3Full/*.cpp *.hpp *.h (full SDK)
  5. Right-click ~prj/prj , select New Group and add facegen
  6. Right-click ~prj/prj/facegen , select Add Files to , and select the data you need (see Deployment), from ~sdk/data , preserving the directory structure. Make sure to de-select Add to targets .
  7. At runtime, make a copy of the above directory in the sandbox, and pass the path for that sandbox directory to Fg::setDataDir()
  8. Since FaceGen uses C++ exceptions, you should bracket FaceGen interfaces with try / catch.