Skip to content

Building Libraries for OF

denbeuteld edited this page Nov 15, 2022 · 30 revisions

This page has mostly been replaced by a more active kind of knowledge, embedded in the Apothecary build formulas. For example, here is the GLFW formula. Once Apothecary is released with openFrameworks, this page should be removed.

GLFW

OS X

  • download glfw
  • unzip it
> cd glfw-3.0
> mkdir build
> cd build
> cmake ../ -DGLFW_USE_CHDIR=0 -DGLFW_USE_MENUBAR=1 -DBUILD_SHARED_LIBS=0 -DGLFW_BUILD_EXAMPLES=0 -DGLFW_BUILD_TESTS=0 -DGLFW_BUILD_UNIVERSAL=0 -DCMAKE_OSX_ARCHITECTURES=i386 -DCMAKE_{C,CXX}_FLAGS=-m32
> make -j

OpenCV

iOS

Great iOS build generator ( used for 0071 release ): https://github.com/stephanepechard/iphone_opencv_test

Also load of opencv for ios tips here: http://computer-vision-talks.com/tag/opencv/ including premade builds.

OS X, VS2010, Windows C::B

  1. Download the latest version from the OpenCV SourceForge. OF 007 shipped with 2.2, as of this writing 2.3.1 has been tested with OF, and 2.4 looks promising.
  2. Unzip the files somewhere near your root. For this example I'll use /OpenCV-2.3.1. This helps make short paths when debug/error messages show up later.
  3. Start up CMake.
  4. For "where is the source code", use /OpenCV-2.3.1 and "where to build the binaries" is /OpenCV-2.3.1/build
  5. Select the 'grouped' and 'advanced' checkboxes.
  6. Under "WITH", deselect everything.
  7. Under "USE", select everything.
  8. Under "BUILD", deselect BUILD_SHARED_LIBS. This will make static libraries. You can also deselect anything related to building test/example apps to speed up compilation.
  9. Under "CMAKE" you might consider adding "-funroll-loops" to CMAKE_CXX_FLAGS_RELEASE and CMAKE_C_FLAGS_RELEASE so they look like -O3 -DNDEBUG -funroll-loops. Change CMAKE_BUILD_TYPE to "Release".
  10. Hit "Configure" then after it's done hit "Generate". CMake will ask what kind of project files you want to generate. Select the one relevant to the platform you're building for.
  11. Open up the generated project file in /OpenCV-2.3.1/build.
  12. (OS X only) There is a conflict in imgproc.hpp where "check" is defined as a macro by OS X. Add the line #undef check to the top of imgproc.hpp to fix this.
  13. Build the libraries.
  14. (Optional) Use some crazy tricks to bundle them into a single library... more on that another time.

NOTES for MINGW:

  • disable SSE / SSE 2
  • uncheck precompiled headers
  • check static CRT

POCO

OS X:

( the following builds 32bit static poco for OS X, without mysql as that is GPL and not a default library )

export ARCHFLAGS="-arch i386"
export POCO_TARGET_OSARCH="i386"
./configure --no-tests --no-samples --static --omit=Data/MySQL
make

iPhone:

1. Edit the file in build/config/iPhone

  • Uncomment out IPHONE_SDK_VERSION and set it equal to your SDK

  • Note: if you want to build for armv7 do: Set POCO_TARGET_OSARCH to be armv7

  • Close and Save the file.

2. Edit the file in build/config/iPhoneSimulator

  • Change POCO_TARGET_OSARCH to i386

  • Close and Save the file.

3. build Poco

cd back to the main folder and run these commands:

./configure --no-tests --no-samples --static --omit=Data/MySQL --omit=Data/SQLite --omit=Data/ODBC --omit=NetSSL_OpenSSL --omit=Crypto --config=iPhone
make

and

./configure --no-tests --no-samples --static --omit=Data/MySQL --omit=Data/SQLite --omit=Data/ODBC --omit=NetSSL_OpenSSL --omit=Crypto --config=iPhoneSimulator
make

4. Use lipo make a universal lib

run the following:

cd lib
lipo -c iPhoneOS/armv6/libPocoFoundation.a iPhoneOS/armv7/libPocoFoundation.a iPhoneSimulator/i386/libPocoFoundation.a -o PocoFoundation.a
lipo -c iPhoneOS/armv6/libPocoData.a iPhoneOS/armv7/libPocoData.a iPhoneSimulator/i386/libPocoData.a -o PocoData.a
lipo -c iPhoneOS/armv6/libPocoNet.a iPhoneOS/armv7/libPocoNet.a iPhoneSimulator/i386/libPocoNet.a -o PocoNet.a
lipo -c iPhoneOS/armv6/libPocoUtil.a iPhoneOS/armv7/libPocoUtil.a iPhoneSimulator/i386/libPocoUtil.a -o PocoUtil.a
lipo -c iPhoneOS/armv6/libPocoXML.a iPhoneOS/armv7/libPocoXML.a iPhoneSimulator/i386/libPocoXML.a -o PocoXML.a
lipo -c iPhoneOS/armv6/libPocoZip.a iPhoneOS/armv7/libPocoZip.a iPhoneSimulator/i386/libPocoZip.a -o PocoZip.a