I'm working on AES Encryption with PJSIP open source library. The library which is used for AES Encryption is not built-in library available in C Programming. So, I have gone with external library (Libmcrypt) for AES Encryption.
I followed this site for build the libmcrypt library into my machine(MAC OSX).
https://coolestguidesontheplanet.com/install-mcrypt-php-mac-osx-10-10-yosemite-development-server/
https://gist.github.com/bricef/2436364
While building those library it created one dynamic library(libmcrypt.dylib) in /usr/local/lib/ path. when checking the architecture of that library using lipo -info libmcrypt.dylib command, it shows
Non-fat file: libmcrypt.dylib is architecture: x86_64
But I'm creating these applications for Android and IOS devices using PJSIP. Their architectures are armeabi(android) and armv7(IOS).
While Linking the libmcrypt.dylib(x86_64) into PJSIP library(armv7), it shows following errors.
Undefined symbols for architecture armv7:
"_mcrypt_enc_get_block_size", referenced from:
_encrypt_AES in libpjsip-armv7-apple-darwin_ios.a(aes.o)
_decrypt_AES in libpjsip-armv7-apple-darwin_ios.a(aes.o)
"_mcrypt_generic", referenced from:
_encrypt_AES in libpjsip-armv7-apple-darwin_ios.a(aes.o)
"_mcrypt_generic_deinit", referenced from:
_encrypt_AES in libpjsip-armv7-apple-darwin_ios.a(aes.o)
_decrypt_AES in libpjsip-armv7-apple-darwin_ios.a(aes.o)
"_mcrypt_generic_init", referenced from:
_encrypt_AES in libpjsip-armv7-apple-darwin_ios.a(aes.o)
_decrypt_AES in libpjsip-armv7-apple-darwin_ios.a(aes.o)
"_mcrypt_module_close", referenced from:
_encrypt_AES in libpjsip-armv7-apple-darwin_ios.a(aes.o)
_decrypt_AES in libpjsip-armv7-apple-darwin_ios.a(aes.o)
"_mcrypt_module_open", referenced from:
_encrypt_AES in libpjsip-armv7-apple-darwin_ios.a(aes.o)
_decrypt_AES in libpjsip-armv7-apple-darwin_ios.a(aes.o)
"_mdecrypt_generic", referenced from:
_decrypt_AES in libpjsip-armv7-apple-darwin_ios.a(aes.o)
ld: symbol(s) not found for architecture armv7
clang: error: linker command failed with exit code 1 (use -v to see invocation)
make[2]: *** [../bin/pjsip-test-armv7-apple-darwin_ios] Error 1
make[1]: *** [pjsip-test-armv7-apple-darwin_ios] Error 2
make: *** [all] Error 1
I don't know a lot about these architectures. Is it possible to convert libmcrypt.dylib(x86_64) into libmcrypt.dylib(armv7). If Yes, then guide me how to convert it into armv7 architecture and if not then sorry for wasting your time.
Thanks in Advance!
Don't use mcrypt. The MCrypt library has not been updated since 2007. It is highly recommended you switch to OpenSSL or another maintained encryption project.
The PJSIP documentation has instructions on how to use OpenSSL for both IOS and Android devices:
https://trac.pjsip.org/repos/wiki/Getting-Started/iPhone#OpenSSLSupport
https://trac.pjsip.org/repos/wiki/Getting-Started/Android#OpenSSLSupport
Instead of using libmcrypt library, we can use below openssl(Github) projects for creating libraries on all architectures as Suggested by above answer. Thank you #Tim.
Use this project build-libssl.sh file for compiling for all architectures both on Android and IOS.
For Android,
https://github.com/ruslansalikhov/openssl-for-android
For IOS,
https://github.com/x2on/OpenSSL-for-iPhone
Just download and compile the project using build-libssl.sh file. It will creates all library for your platform. Either in Android or IOS.
Download the Project and go to the project directory using cmd/terminal.
cd OpenSSL-for-iPhone/
Compile the Project using following command,
./build-libssl.sh
NOTE:
Machine must have gcc compiler and SDK installed(Android ndk and IOS).
After Successfull Compilation, go to you PROJECT_DIR(OpenSSL-for-iPhone)/lib folder. Check there is four libraries created for all architectures.
Use following command to check supported Architectures by the library file. Go to the lib path on cmd/terminal interface and check,
lipo -info libcrypto.a
It will show which architectures are supported by the library file.
Architectures in the fat file: libcrypto.a are: i386 armv7s armv7
x86_64 arm64
Related
It is definitely possible to target Intel when compiling on an Apple Silicon (ARM64) system, as Xcode does that all the time when building universal bundles of an app. However, I am unable to replicate this compiling a C program with make (specifically Stockfish).
What I've tried
I'm invoking make like so: make build ARCH=x86-64-modern COMP=clang (the same command works when I substitute x86-64-modern for apple-silicon). I've tried using the gcc compiler, which also worked when targeting the apple-silicon arch.
The problem
The make build command terminates with a bunch of errors, most importantly:
Undefined symbols for architecture x86_64:
"_main", referenced from:
implicit entry/start for main executable
ld: symbol(s) not found for architecture x86_64
clang: error: linker command failed with exit code 1 (use -v to see invocation)
Above the error is a bunch of lines complaining that a file was built for an "unknown bitcode architecture:
ld: warning: ignoring file <name>.o, lto file was built for unknown bitcode architecture which is not the architecture being linked (x86_64): <name>.o
So, it seems like the compilation phase succeeds, but the linking phase fails due to missing symbols. How would I acquire and provide the missing symbols to ld such that it can link successfully?
Basically it's my first stack overflow question, so I am sorry for any inaccuracies/stupid questions here + I have tried for 3 days to solve my problem using all other answers people gave on similar questions, but either way I don't know Cmake enough or I am doing something wrong from the very beginning.
I've installed Json-c through Homebrew (brew install json-c). I am using Clion on macOS which uses Cmake.
I have modified my CmakeLists:
cmake_minimum_required(VERSION 3.10)
project(Project C)
set(CMAKE_C_STANDARD 99)
INCLUDE_DIRECTORIES(/usr/local/Cellar/json-c/0.13.1/include/json-c)
LINK_DIRECTORIES(/usr/local/Cellar/json-c/0.13.1/lib)
add_executable(Project main.c functions.c functions.h exp_functions.c exp_functions.h)
TARGET_LINK_LIBRARIES(Project)
but I am not sure how to set arguments for TARGET_LINK_LIBRARIES.
When I am trying to build the project it gives me this:
Undefined symbols for architecture x86_64:
"_json_object_new_double", referenced from:
_GenerateJson in functions.c.o
"_json_object_new_object", referenced from:
_GenerateJson in functions.c.o
"_json_object_new_string", referenced from:
_GenerateJson in functions.c.o
"_json_object_object_add", referenced from:
_GenerateJson in functions.c.o
"_json_object_to_json_string", referenced from:
_GenerateJson in functions.c.o
ld: symbol(s) not found for architecture x86_64
clang: error: linker command failed with exit code 1 (use -v to see invocation)
From what I have found on the web, someone had similar problem (https://github.com/json-c/json-c/issues/235), but after I have installed the package through Brew, I don't have any "json-c" files/folders in /usr/local/lib. There's only "json-c" alias in usr/local/include to brew directory.
I have tried to install json-c using instructions that are provided on repository site (https://github.com/json-c/json-c), but after that I had no clue how to set CmakeLists.txt to make the project work
What am I doing wrong. I am fresh at programming at all + I don't know much of the cmake and how macOS/Homebrew manages files when I am installing new packages through git clone.
You are missing something like
LDFLAGS+= -ljson-c
to link with the library. It was in the setup instructions for CMake in their README.
So I am learning OpenGL 4 from openglbook.
I copied and pasted the simple window creating program in my editor and followed Compiling OpenGL programs on OS X by using
gcc -o hello hello.c -framework OpenGL -framework GLUT
I got the following error:
Undefined symbols for architecture x86_64:
"_glewGetErrorString", referenced from:
_Initialize in chapter-c8ba2d.o
"_glewInit", referenced from:
_Initialize in chapter-c8ba2d.o
"_glutInitContextFlags", referenced from:
_InitWindow in chapter-c8ba2d.o
"_glutInitContextProfile", referenced from:
_InitWindow in chapter-c8ba2d.o
"_glutInitContextVersion", referenced from:
_InitWindow in chapter-c8ba2d.o
"_glutSetOption", referenced from:
_InitWindow in chapter-c8ba2d.o
ld: symbol(s) not found for architecture x86_64
clang: error: linker command failed with exit code 1 (use -v to see invocation)
If I understand correctly, the problem is tha -framework GLUT means that you're linking against the GLUT framework shipped by Apple with macOS and located inside /System/Library/Frameworks folder. This GLUT implementation unfortunately lacks some functionality provided by current version of FreeGLUT. And OpenGLBook.com tutorials use some of this functionality, thus, as it is mentioned many times here, the code examples have to be compiled with FreeGLUT.
There are, of course, few ways this can be done. The easiest one is by installing freeglut by means of the infamous Homebrew package manager and then setting up the CMake project as described below.
So, first install freeglut
brew install freeglut
Then setup CMake project by adding the following lines into CMakeLists.txt
find_package(FreeGLUT CONFIG REQUIRED)
find_package(glew CONFIG REQUIRED)
link_libraries(FreeGLUT::freeglut GLEW::GLEW)
I am trying to use the function EC_KEY_new_by_curve_name(NID_secp256k1) present in openssl. However, when I compile, I get the following error:
undefined symbols for architecture x86_64:
"_EC_KEY_new_by_curve_name", referenced from:
CKey::CKey() in bitcoin.o
ld: symbol(s) not found for architecture x86_64
clang: error: linker command failed with exit code 1 (use -v to see invocation)
I have been hinted that macos openssl is not compile with the ECC extensions. Is the problem? If so, how do I correct it?
If you're using the OpenSSL library that comes with MacOS SDK, then it should automatically have 64-bit support built in.
Looking at the first hit on Google, I'm wondering if you are just not including the correct library in your XCode project. Did you get -lcrypto into the project settings, or forget to add libCrypto.dylib to your list of libraries in the project?
On my SnowLeopard (10.6) machine, I see the symbols are defined in libCrypto:
[/usr/lib]:; nm -arch x86_64 libcrypto.0.9.8.dylib | egrep -i new_by_curve
00000000000a4ac0 T _EC_GROUP_new_by_curve_name
00000000000ab540 T _EC_KEY_new_by_curve_name
I have imported the ffmpeg and SDL libraries into my Xcode project for a Cocoa application.
My project builds and runs successfully with these libraries when my project contains only Cocoa classes, but when I include a C file in my project, the build fails with one warning and 35 errors:
The warning is:
ld: warning: in /Developer/SDKs/MacOSX10.6.sdk/usr/lib/gcc/powerpc-apple-darwin10/4.2.1/libgcc.a, file was built for unsupported file format which is not the architecture being linked (x86_64)
and the errors:
"___gedf2", referenced from:
_eval_expr in libavcodec.a(eval.o)
_quantize_lpc_coefs in libavcodec.a(lpc.o)
_rc_2pass2_before in libxvidcore.a(plugin_2pass2.o)
"___ledf2", referenced from:
_qp2bits in libavcodec.a(ratecontrol.o)
_get_qscale in libavcodec.a(ratecontrol.o)
"___umodsi3", referenced from:
_vorbis_parse_setup_hdr_codebooks in libavcodec.a(vorbis_dec.o)
_vorbis_parse_setup_hdr_codebooks in libavcodec.a(vorbis_dec.o)
For running the code, these are the configuration settings:
Active architecture: x86_64
Architecture in project setting: Standard (32/64_bit universal)
Mac OS X version: 10.6.3
Xcode version: 3.2.3
Also, the same code is building and running successfully with the same settings on my other system, a Mac Mini.
If anyone has any idea what I am missing then please help. Thanks.
Read the error message carefully (emphasis mine):
ld: warning: in /Developer/SDKs/MacOSX10.6.sdk/usr/lib/gcc/powerpc-apple-darwin10/4.2.1/libgcc.a, file was built for unsupported file format which is not the architecture being linked (x86_64)
Looks like you're mixing PowerPC and Intel libraries somehow. You're compiling for x86_64 but you're picking up a libgcc.a for PowerPC.
Those symbols with all the leading underscores are probably supposed to come from libgcc.a but you're not linking the x86_64 version of libgcc.a so they're missing in action and chaos ensues. Sounds like something in your xcode configuration is confused.