OpenSSL with FIPS cross compiling for iOS armv7 - ios

I cross compiled the FIPS for armv7 using the instructions from
http://opensslfoundation.com/testing/validation-2.0/platforms/ios/
I am having difficulties cross compiling openssl dependency on fips.
I am getting following error in terminal.
/usr/local/ssl/fips-2.0/bin/fipsld: line 185: ./openssl: Bad CPU type in executable
make[2]: *** [link_app.] Error 1
make[1]: *** [openssl] Error 2
make: *** [build_apps] Error 1
This is because the openssl executable under the "/apps" folder is of architecture armv7.
Since I am cross compiling openssl, I need only the libssl and libcrypto with architecture armv7, other intermediate executables should build with i386 architecture.
Any help with setting up the environment variables is appreciated.

The OpenSSL FIPS User Guide 2.0 has a comprehensive example of building the FIPS Object Module and FIPS Capable Library. It also offers a sample iOS program to test your build against. See Appendix E on p. 122.
From the looks of it (due to link_app error), you did not set your environment properly with setenv-ios-11.sh. That caused your build attempt to build the executables (which should not be built in this configuration).

Related

ios - THEOS linking error for default tweak

I am starting to develop tweaks from my macbook pro and I and getting the following compiler / linker error when I do make package:
> Making all for tweak CorrectVolume…
==> Compiling Tweak.x (arm64)…
==> Linking tweak CorrectVolume (arm64)…
ld: warning: ignoring file /usr/local/opt/llvm/lib/libc++.dylib, building for iOS-arm64 but attempting to link with file built for macOS-x86_64
ld: in '/usr/local/opt/llvm/lib/libunwind.dylib', building for iOS-arm64 but attempting to link with file built for macOS-x86_64
clang: error: linker command failed with exit code 1 (use -v to see invocation)
make[3]: *** [/Users/joseperezcano/Desktop/Objective_C/correctvolume/.theos/obj/debug/arm64/CorrectVolume.dylib] Error 1
make[2]: *** [/Users/joseperezcano/Desktop/Objective_C/correctvolume/.theos/obj/debug/arm64/CorrectVolume.dylib] Error 2
make[1]: *** [internal-library-all_] Error 2
make: *** [CorrectVolume.all.tweak.variables] Error 2
The program is the one generated by nic.pl without anything else, the tweak isn't supposed to do anything and even so it doesn't compiles. However, when I try to compile from my iPhone it compiles perfectly. I've tried reinstalling the llvm but it didn't change the result.
In case this information is relevant, I have all the sdk patched from the theos github plus one more for iOS 13.4.
I managed to solve the issue by updating my OS to Monterey. Then I run brew doctor to make sure everything was running smoothly and reinstalled theos. After that everything is compiling correctly.

OpenSSL FIPS capable library for iOS arm64 architecture

I am successfully generating OpenSSL FIPS capable library for iOS armv7 architecture by referring Appendix E
from https://www.openssl.org/docs/fips/UserGuide-2.0.pdf
However for arm64 architecture with grater than iOS8 I am trying to build FIPS capable library by tweaking setenv-ios-11.sh setenv-darwin-i386.sh files and compiler but it is throwing below error.
/Applications/Xcode.app/Contents/Developer/Platforms/iPhoneOS.platform/Developer/usr/bin/
llvm-gcc: cannot execute: No such file or directory
How do I build the OpenSSL FIPS capable library for iOS arm64 architecture?
The problem is related to GCC path. So you need to link gcc to your path by below command.
Details: llvm-gcc-4.2: error
Fix the issue on iOS devices:
cd /Applications/Xcode.app/Contents/Developer/Platforms/iPhoneOS.platform/Developer/usr/bin
ln -s /usr/bin/llvm-gcc gcc-4.2

Error compiling freetype2 library for arm7 with OSX gcc: `limits.h: No such file or directory

I am trying to compile the freetype2 library for arm7, using Xcode's command line tools in OSX. I am using the following parameterisation of the project's configure script:
Compiling FreeType for iPhone?
These errors were produced when running the script:
configure:3426: /Applications/Xcode.app/Contents/Developer/Platforms/iPhoneOS.platform/Developer/usr/bin/gcc -E conftest.c
In file included from conftest.c:10:
/Applications/Xcode.app/Contents/Developer/Platforms/iPhoneOS.platform/Developer/usr/llvm-gcc-4.2/bin/../lib/gcc/i686-apple-darwin10/4.2.1/include/limits.h:15:25: error: limits.h: No such file or directory
configure:3426: /Applications/Xcode.app/Contents/Developer/Platforms/iPhoneOS.platform/Developer/usr/bin/gcc -E -traditional-cpp conftest.c
conftest.c:12: error: assert.h: No such file or directory
configure:3426: /lib/cpp conftest.c
/Volumes/DATA/filestore/development/libs/c/freetype2/extract/2.5.3/builds/unix/configure: line 1600: /lib/cpp: No such file or directory
configure:3465: result: /lib/cpp
configure:3485: /lib/cpp conftest.c
/Volumes/DATA/filestore/development/libs/c/freetype2/extract/2.5.3/builds/unix/configure: line 1600: /lib/cpp: No such file or directory
I can see that the missing files actually do exist in the directories output in the error messages.
CFLAGS and LDFLAGS contain the following parameter, which should allow for the inclusion of system header files:
-isysroot /Applications/Xcode.app/Contents/Developer/Platforms/iPhoneOS.platform/Developer/SDKs/iPhoneOS6.1.sdk/
The other odd thing that I noticed with these error messages, is that the architecture identifier in the directory structures is i686-apple-darwin10. The -arch armv7 compiler flag is being used, so why are i686-apple-darwin10 directories being inspected at all?
* UPDATED *
I also tried parameterising the configure script as per another example:
https://stackoverflow.com/a/12594507/1704014
The following error terminated its execution:
checking for suffix of native executables... ld: library not found for -lcrt1.10.6.o
collect2: ld returned 1 exit status
configure: error: native C compiler is not working
This also indicates that a different target architecture (OSX 10.6) is being built against, not arm7.
Any help much appreciated.
The problem in my OSX build environment was the Xcode command line tools installation. I reinstalled the latest distribution of the tools, and was able to compile successfully from then on.
To build the freetype2 library for arm7 and arm7s architectures, I found the following suggested commands useful:
https://stackoverflow.com/a/12594507/1704014

Installing OpenCV 3.0.0-dev, issue with configuration options

I know OpenCV 3.0 is not a release version, yet. I'm trying to evaluate a few features in the 3.0 version for a prototype system we are building. I cloned the latest source code from the git repository and I use the following cmake to build the libraries:
cmake -D BUILD_SHARED_LIBS=ON -D CMAKE_BUILD_TYPE=RELEASE -D CMAKE_INSTALL_PREFIX=/usr/local ..
However, I encounter this issue when it builds the libraries when i do a make:
/usr/bin/ld: /usr/local/lib/libavcodec.a(avpacket.o): relocation R_X86_64_32S against `av_destruct_packet' can not be used when making a shared object; recompile with -fPIC
/usr/local/lib/libavcodec.a: could not read symbols: Bad value
collect2: error: ld returned 1 exit status
make[2]: *** [lib/libopencv_highgui.so.3.0.0] Error 1
make[1]: *** [modules/highgui/CMakeFiles/opencv_highgui.dir/all] Error 2
make[1]: *** Waiting for unfinished jobs....
I'm not quite sure where to set the -fPIC flag in the CMakeLists.txt. Just a point to note, I have OpenCV 2.4.8 libraries already built and running on my machine. Thanks for taking time to help me out!
Thanks for the answer. I managed to install OpenCV 3.0.0-dev version by removing my existing OpenCV installation. Although this was not required, I removed my previous 2.4.8 library files and managed to compile it. CCMake helped make the decision for the installation much simpler. Use that to decide which libraries you'd like to compile before running make.

Building fftw for iOS

I'm trying to build fftw for iOS.
I found this question:
How to link third party libraries like fftw3 and sndfile to an iPhone project in Xcode?
And tried running the shell script, but I am getting the errors shown below.
make[2]: *** [bench] Error 1
make[1]: *** [all-recursive] Error 1
make: *** [all] Error 2
lipo: unknown architecture specification flag: armv7s in specifying input file -arch armv7s ios-library/libfftw3f_armv7s.a
lipo: known architecture flags are: any little big ppc64 x86_64 ppc970-64 ppc i386 m68k hppa sparc m88k i860 veo arm ppc601 ppc603 ppc603e ppc603ev ppc604 ppc604e ppc750 ppc7400 ppc7450 ppc970 i486 i486SX pentium i586 pentpro i686 pentIIm3 pentIIm5 pentium4 m68030 m68040 hppa7100LC veo1 veo2 veo3 veo4 armv4t armv5 xscale armv6 armv7 armv7f armv7k
lipo: Usage: lipo [input_file] ... [-arch <arch_type> input_file] ... [-info] [-detailed_info] [-output output_file] [-create] [-arch_blank <arch_type>] [-thin <arch_type>] [-remove <arch_type>] ... [-extract <arch_type>] ... [-extract_family <arch_type>] ... [-verify_arch <arch_type> ...] [-replace <arch_type> <file_name>] ...
I am a total nooby when it comes to compiling for iOS so any help is much appreciated.
It looks like it can't find the armv7s architecture specified...
If I leave in only the first part, for the armv7 architecture, I get the following errors:
Toolchains/XcodeDefault.xctoolchain/usr/bin/clang -x c -arch armv7 -std=gnu99 -mfpu=neon
checking whether the C compiler works... no
configure: error: in `/Users/davidmenard/Desktop/fftw-3.3.3':
configure: error: C compiler cannot create executables
See `config.log' for more details
make: *** No targets specified and no makefile found. Stop.
cp: .libs/libfftw3f.a: No such file or directory
I needed to recompile my framework: double check those armv7s to not miss at that 2 place:
For me the problem was solved, hopefully it will help a few of you!
My XCode compilers were not getting along, because I had both XCode 4 and XCode5-DP5 installed. Using the latest compiler fixed my errors.

Resources