ofnode / of

CMake openFrameworks for Linux, OS X and Windows.
71 stars 14 forks source link

Failed to build on OSX Mojave #23

Open koreus7 opened 5 years ago

koreus7 commented 5 years ago

Fresh install of Mojave 10.14.6 Installed Xcode, developer tools and brew.

brew install opencv@2 --c++11 --without-python --without-numpy --without-test

Failed so I installed open cv without any flags.

Then I did

brew install cmake
brew install pkgconfig
brew install libffi
export PKG_CONFIG_PATH="/usr/local/opt/libffi/lib/pkgconfig"
export LDFLAGS="-L/usr/local/opt/libffi/lib"
mkdir build
cd build
cmake .. -G Ninja
ninja
[24/706] Building CXX object CMakeFiles/openFrameworks.dir/src/openframeworks/graphics/ofImage.cpp.o
FAILED: CMakeFiles/openFrameworks.dir/src/openframeworks/graphics/ofImage.cpp.o
/Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/c++  -DBOOST_ALL_NO_LIB -DBOOST_FILESYSTEM_DYN_LINK -DBOOST_SYSTEM_DYN_LINK -DFREEIMAGE_LIB -DGLEW_NO_GLU -DGLEW_STATIC -DHAVE_GETTIMEOFDAY -DOF_SOUNDSTREAM_RTAUDIO -DOF_SOUND_PLAYER_OPENAL -DOF_USING_MPG123 -DPOCO_STATIC -D__MACOSX_CORE__ -DopenFrameworks_EXPORTS -I../src/openframeworks -I../src/openframeworks/3d -I../src/openframeworks/app -I../src/openframeworks/communication -I../src/openframeworks/events -I../src/openframeworks/gl -I../src/openframeworks/graphics -I../src/openframeworks/math -I../src/openframeworks/sound -I../src/openframeworks/types -I../src/openframeworks/utils -I../src/openframeworks/video -I../src/freeimage/Source -I../src/freeimage/Source/LibJPEG -I../src/freeimage/Source/LibOpenJPEG -I../src/freeimage/Source/LibPNG -I../src/freeimage/Source/LibRawLite -I../src/freeimage/Source/LibTIFF4 -I../src/freeimage/Source/LibJXR -I../src/freeimage/Source/LibJXR/jxrgluelib -I../src/freeimage/Source/LibJXR/image -I../src/freeimage/Source/LibJXR/image/encode -I../src/freeimage/Source/LibJXR/image/sys -I../src/freeimage/Source/LibJXR/image/x86 -I../src/freeimage/Source/LibJXR/image/decode -I../src/freeimage/Source/LibJXR/common -I../src/freeimage/Source/LibJXR/common/include -I../src/freeimage/Source/LibWebP -I../src/freeimage/Source/OpenEXR -I../src/freeimage/Source/OpenEXR/Half -I../src/freeimage/Source/OpenEXR/Iex -I../src/freeimage/Source/OpenEXR/IexMath -I../src/freeimage/Source/OpenEXR/IlmImf -I../src/freeimage/Source/OpenEXR/IlmThread -I../src/freeimage/Source/OpenEXR/Imath -I../src/glew -I../src/glew/include -I../src/glfw -I../src/glfw/include -I../src/glfw/include/GLFW -I../src/kissfft -I../src/kissfft/tools -I../src/libtess2 -I../src/libtess2/Include -I../src/libtess2/Source -I../src/poco -I../src/poco/Crypto/include -I../src/poco/Foundation/include -I../src/poco/Net/include -I../src/poco/NetSSL_OpenSSL/include -I../src/poco/Util/include -I../src/poco/XML/include -I../src/poco/Zip/include -I../src/rtaudio -I../src/rtaudio/include -I../src/utf8cpp -I../src/utf8cpp/include -I/usr/local/include/freetype2 -I/usr/local/Cellar/libffi/3.2.1/lib/libffi-3.2.1/include -I/usr/local/Cellar/cairo/1.16.0_2/include/cairo -I/usr/local/Cellar/glib/2.62.0/include -I/usr/local/Cellar/glib/2.62.0/include/glib-2.0 -I/usr/local/Cellar/glib/2.62.0/lib/glib-2.0/include -I/usr/local/opt/gettext/include -I/usr/local/Cellar/pcre/8.43/include -I/usr/local/Cellar/pixman/0.38.4/include/pixman-1 -I/usr/local/Cellar/fontconfig/2.13.1/include -I/usr/local/opt/freetype/include/freetype2 -I/usr/local/Cellar/libpng/1.6.37/include/libpng16 -F/Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.14.sdk/System/Library/Frameworks -I/usr/local/opt/openssl/include -I/usr/local/Cellar/mpg123/1.25.12/include -I../src/poco/JSON/include -isystem /usr/local/include -fcolor-diagnostics -std=c++1y -O3 -DNDEBUG -Wno-narrowing -Wno-deprecated-declarations -Wno-switch -Wno-ignored-attributes -Wno-deprecated-register  -isysroot /Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.14.sdk -fPIC   -g1 -x objective-c++ -MD -MT CMakeFiles/openFrameworks.dir/src/openframeworks/graphics/ofImage.cpp.o -MF CMakeFiles/openFrameworks.dir/src/openframeworks/graphics/ofImage.cpp.o.d -o CMakeFiles/openFrameworks.dir/src/openframeworks/graphics/ofImage.cpp.o -c ../src/openframeworks/graphics/ofImage.cpp
In file included from ../src/openframeworks/graphics/ofImage.cpp:5:
../src/freeimage/Source/FreeImage.h:153:17: error: typedef redefinition with different types ('int32_t' (aka 'int') vs 'signed char')
typedef int32_t BOOL;
                ^
/Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.14.sdk/usr/include/objc/objc.h:81:25: note: previous definition is here
    typedef signed char BOOL;
                        ^
1 error generated.
[33/706] Building CXX object CMakeFiles/openFrameworks.di...eeimage/Source/OpenEXR/IlmImf/ImfMultiPartInputFile.cpp.o
ninja: build stopped: subcommand failed.

If I remove the typedef from FreeImage.h then I get errors complaining that BOOL is not defined. Which is conflicting because according to ninja/cmake it is defined twice so removing one definition should still leave it defined.

MatthewScholefield commented 5 years ago

Hmm, looks like that problem is related to this issue from 10 years ago. Perhaps we could fix this by upgrading freeImage, but I'm not that sure.

koreus7 commented 5 years ago

The fix in that issue seems to be replacing the typedef with a define

typedef int32_t BOOL;

Replaced by:

#define BOOL int32_t

In any case I suppose there is a version of free image which is compatible with the latest OSX.

koreus7 commented 5 years ago

I just diffed the FreeImage header from the latest OF distribution (which compiles on my machine) and the one here.

Screenshot 2019-09-15 at 15 28 58

I'm not sure what is being done here https://github.com/openframeworks/apothecary/blob/master/apothecary/formulas/FreeImage/FreeImage.sh to get this version of the header but the result is here http://ci.openframeworks.cc/libs/0.10.1/openFrameworksLibs_master_osx1.tar.bz2

koreus7 commented 5 years ago

OF 10.1 is using a patched branch of FreeImage

GIT_URL=https://github.com/danoli3/FreeImage
GIT_TAG=3.17.0-header-changes

with the headers fixed for OSX

I tried to build against that version and got:

Undefined symbols for architecture x86_64:
  "InitJXR(Plugin*, int)", referenced from:
      _FreeImage_Initialise in Plugin.cpp.o

Seems similar (though possibly not related) this this issue: https://github.com/openframeworks/openFrameworks/issues/4385