libcocos2d tvOS.a(bio_lib.o)' does not contain bitcode - xcode

When compiling cocos2d-js for AppleTV project I receive this error:
ld: '/Users/pepa/Library/Developer/Xcode/DerivedData/GameXY-gwkkxwmtiilmalhdxfdjgqdfhedy/Build/Products/Debug-appletvos/libcocos2d
tvOS.a(bio_lib.o)' does not contain bitcode. You must rebuild it with
bitcode enabled (Xcode setting ENABLE_BITCODE) or obtain an updated
library from the vendor for architecture arm64
clang: error: linker command failed with exit code 1 (use -v to see invocation)
I believe that I've included only libs built for AppleTV target with bitcode enabled. But the compiler is still complaining. Is the hint to tell which library miss the bitcode in the brackets? (bio_lib.o)
If so, would you know which library it belongs to? I did not find it on my computer.
I'm using the prebuilt binaries from here: https://github.com/elvman/cocos2d-x-3rd-party-libs-bin/tree/tvos

Use next steps:
Install git, make, autoconf, automake, libtool. If you are using Homebrew this can be done by:
brew install git make autoconf automake libtool
Clone repository:
git clone https://github.com/cocos2d/cocos2d-x-3rd-party-libs-src.git
Go to cocos2d-x-3rd-party-libs-src/build and change 2 lines in file tvos.ini:
cfg_build_release_mode="-O3 -DNDEBUG -fembed-bitcode"
cfg_build_debug_mode="-O0 -g -DDEBUG -fembed-bitcode"
Run build script:
build.sh -p=tvos --libs=curl --arch=arm64,x86_64 --mode=release
update libcurl.a crypto and ssl library

Ok for anyone coming here trying to build cocos2d-x (3.10) for iOS using Bitcode enabled. I did it, based on the answer of user1675169 ( https://stackoverflow.com/a/33969215/129202 ) but of course I replaced the os in the build.sh line, and I had to replace all of these one by one:
libtiff.a
libwebp.a
libchipmunk.a
libjpeg.a
libpng.a
libfreetype.a
It took me a while to replace each and everyone of these. Depending on what you use in your cocos2d-x project, you might need to replace other libraries as well. Probably in the end cocos2d-x 3.11 will be delivered with all of these libraries recompiled with bitcode enabled in the first place.
A recompile line could look like this:
build.sh -p=ios --libs=tiff --arch=arm64,x86_64 --mode=release
In the end I was able to precompile the whole libcocos2d with bitcode enabled. I haven't tried sending this to iTunes Connect yet but I guess it might actually work in the end.

Related

Xcode React-Native: linker error - library not found for -lRCTTypeSafety after clean

Xcode 12.3
Cocoapods 1.10.1
React Native CLI 4.13.1
I am having a recurring failure building a React Native app at the linking stage (library not found for -lRCTTypeSafety) in the Xcode "Archive" Build task. ("Product" > "Archive") It fails with the same error when I run the first "Build" after a "Clean Build Folder".
It does not occur when I run the "Build" task, which usually succeeds, but the "first build after a clean" behavior lines up with how the "Archive" task behaves, which appears to run an implicit "clean" first, so they appear to be a similar failure case.
None of the suggested remediations I've found on-line have worked. I am using the workspace, not the project file. FWIW, I have confirmed the same occurs using xcodebuild. (As opposed to the Xcode gui.) xcodebuild clean build fails reliably, as well as xcodebuild archive, but xcodebuild build succeeds if it isn't the first build after a clean.
Several Pod libraries are missing from the linker command when it fails. On a successful run, the xcodebuild build action has the following additional -L flags in the clang linking command that are missing on the failed attempts:
-L/Users/<user>/Library/Developer/Xcode/DerivedData/<project>-bcgmbzkfkmobskcxnhtpmhoehiux/Build/Products/Release-iphoneos/DoubleConversion
-L/Users/<user>/Library/Developer/Xcode/DerivedData/<project>-bcgmbzkfkmobskcxnhtpmhoehiux/Build/Products/Release-iphoneos/FBReactNativeSpec
-L/Users/<user>/Library/Developer/Xcode/DerivedData/<project>-bcgmbzkfkmobskcxnhtpmhoehiux/Build/Products/Release-iphoneos/Folly
-L/Users/<user>/Library/Developer/Xcode/DerivedData/<project>-bcgmbzkfkmobskcxnhtpmhoehiux/Build/Products/Release-iphoneos/RCTTypeSafety
-L/Users/<user>/Library/Developer/Xcode/DerivedData/<project>-bcgmbzkfkmobskcxnhtpmhoehiux/Build/Products/Release-iphoneos/RNCPicker
-L/Users/<user>/Library/Developer/Xcode/DerivedData/<project>-bcgmbzkfkmobskcxnhtpmhoehiux/Build/Products/Release-iphoneos/React-Core
-L/Users/<user>/Library/Developer/Xcode/DerivedData/<project>-bcgmbzkfkmobskcxnhtpmhoehiux/Build/Products/Release-iphoneos/React-CoreModules
-L/Users/<user>/Library/Developer/Xcode/DerivedData/<project>-bcgmbzkfkmobskcxnhtpmhoehiux/Build/Products/Release-iphoneos/React-RCTAnimation
-L/Users/<user>/Library/Developer/Xcode/DerivedData/<project>-bcgmbzkfkmobskcxnhtpmhoehiux/Build/Products/Release-iphoneos/React-RCTBlob
-L/Users/<user>/Library/Developer/Xcode/DerivedData/<project>-bcgmbzkfkmobskcxnhtpmhoehiux/Build/Products/Release-iphoneos/React-RCTImage
-L/Users/<user>/Library/Developer/Xcode/DerivedData/<project>-bcgmbzkfkmobskcxnhtpmhoehiux/Build/Products/Release-iphoneos/React-RCTLinking
-L/Users/<user>/Library/Developer/Xcode/DerivedData/<project>-bcgmbzkfkmobskcxnhtpmhoehiux/Build/Products/Release-iphoneos/React-RCTNetwork
-L/Users/<user>/Library/Developer/Xcode/DerivedData/<project>-bcgmbzkfkmobskcxnhtpmhoehiux/Build/Products/Release-iphoneos/React-RCTSettings
-L/Users/<user>/Library/Developer/Xcode/DerivedData/<project>-bcgmbzkfkmobskcxnhtpmhoehiux/Build/Products/Release-iphoneos/React-RCTText
-L/Users/<user>/Library/Developer/Xcode/DerivedData/<project>-bcgmbzkfkmobskcxnhtpmhoehiux/Build/Products/Release-iphoneos/React-RCTVibration
-L/Users/<user>/Library/Developer/Xcode/DerivedData/<project>-bcgmbzkfkmobskcxnhtpmhoehiux/Build/Products/Release-iphoneos/React-cxxreact
-L/Users/<user>/Library/Developer/Xcode/DerivedData/<project>-bcgmbzkfkmobskcxnhtpmhoehiux/Build/Products/Release-iphoneos/React-jsi
-L/Users/<user>/Library/Developer/Xcode/DerivedData/<project>-bcgmbzkfkmobskcxnhtpmhoehiux/Build/Products/Release-iphoneos/React-jsiexecutor
-L/Users/<user>/Library/Developer/Xcode/DerivedData/<project>-bcgmbzkfkmobskcxnhtpmhoehiux/Build/Products/Release-iphoneos/React-jsinspector
-L/Users/<user>/Library/Developer/Xcode/DerivedData/<project>-bcgmbzkfkmobskcxnhtpmhoehiux/Build/Products/Release-iphoneos/ReactCommon
-L/Users/<user>/Library/Developer/Xcode/DerivedData/<project>-bcgmbzkfkmobskcxnhtpmhoehiux/Build/Products/Release-iphoneos/<project>.app
-L/Users/<user>/Library/Developer/Xcode/DerivedData/<project>-bcgmbzkfkmobskcxnhtpmhoehiux/Build/Products/Release-iphoneos/Yoga
-L/Users/<user>/Library/Developer/Xcode/DerivedData/<project>-bcgmbzkfkmobskcxnhtpmhoehiux/Build/Products/Release-iphoneos/glog
-L/Users/<user>/Library/Developer/Xcode/DerivedData/<project>-bcgmbzkfkmobskcxnhtpmhoehiux/Build/Products/Release-iphoneos/react-native-geolocation
-L/Users/<user>/Library/Developer/Xcode/DerivedData/<project>-bcgmbzkfkmobskcxnhtpmhoehiux/Build/Products/Release-iphoneos/react-native-maps
-L/Users/<user>/Library/Developer/Xcode/DerivedData/<project>-bcgmbzkfkmobskcxnhtpmhoehiux/Build/Products/Release-iphoneos/React-Core/AccessibilityResources.bundle
A successful build action has no WriteAuxiliaryFile, CompileC, or Libtool log lines, so it appears that the failed first attempt after a clean is actually building the Pod files correctly, just not providing the necessary paths to the linker command.
The Libtool lines for the missing library from a failed build look like:
Libtool /Users/<user>/Library/Developer/Xcode/DerivedData/<project>-bcgmbzkfkmobskcxnhtpmhoehiux/Build/Products/Release-iphoneos/RCTTypeSafety/libRCTTypeSafety.a normal (in target 'RCTTypeSafety' from project 'Pods')
/Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/libtool -static -arch_only arm64 -D -syslibroot /Applications/Xcode.app/Contents/Developer/Platforms/iPhoneOS.platform/Developer/SDKs/iPhoneOS14.3.sdk -L/Users/<user>/Library/Developer/Xcode/DerivedData/<project>-bcgmbzkfkmobskcxnhtpmhoehiux/Build/Products/Release-iphoneos/RCTTypeSafety -filelist /Users/<user>/Library/Developer/Xcode/DerivedData/<project>-bcgmbzkfkmobskcxnhtpmhoehiux/Build/Intermediates.noindex/Pods.build/Release-iphoneos/RCTTypeSafety.build/Objects-normal/arm64/RCTTypeSafety.LinkFileList -dependency_info /Users/<user>/Library/Developer/Xcode/DerivedData/<project>-bcgmbzkfkmobskcxnhtpmhoehiux/Build/Intermediates.noindex/Pods.build/Release-iphoneos/RCTTypeSafety.build/Objects-normal/arm64/RCTTypeSafety_libtool_dependency_info.dat -o /Users/<user>/Library/Developer/Xcode/DerivedData/<project>-bcgmbzkfkmobskcxnhtpmhoehiux/Build/Products/Release-iphoneos/RCTTypeSafety/libRCTTypeSafety.a
and I've checked that the output file libRCTTypeSafety.a is present in the path specified for the -o flag above. The directory that contains the file is included in the missing -L flags provided, so it really looks like there's just some step between compilation and linking that is getting missed.
Any help would be greatly appreciated!

Linker complains about missing vtkCommon when using PCL

I try to get a pcl setup running on macOS 10.13.5 unsing homebrew.
I tried to install pcl with both techniques brew install pcl and brew install --build-from-source pcl
As dependencie vtk (8.1.1) is installed automatically and I can see that those libaries are installed in /usr/local.
But in the linking stage I get the following error:
ld: library not found for -lvtkCommon
clang: error: linker command failed with exit code 1 (use -v to see invocation)
If I check the list of installed libraries I can verify that there is not vtkCommon only a vtkCommonCore
In CMake I use the following lines to include PCL, the vtkCommon appears in the ${PCL_LIBRARIES} variable.
find_package(PCL REQUIRED COMPONENTS filters surface kdtree features segmentation)
list(APPEND include_directories ${PCL_INCLUDE_DIRS})
list(APPEND used_libraries ${PCL_LIBRARIES})
Does anyone know why this happens and how it can be solved?
As mentioned by #Tsyvarev the problem was that an a not match PCLConfig.cmake was existed alongside to the correct one, deleting that incorrect on solved the problem.

Xcode 7 - How to remove ld: warning: -read_only_relocs cannot be used with x86_64

I have recently updated to Xcode 7 and now receive the following warning when I compile:
ld: warning: -read_only_relocs cannot be used with x86_64
I don't think I changed anything in the build settings or code to create this. Does anyone know what is causing this warning and how to remove it?
I have found the problem for those interested. As mentioned in the comment, I'm using the Twilio API and if you install this via cocoapods it adds the -read_only_relocs flag to the Other Linker Flags in Xcode (found under Build Settings). Not only does this generate the warning above (on the simulator) but it wont compile on an actual device because you can't have both BITCODE = YES and this flag. If you want to compile, you will need to set Enable Bitcode to No in the Build Options.

How to build boost with mpi support on homebrew?

According to this post (https://github.com/mxcl/homebrew/pull/2953), the flag "--with-mpi" should enable boost_mpi build support for the related homebrew formula, so I am trying to install boost via homebrew like this:
brew install boost --with-mpi
However, the actual boost mpi library is not being build and can not be found.
There is currently some work being done around this, according to: https://github.com/mxcl/homebrew/pull/15689
In summary, I can currently build boost, but it seems the "--with-mpi" flag is being ignored. Could someone please check, if I should be able to build boost (with mpi support) on Mac OS X Mountain Lion (10.8)?
The (verbose) output generates these lines:
MPI auto-detection failed: unknown wrapper compiler mpic++
Please report this error to the Boost mailing list: http://www.boost.org
You will need to manually configure MPI support.
warning: skipping optional Message Passing Interface (MPI) library.
note: to enable MPI support, add "using mpi ;" to user-config.jam.
note: to suppress this message, pass "--without-mpi" to bjam.
note: otherwise, you can safely ignore this message.
Not sure how exactly I can fix this and get the mpi stuff to be build - any ideas?
Just in case this helps anyone else along the line, here's how I fixed this. The main error is MPI auto-detection failed: unknown wrapper compiler mpic++, any typing mpic++ at the command line verified that it was not working properly for me. I used brew to install open-mpi, but the same error was showing in the verbose output for installing boost. A run of brew doctor showed that openmpi was not linked properly, so I fixed those errors and reran brew -v install boost --with-mpi --without-single and it finally built and installed all of the libraries without a problem
To anyone that comes across this, the package migrated to boost-python and boost-mpi separate from boost. Use brew install boost-mpi
Just get it worked on OSX 10.11.5. I've tried brew, but with no luck.
Suppose you already have gcc installed. Here are what I've done:
1. Find and disable (but do not remove) clang
clang alway cause headaches. There would be a lot of warnings when building Boost.
which clang, which should give you /usr/bin/clang
Rename it: sudo mv clang clang_mac_remove, also for clang++: sudo mv clang++ clang++_mac_remove. You can change the names back if you need them in future.
2. Install OpenMPI
If you already installed using brew, uninstall first. Becasue it would have used clang as the compiler wrapper by default. You need to change the wrapper to gcc.
Download the package.
Specify the wrapper compiler to gcc and g++:
./configure CC=gcc CXX=g++ F77=ifort FC=ifort --prefix=/usr/local
Below may take a long time.
make all
sudo make install
Reference: https://wiki.helsinki.fi/display/HUGG/Open+MPI+install+on+Mac+OS+X
3. Install Boost MPI
Download the package.
Run ./bootstrap.sh (can open it first and specify the toolset to gcc, otherwise, the default option is darwin for mac).
Add using mpi ; in project-config.jam file. Then ./b2 —with-mpi will only build the mpi library.
Then, all built libraries can be found in the folder ~/Downloads/boost_1_61_0/stage/lib.
Copy or move them to /usr/local/lib or any other commonly used library path.
Reference: http://www.boost.org/doc/libs/1_61_0/doc/html/mpi/getting_started.html
4. Compile with Boost MPI
LIBRARY DIR = -L/usr/local/lib
INCLUDE = -I/usr/local/include/
LINKER = -lboost_mpi -lboost_serialization
e.g.
mpic++ -std=c++11 -I/usr/local/include/ -c boost_test.cpp -L/usr/local/lib -lboost_mpi -lboost_serialization
Good luck!

compile Boost as static Universal binary lib

I want to have a static Universal binary lib of Boost. (Preferable the latest stable version, that is 1.43.0, or newer.)
I found many Google hits with similar problems and possible solutions. However, most of them seems outdated. Also none of them really worked.
Right now, I am trying
sudo ./bjam --toolset=darwin --link=static --threading=multi \
--architecture=combined --address-model=32_64 \
--macosx-version=10.4 --macosx-version-min=10.4 \
install
That compiles and install fine. However, the produced binaries seems broken.
az#ip245 47 (openlierox) %file /usr/local/lib/libboost_signals.a
/usr/local/lib/libboost_signals.a: current ar archive random library
az#ip245 49 (openlierox) %lipo -info /usr/local/lib/libboost_signals.a
input file /usr/local/lib/libboost_signals.a is not a fat file
Non-fat file: /usr/local/lib/libboost_signals.a is architecture: x86_64
Edit: It seems that the command was wrong and I must remove the "--" for most options. So the command I am trying now (-a just means to rebuild all):
sudo ./bjam -a toolset=darwin link=static threading=multi \
architecture=combined address-model=32_64 \
macosx-version=10.4 macosx-version-min=10.4 \
install
However, this gives many strange errors (what I already had earlier), all like this:
darwin.compile.c++.pch bin.v2/libs/math/build/darwin-4.2.1/release/address-model-32_64/architecture-combined/link-static/macosx-version-min-10.4/macosx-version-10.4/threading-multi/../src/tr1/pch.hpp.gch
In file included from ./boost/math/special_functions/acosh.hpp:18,
from ./boost/math/special_functions.hpp:15,
from libs/math/build/../src/tr1/pch.hpp:9:
./boost/config/no_tr1/cmath.hpp:21:19: error: cmath: No such file or directory
This could be another problem I have when building Universal binaries: g++ on MacOSX doesn't work with -arch ppc64
I found the problem. It seems that the MacOSX 10.4 SDK is missing a bunch of symlinks for GCC 4.2.
Use this as a test case:
g++ on MacOSX doesn't work with -arch ppc64
It will report multiple errors with GCC 4.2 (missing C++ includes, missing C includes, missing libs). In all cases, you can just fix that by setting a symlink. Search in your SDK for the file and just set the symlink in the same way it is in the MacOSX 10.5 SDK.
After that, it all just worked.
We use Boost compiled for 10.4 here at work. We don't use GCC 4.2 on it though, rather we use GCC 4.0 as Apple's GCC 4.2 is not supported for the MacOS 10.4 SDK. To accomplish this you need a bjam user config file, eg. user-config-darwin.jam. Here's the contents of ours. Modify to your heart's content:
# Boost.Build Configuration
# Compiler configuration
using darwin : 8.11 : /usr/bin/g++-4.0 :
<architecture>"combined"
<address-model>"32" # this can be changed to 32_64 for 32/64 universal builds
<macosx-version>"10.4"
<macosx-version-min>"10.4"
# <root>"/Developer"
<compileflags>""
<linkflags>"" ;
Then, you need to tell bjam to use the user config jam file when compiling:
bjam --user-config=user-config-darwin.jam ... (your other options go here) ...
Now you don't have to mess with symlinks in the system SDK directories.
To build 4-way universal boost static binaries on OSX 10.6 I do the following:
Download boost from the boost website.
Extract the archive and cd into the boost_1_xx_0 folder (where xx is the version of boost you are using).
Run:
./bootstrap.sh and then
./bjam macosx-version=10.6 macosx-version-min=10.4 architecture=combined threading=multi link=static address-model=32_64
This will compile everything except for Boost.MPI (which requires the --with-mpi option). The build products get put in ./stage

Resources