I want to install 32 bit gettext by homebrew:
brew install gettext --32-bit
But when it is still x86_64 version:
file /usr/local/Cellar/gettext/0.18.2/lib/libgettextlib-0.18.2.dylib
/usr/local/Cellar/gettext/0.18.2/lib/libgettextlib-0.18.2.dylib: Mach-O 64-bit dynamically linked shared library x86_64
You probably want to use brew install gettext --universal, which will build a universal ("fat") binary containing both 32-bit and 64-bit code. There's no --32-bit option; see brew info gettext to see what options are supported.
$ brew install gettext --universal
[...snip...]
$ file /usr/local/Cellar/gettext/0.18.2/lib/libgettextlib-0.18.2.dylib
/usr/local/Cellar/gettext/0.18.2/lib/libgettextlib-0.18.2.dylib: Mach-O universal binary with 2 architectures
/usr/local/Cellar/gettext/0.18.2/lib/libgettextlib-0.18.2.dylib (for architecture i386): Mach-O dynamically linked shared library i386
/usr/local/Cellar/gettext/0.18.2/lib/libgettextlib-0.18.2.dylib (for architecture x86_64): Mach-O 64-bit dynamically linked shared library x86_64
Related
I am cross-compiling on x86_64 MacOS 11 for arm64 architecture.
clang/XCode support it but I face an issue when external library is required.
Let it be boost, for example. I know that the bottle for arm64 is available but it looks like there is no way to select it for installation.
arch -arm64 brew ... says that this architecture is unknown which sounds fair.
So the question is wheather there is an option to force brew install bottles for 'foreign' architecture ?
Thanks to Homebrew team
https://github.com/Homebrew/discussions/discussions/2843
I made it work with the code like this:
setopt sh_word_split
mkdir arm-homebrew && curl -L https://github.com/Homebrew/brew/tarball/master | tar xz --strip 1 -C arm-homebrew
alias arm-brew='$(pwd)/arm-homebrew/bin/brew'
response=$(arm-brew fetch --force --bottle-tag=arm64_big_sur boost | grep "Downloaded to")
parsed=($response)
arm-brew install $parsed[3]
Native system brew can be asked to download any desired bottle version with two switches:
--force ignores the compatibility check
--bottle-tag=arm64_big_sur downloads the ARM Big Sur build. This assumes the formula has this build, check the formula .rb for available tags. Big Sur is the earliest macOS with ARM support.
Then use brew --cache to get the filename of the downloaded bottle and pass to brew install:
brew fetch --force --bottle-tag=arm64_big_sur boost
brew install $(brew --cache --bottle-tag=arm64_big_sur boost)
You can verify that it worked with cd $(brew --prefix boost) then use file on any .dylib files to see what architecture they're built for.
If the formula has any dependencies then they will still be installed normally (for the native architecture), so you may have to follow the same process for them.
I have an xcode project which uses xmppframework.
the KissXML module of this framework needs libxml2, according to https://github.com/robbiehanson/KissXML/wiki/GettingStarted.
I followed these instructions, and downloaded libxml2 from ftp://xmlsoft.org/libxml2/.
Specifically, I downloaded and extracted LATEST_LIBXML2, which turns out to be libxml2-2.9.2.
I then added the relevant header search path to my xcode project, and
-l "lxml2"
to my linker flags.
However, when I build my project, it gives the following linker error:
ld: library not found for -llxml2
clang: error: linker command failed with exit code 1 (use -v to see invocation)
I suspect this is because I need to build libxml2 myself, in order to get the library binary. However, I can't find specific instructions for doing this on OS X Yosemite, xcode 6.
Does anyone have any instructions on building libxml2-2.9.2 on OS X Yosemite, Xcode 6, so that I can link to it in my project?
Alternatively, if someone can provide a binary for libxml2-2.9.2, that might also work. I did find http://www.explain.com.au/oss/libxml2xslt.html#id2658905, but this guy only seems to offer binaries for older versions of libxml2, not the current version.
Thanks!
Best regards,
Chris
Well firstly, the library is called libxml2, so the link should be -lxml2 and not -llxml2.
Secondly, there is already a libxml2 built-in to OSX/iOS, and you can actually reference that library in the link libraries section for the project. You generally don't need to build the library unless you really want newer features of the newer version.
In the General tab of the project, use the Linked frameworks and Libraries to add a reference to libxml2.dylib.
The instructions on the page you reference are using the version of libxml2 that is available on OSX/iOS already. You do not need to download libxml2 to get it to work.
The location that's mentioned /usr/include/libxml2 on the page will work for you also if you install the command line developer tools - at a terminal prompt do xcode-select --install.
I have built LibXML2 (latest version 2.9.2) on Solaris SPARC, Linux and Windows. I have never use MacOS (poor =)) ).
Here's my brief instruction. You can try the similar way.
cd /opt/mydir/libxml2
mkdir linux-gcc3
gunzib -c libxml2-2.9.2.tar.gz | tar xvf –
cd libxml2-2.9.2
./configure --prefix=/opt/mydir/libxml2/linux-gcc3 --enable-static --disable-shared 2>&1 | tee conf.log
## 64 bit
## ./configure CC="cc -m64" --prefix=/opt/mydir/libxml2/linux-gcc3 --enable-static --disable-shared 2>&1 | tee conf.log
make 2>&1 | tee make.log
make install
I need a network library for my c library so I can use it on both iOS and android. I've been searching around and tried to build libcurl as a static library but wasn't successful.
I built it with the following settings
$ export CC="clang"
$ export CFLAGS="-Wall -g -std=c11 -pipe -Os -gdwarf-2"
$ ./configure --enable-static
make install
It runs fine when I test the library with my test.c library. However, when I run it on my iOS project, I got a mismatch on CurlchkszEQ(long, CURL_SIZEOF_LONG)
I think the problem was that CURL_SIZEOF_LONG is set to be 8 while long in iOS is 4.
Does anyone know what went wrong with my config setting?
You want to cross-compile libcurl for iOS but the problem here is that you use clang which by default produces 64-bit x86_64 object files.
In other words you need to work with the iOS toolchain (xcrun -sdk iphoneos clang), provide the right architecture flag(s)[1] (e.g -arch armv7) and use the right sysroot path.
I recommend you to refer to:
curl-ios-build-scripts: a collection of handy scripts used to build (lib)curl for iOS 5+ and OSX 10.7+,
or, http://seiryu.home.comcast.net/~seiryu/libcurl-ios.html which provides a ready-to-use a precompiled binary.
[1]: you may want to produce a fat library that targets ARMv7, ARMv7s and i386 (simulator) architectures.
I have an opencv project that I've been developing under ubuntu 12.04, on a parellels VM on a mac which has an x86_64 architecture. There have been many screen switching performance issues that I believe are due to the VM, where linux video modes flip around for a couple seconds while camera access is made by the opencv application. I decided to moved the project into Xcode on the mac side of the computer to continue the opencv development. However, I'm not that familiar with xcode and am having trouble getting the project to build correctly there.
I have xcode installed.
I downloaded and decompressed the latest version of opencv on the mac, and ran: ~/src/opencv/build/cmake-gui -G Xcode .. per the instructions from willowgarage and various other locations.
This appeared to work fine (however I'm wondering now if I'm missing an architecture setting in here, although it is 64-bit intel in Xcode).
I then setup an xcode project with the source files from the linux project and changed the include directories to use /opt/local/include/... rather than the /usr/local/include/...
I switched xcode to use the LLVM GCC compiler in the build settings for the project
then set the Apple LLVM Dialog for C++ to Language Dialect to GNU++11 (which seems possibly inconsistant with the line above)
I'm not using a makefile in xcode, (that I'm aware of - it has its own project file...)
I was also running into a linker issue that looked like they may be resolved with the addition of this linker flag:
-lopencv_video
based on a similar posting here: other thread
however in that case the person was using a Makefile in their project.
I've tried adding this linker flag under "Other Linker Flags" in xcode build settings but still get build errors.
I think I may have two issues here, one with the architecture settings when building the opencv libraries with Cmake, and one with the linker flag settings in my project.
Currently the build error list looks like this:
Undefined symbols for architecture x86_64:
"cv::_InputArray::_InputArray(cv::Mat const&)", referenced from:
_main in main.o
"cv::_OutputArray::_OutputArray(cv::Mat&)", referenced from:
_main in main.o
"cv::Mat::deallocate()", referenced from:
cv::Mat::release() in main.o
"cv::Mat::copySize(cv::Mat const&)", referenced from:
cv::Mat::Mat(cv::Mat const&)in main.o
cv::Mat::operator=(cv::Mat const&)in main.o
"cv::Mat::Mat(_IplImage const*, bool)", referenced from:
_main in main.o
"cv::imread(std::basic_string<char, std::char_traits<char>, std::allocator<char> > const&, int)", referenced from:
_main in main.o
---SNIP---
ld: symbol(s) not found for architecture x86_64
collect2: ld returned 1 exit status
Can anyone provide some guidance on what to try next?
Thanks,
Walt
steps to compile and run c++ opencv 2.4.4 on mac os x lion 10.7.5 with cmake 2.8.10 and xcode 4.6.1
EDIT: successfully tested with opencv 2.4.5 on mac os x mountain lion 10.8.3 and Xcode 4.5
Having the right tools
download opencv-unix from http://sourceforge.net/projects/opencvlibrary/files/ and untar it wherever
download cmake .dmg from http://www.cmake.org/cmake/resources/software.html and install it
i am assuming you have xcode 4.6 on os x lion which includes the ios sdk 6.1
go to xcode preferences to download and install the Command Line Tools so you have g++ etc.
Use cmake to compile opencv
go to the extracted opencv folder
create a build directory
mkdir build
cd build
cmake -D WITH_TBB=OFF -D BUILD_NEW_PYTHON_SUPPORT=OFF -D BUILD_FAT_JAVA_LIB=OFF -D BUILD_TBB=OFF -D BUILD_EXAMPLES=ON -D CMAKE_CXX_COMPILER=g++ CMAKE_CC_COMPILER=gcc -D CMAKE_OSX_ARCHITECTURES=x86_64 -D BUILD_opencv_java=OFF -G "Unix Makefiles" ..
make -j8
sudo make install
from the build folder, go to bin/ and run one of the tests
./opencv-test-photo
Create your own c++ opencv xcode project
fire up xcode and create a new xcode project
select Command Line Tool for the type of project under os x
open your project's build settings
under Architectures, set Architecture to 64-bit intel. also set Valid Architectures to x86_64
under Build Options, set Compiler for C/C++ to Default Compiler
under Search Paths, set Header Search Paths to /usr/local/include
also under Search Paths, set Library Search Paths to /usr/local/lib
under Apple LLVM compiler 4.2 - Language set C++ Standard Library to libstd++ (With OpenCV 2.4.6, Xcode 5, LLVM 5.0, and 10.8.5, set both language dialect and std library to "Compiler Default" instead)
Add the compiled opencv libraries to your project
go the the Build Phases tab next to Build Settings tab you were in
inside Link Binary With Libraries, click on the + sign and choose Add Other
hit the front slash / on your keyboard and enter /usr/local/lib
hit enter and select the libraries you want to use in your project
make sure you always select libopencv_core.2.4.4.dylib
hit enter and you will see the selected dylibs under your project
write some code
first lets organize the files, right click on your project blueprint icon and select New Group
name the new group opencv or whatever
drag the dylibs and drop them in that group
open main.cpp
copy code from any of the sample tests that came with opencv and paste it here
make sure all the required dylibs are added, for example, if you copied the opencv_test_stitching.cpp code into main.cpp, you will need to add the following libraries in the previous steps
libopencv_core.2.4.4.dylib
libopencv_highgui.2.4.4.dylib
libopencv_stitching.2.4.4.dylib
Cheers.
i'm trying to use Google's v8 in my iPhone Application.
I built the libraries using "make arm" as stated on Google's website.
Unfortunately I get several linker errors telling me that the library is build "for archive".
The terminal tells me that the library's architecture is i386:
lipo -info libv8_base.a
input file libv8_base.a is not a fat file
Non-fat file: libv8_base.a is architecture: i386
So, how do I actually build a armv7 library?
BTW: I don't really know much about this library building stuff. Maybe I can only build for ARM on an actual ARM device? I don't get why I can't just download the prebuilt files anywhere, too.
You can find instructions to cross-compile for ARM on the v8 wiki.
When running on an x86 machine
make arm
builds a simulator, not an actual ARM binary.
You can also compile a release shell natively if you have ARM hardware:
scons arch=arm -j2
EDIT:
You may also want to learn about cross-compilation.
There is a simulator for armv7 built in the v8 source. If you check v8/src/arm/ you will find simulator files.
To build, make sure your CC, CXX and LINK are point to native gcc / g++ tools. And then do
Make arm.release -j8
This will make for arm and look into *.gypi files for more build options. Hope this is useful.