XCode 6.4 breaks Project with zipzap dependency - ios7

Up until I upgraded to XCode 6.4 the project was working fine but after the upgrade I have boiled down the build failure to zipzap.
Using CocoaPod 0.37.2
pod 'zipzap', '~> 8.0'
Linked Frameworks and Libraries = libz.1.2.5.dylib
Targeting iOS 7.0 +
Build Failure
Undefined symbols for architecture arm64:
"___cxa_begin_catch", referenced from:
___clang_call_terminate in libPods-Ally-zipzap.a(ZZArchive.o)
"std::terminate()", referenced from:
___clang_call_terminate in libPods-Ally-zipzap.a(ZZArchive.o)
"___gxx_personality_v0", referenced from:
+[ZZArchive archiveWithURL:error:] in libPods-Ally-zipzap.a(ZZArchive.o)
+[ZZArchive archiveWithData:error:] in libPods-Ally-zipzap.a(ZZArchive.o)
-[ZZArchive initWithURL:options:error:] in libPods-Ally-zipzap.a(ZZArchive.o)
-[ZZArchive initWithData:options:error:] in libPods-Ally-zipzap.a(ZZArchive.o)
-[ZZArchive initWithChannel:options:error:] in libPods-Ally-zipzap.a(ZZArchive.o)
-[ZZArchive loadCanMiss:error:] in libPods-Ally-zipzap.a(ZZArchive.o)
-[ZZArchive updateEntries:error:] in libPods-Ally-zipzap.a(ZZArchive.o)
...
ld: symbol(s) not found for architecture arm64
Things I have done so far
For both the Project and the Pods project: Build Settings > C++ Standard Library = libstdc++ (originally was libc++)
couple of times pod deintegrate && rm *.lock && pod install

I've experienced this issue as well - the ZipZap podspec has been updated losing a number of compiler flags in the process:
https://github.com/pixelglow/ZipZap/commit/0e4e6aa885196640ca86462c6748e68a50c66ee9
The way I resolved this in my project was to restore the compiler flags (that were present before the update) as follows:
Navigate to the Pods project in your workspace
Select the Pods-zipzap target
Select the Build Phases tab
Expand the Compile Sources section
Select all the Objective-C++ files (with the extension .mm) - hold the CMD key to select multiple files
Add the compiler flags: -fno-objc-exceptions -fno-exceptions -std=c++11 -stdlib=libc++ -DOS_OBJECT_USE_OBJC=0
Select all Objective-C files (.m) except Pods-zipzap-dummy.m
Add the compiler flags: -fno-objc-exceptions -std=c99 -DOS_OBJECT_USE_OBJC=0
Select the one C++ file (.cpp)
Add the compiler flags: -fno-exceptions -std=c++11 -stdlib=libc++ -DOS_OBJECT_USE_OBJC=0
If you have a test target you will likely need to add the same flags there as well. All being well you should now be able to build again.
[Update]: Upgrading Cocoapods to version 0.38.0 will also resolve the errors but may result in compile errors currently with ZipZap 8.0.4 - see https://github.com/pixelglow/ZipZap/issues/105.
Alternatively, you could rollback to ZipZap 8.0.3 in your Podfile.

Related

How do I tell meson setup about the location of a dependency?

I'm trying to build celluloid, which uses meson. I ran meson, but it failed to find an appropriate version of mpv:
Determining dependency 'mpv' with pkg-config executable '/usr/bin/pkg-config'
Called `/usr/bin/pkg-config --modversion mpv` -> 1
Found CMake: /usr/bin/cmake (3.13.4)
Determining dependency 'mpv' with CMake executable '/usr/bin/cmake'
Try CMake generator: auto
Called `/usr/bin/cmake --trace-expand -DNAME=mpv .` in /tmp/celluloid-0.20/build/meson-private/cmake_mpv -> 0
Dependency mpv found: NO (tried pkgconfig and cmake)
src/meson.build:125:0: ERROR: Dependency "mpv" not found, tried pkgconfig and cmake
so I downloaded and built the latest mpv release (0.33.0), built and installed it at /opt/mpv.
Now - how do I tell meson to take mpv from this new path?
Note: The relevant snippet of the meson files seems to be:
executable('celluloid', sources,
dependencies: [
libgtk,
libgio,
meson.get_compiler('c').find_library('m', required: false),
dependency('mpv', version: '>= 1.107'),
dependency('epoxy')
],
link_with: extra_libs,
include_directories: includes,
c_args: cflags,
install: true
)
You tell meson about your dependency by letting pkgconfig know about your dependency...
and that can be done by adding your dependency's path to the PKG_CONFIG_PATH environment variable; it is delimited by colons, just like PATH, e.g. /opt/foo:/opt/extra/baz.
Remember that you may also need to add associated paths to LD_LIBRARY_PATH after building and installing with a custom-built directory.

Unable to link against Boost.Python on OS X

I am trying to build a really trivial example with Boost.Python. I have installed boost and boost-python with homebrew. I am using python 3.4.3 and boost 1.59. My OS is El Capitan.
Boost.Python was installed with python3 like this:
brew install boost-python --with-python3
I have 3 files:
/* greet.hpp */
#ifndef BOOSTPYTHONHELLOWORLD_GREET_HPP
#define BOOSTPYTHONHELLOWORLD_GREET_HPP
char const* greet();
#endif //BOOSTPYTHONHELLOWORLD_GREET_HPP
/* greet.cpp */
#include "greet.hpp"
char const* greet()
{
return "Hello world";
}
/* greet_ext.cpp */
#include "greet.hpp"
#include <boost/python.hpp>
BOOST_PYTHON_MODULE(greet_ext)
{
using namespace boost::python;
def("greet", greet);
}
My CMakeLists.txt file looks like this:
cmake_minimum_required(VERSION 3.3)
project(BoostPythonHelloWorld)
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -std=c++11")
set(PYTHON_LIBRARY "/usr/local/Cellar/python3/3.4.3/Frameworks/Python.framework/Versions/3.4/lib/libpython3.4m.dylib")
set(PYTHON_INCLUDE_DIR "/usr/local/Cellar/python3/3.4.3/Frameworks/Python.framework/Versions/3.4/include/python3.4m")
FIND_PACKAGE(PythonLibs 3.4 REQUIRED)
FIND_PACKAGE(Boost COMPONENTS python)
if(NOT WIN32)
add_definitions(-DBOOST_ALL_DYN_LINK=1)
add_definitions(-DBOOST_TEST_DYN_LINK)
endif()
INCLUDE_DIRECTORIES(${Boost_INCLUDE_DIRS} ${PYTHON_INCLUDE_DIRS})
add_library(greet SHARED greet.cpp)
add_library(greet_ext SHARED greet_ext.cpp)
target_link_libraries(greet_ext greet)
target_link_libraries(greet_ext ${PYTHON_LIBRARIES})
target_link_libraries(greet_ext ${Boost_LIBRARIES})
set_target_properties(greet_ext PROPERTIES PREFIX "")
When I run CMake it finds all the correct python libraries (because I specified them manually as you can see in the file above).
During build I get the following link error:
Scanning dependencies of target greet
[ 25%] Building CXX object CMakeFiles/greet.dir/greet.cpp.o
[ 50%] Linking CXX shared library libgreet.dylib
[ 50%] Built target greet
Scanning dependencies of target greet_ext
[ 75%] Building CXX object CMakeFiles/greet_ext.dir/greet_ext.cpp.o
[100%] Linking CXX shared library greet_ext.dylib
Undefined symbols for architecture x86_64:
"boost::python::detail::init_module(PyModuleDef&, void (*)())", referenced from:
_PyInit_greet_ext in greet_ext.cpp.o
ld: symbol(s) not found for architecture x86_64
clang: error: linker command failed with exit code 1 (use -v to see invocation)
make[2]: *** [greet_ext.dylib] Error 1
make[1]: *** [CMakeFiles/greet_ext.dir/all] Error 2
make: *** [all] Error 2
Anyone have any idea why this is happening?
EDIT
If I link against Python 2.7 it works, which means boost-python was built against python 2.7 instead of 3.4, even though I specified the --with-python3 options..
So, the questions is, how to build boost-python against python 3.4?
The solution I am currently using is to reinstall boost-python without python 2.7 support.
The steps I took were:
Uninstall boost-python if already installed: brew uninstall boost-python.
Install boost-python with python3 support but without python 2.7 support: brew install boost-python --with-python3 --without-python.
In order to use boost-python with python 3 you need to change this in your CMakeLists.txt:
FIND_PACKAGE(Boost COMPONENTS python)
to this:
FIND_PACKAGE(Boost COMPONENTS python3)
That way you can recompile boost with python 2 support and still use python 3.
I'd suggest installing boost-python3 via brew.
You still need to give the minor version number as well and possibly the library path. The following worked for me:
BOOST_LIBRARYDIR=/usr/local/Cellar/boost-python3/1.67.0/lib cmake ..
with CMakeLists.txt (located in ..) containing
FIND_PACKAGE(Boost COMPONENTS python36)
(for Boost 1.67.0 and Python 3.6, obviously).

j2objc Compile error: Undefined symbols for architecture arm64:

i get the following error when i run j2objcc -o blssmibi BLSSMIBI.o
Undefined symbols for architecture x86_64:
"_OBJC_CLASS_$_Curve", referenced from:
objc-class-ref in BLSSMIBI.o
ld: symbol(s) not found for architecture x86_64
clang: error: linker command failed with exit code 1 (use -v to see invocation)
what should i do to fix this?
There's no Curve class anywhere in j2objc's libraries, so my guess it's a dependency from the Java file that you used to generate BLSSMIBI (maybe that's the it looks like a package prefix was used). If you aren't sure what a class's dependencies are, try compiling with javac to a temporary directory and see what name.class files are created (ignore the ones with $ in their names, as they're inner classes). That list of class files is used to figure out all the classes that need transpiling, as well as all the .o files that the app requires.

clang error: linker command failed, XCode 4.2 command-line app

I am learning objective-c and XCode using Stephen Kochan's book. For one of the assignments, I needed to implement an AddressBook lookup feature from the command line. I used two classes from a previous project, added the files and did not make a copy. All builds fine in XCode, but when I issue the following command at the command line:
clang -fobjc-arc -framework Foundation main.m -o ch19
I get the error:
Undefined symbols for architecture x86_64:
"_OBJC_CLASS_$_AddresBook", referenced from:
objc-class-ref in cc-bx2cgt.o
"_OBJC_CLASS_$_AddressCard", referenced from:
objc-class-ref in cc-bx2cgt.o
ld: symbol(s) not found for architecture x86_64
clang: error: linker command failed with exit code 1 (use -v to see invocation)
No typo in AddresBook, my class name has one "s". I tried removing the files (AddresBook.h and .m and AddressCard.h and .m) from my project, adding them with and without copying. Building and running the app in XCode works just fine.
How can I "clear" out the references and add them again so that I can compile it from the command line?
Thank you.
You need to add those other files object codes.
clang -fobjc-arc -framework Foundation main.m AddressBook.m -o ch19 or compile them to object files and then link them.
You should also be using xcodebuild for this, if you want to do it on the command line.

Build static Graphviz libraries for iOS

I am trying build the static libraries for Graphviz to include them in in an iOS app, but I can't get it to work. Here's what I have done so far, using graphviz 2.28.0], Xcode 4.1, OSX 10.7 and I am targeting the iOS simulator.
I found Glen Low's configure instructions, and with some informed guesswork updated these to:
./configure --build=i486-apple-darwin --host=arm-apple-darwin9 --disable-dependency-tracking --enable-shared=no --enable-static=yes --enable-ltdl-install=no --enable-ltdl=no --enable-swig=no --enable-tcl=no --with-codegens=no --with-fontconfig=no --with-freetype2=no --with-ipsepcola=yes --with-libgd=no --with-quartz=yes --with-visio=yes --with-x=no --with-cgraph=no CC="/Developer/Platforms/iPhoneOS.platform/Developer/usr/bin/gcc-4.2" CPP="/Developer/Platforms/iPhoneOS.platform/Developer/usr/bin/gcc-4.2 -E" CXX="/Developer/Platforms/iPhoneOS.platform/Developer/usr/bin/g++-4.2" CXXCPP="/Developer/Platforms/iPhoneOS.platform/Developer/usr/bin/g++-4.2 -E" OBJC="/Developer/Platforms/iPhoneOS.platform/Developer/usr/bin/gcc-4.2" LD="/Developer/Platforms/iPhoneOS.platform/Developer/usr/bin/ld" CPPFLAGS="-arch armv6 -isysroot /Developer/Platforms/iPhoneOS.platform/Developer/SDKs/iPhoneOS4.3.sdk -miphoneos-version-min=4.0" CXXCPPFLAGS="-arch armv6 -isysroot /Developer/Platforms/iPhoneOS.platform/Developer/SDKs/iPhoneOS4.3.sdk -miphoneos-version-min=4.0"
This works, but then the "make" runs for a while and errors out with:
Making all in gvpr
CCLD mkdefs
ld: warning: ignoring file mkdefs.o, file was built for armv6 which is not the architecture being linked (i386)
ld: warning: ignoring file /usr/local/lib/libSystem.dylib, missing required architecture i386 in file
ld: warning: symbol dyld_stub_binder not found, normally in libSystem.dylib
Undefined symbols for architecture i386:
"_exit", referenced from:
start in crt1.10.6.o
"_main", referenced from:
start in crt1.10.6.o
ld: symbol(s) not found for architecture i386
collect2: ld returned 1 exit status
make[3]: *** [mkdefs] Error 1
make[2]: *** [all-recursive] Error 1
make[1]: *** [all-recursive] Error 1
make: *** [all] Error 2
I don't quite understand all the architecture specifications, so any help to get this to work is most welcome.
Problem is imo that mkdefs is executed during the build process itself after it was created. So if you build for armv6 or armv7 the file can't be executed on the command line of Mac OS X. My workaround was to build a mkdefs for architecture i386 (which is needed for the iPhone simulator too) and copy it in the lib/gvpr directory after getting this error. Make sure that the file could not be overwritten and restart the build.
I got this working. The build script fails at the end when it tried to make an executable since it's compiled for i386 instead of x86 or x86_64 but all the libraries build just fine.
# For iPhoneOS
export DEV_iOS=/Developer/Platforms/iPhoneOS.platform/Developer
export SDK_iOS=${DEV_iOS}/SDKs/iPhoneOS5.0.sdk
export COMPILER_iOS=${DEV_iOS}/usr/bin
export CC=${COMPILER_iOS}/gcc
export CXX=${COMPILER_iOS}/g++
export LDFLAGS="-arch armv7 -pipe -Os -gdwarf-2 -no-cpp-precomp -mthumb -isysroot ${SDK_iOS}"
export CFLAGS=${LDFLAGS}
export CXXFLAGS=${LDFLAGS}
export LD=${COMPILER_iOS}/ld
export CPP=${COMPILER_iOS}/llvm-cpp-4.2
export AR=${COMPILER_iOS}/ar
export AS=${COMPILER_iOS}/as
export NM=${COMPILER_iOS}/nm
export CXXCPP=${COMPILER_iOS}/llvm-cpp-4.2
export RANLIB=${COMPILER_iOS}/ranlib
./configure --host=arm-apple-darwin11 --disable-dependency-tracking --enable-shared=no --enable-static=yes --enable-ltdl-install=no --enable-ltdl=no --enable-swig=no --enable-tcl=no --with-codegens=no --with-fontconfig=no --with-freetype2=no --with-ipsepcola=yes --with-libgd=no --with-quartz=yes --with-visio=yes --with-x=no --with-cgraph=no
It appears that the linker is trying to link to the system libraries installed on your Mac. Those libraries are all going to be compiled for i386 or x86_64 which isn't going to work when compiling libraries for iPhone. You'll need to reconfigure the linker to link against the libraries that come in the iPhone SDK.
It should also be noted that you will probably have to compile the library twice - once as armv6 and again as armv7. iPhone 3G and some of the older iPod Touches use the armv6 architecture, while newer iPhones use the armv7 architecture. After you've compiled the libraries under both architectures you can use lipo (type "man lipo" in your Terminal for more info) to create a single static library with both architectures in it. If you are going to develop your app using the iPhone/iPad simulator, then I also suggest compiling once as i386 so that you can use your library with the simulator. Again, lipo can create a single static library with all 3 architectures in it.
Now the GraphViz website appears to be unreachable at the moment, so I could not download the library and run the configure script like you did, but I suspect that before you run "make" you should make the following changes to the makefile that is produced by the configure script. Depending on which version of the iOS SDK you are targeting and what version of gcc you have on your machine you may have to tweak some of the changes below so they are appropriate for your environment. The instructions below will build for armv6. You'll need to change the settings to build for armv7 once you are ready to tackle that architecture.
Find CC= cc and change it to:
CC= /Developer/Platforms/iPhoneOS.platform/Developer/usr/bin/gcc-4.2
Find -arch i386 in CFLAG and change it to:
-arch armv6
Find CFLAG and add to the BEGINNING!!:
-isysroot /Developer/Platforms/iPhoneOS.platform/Developer/SDKs/iPhoneOS4.0.sdk
Find SHARED_LDFLAGS=-arch i386 -dynamiclib and change it to:
SHARED_LDFLAGS=-arch armv6 -dynamiclib