Openssl (OS X Yosemite) Installation Make Errors - c

While OpenSSL ver. 0.9.8za was already installed on my system (darwin64-x86_64-cc), I elected to install the latest version, 1.0.1j, using the instructions for UNIX systems, in the "INSTALL" file within the downloaded tarball. I chose to configure with the 64-bit option, './Configure darwin64-x86_64-cc', and then ran the makefile. So far, so good. After about a minute, as I was thinking the installation would be successful, the compiler displayed following error messages, after compilation terminated:
Compile command line: './Configure darwin64-x86_64-cc' (Openssl suggestion for 64-bit)
duplicate symbol _OPENSSL_cleanse in:
../libcrypto.a(mem_clr.o)
../libcrypto.a(x86_64cpuid.o)
ld: 1 duplicate symbol for architecture x86_64
clang: error: linker command failed with exit code 1 (use -v to see invocation)
make[2]: *** [link_app.] Error 1
make[1]: *** [openssl] Error 2
make: *** [build_apps] Error 1
The problem appears to originate in the linker, but then again, I'm still a command line novice.
So, given this error, what needs to be changed in order to fully compile OpenSSL 1.0.1j?
When the automatic configuration route was taken (./config), the following error is given:
cc -I.. -I../.. -I../modes -I../asn1 -I../evp -I../../include -DOPENSSL_THREADS -D_REENTRANT
DDSO_DLFCN -DHAVE_DLFCN_H -arch i386 -O3 -fomit-frame-pointer -DL_ENDIAN
DOPENSSL_BN_ASM_PART_WORDS -DOPENSSL_IA32_SSE2 -DOPENSSL_BN_ASM_MONT -DOPENSSL_BN_ASM_GF2m
DSHA1_ASM -DSHA256_ASM -DSHA512_ASM -DMD5_ASM -DRMD160_ASM -DAES_ASM -DVPAES_ASM -DWHIRLPOOL_ASM
DGHASH_ASM -c -o obj_xref.o obj_xref.c
ar r ../../libcrypto.a o_names.o obj_dat.o obj_lib.o obj_err.o obj_xref.o
ar: ../../libcrypto.a is a fat file (use libtool(1) or lipo(1) and ar(1) on it)
ar: ../../libcrypto.a: Inappropriate file type or format
make[2]: *** [lib] Error 1
make[1]: *** [subdirs] Error 1
make: *** [build_crypto] Error 1
Update: The "PROBLEMS" documentation suggests changing two lines in the apps/Makefile and test/Makefile:
"LIBCRYPTO= -L.. -lcrypto"
"LIBSSL=-L -lssl"
to:
"LIBCRYPTO=../libcrypto.a"
"LIBSSL=../libssl.a"
Re-attempting make afterward, the same message was given.
My sincere thanks for the help and comments by jww, Jonathan L. and others gave/made. Should errors persist, I'll continue the search for the missing information and eventually post a solution.

I'm not sure what your problem is. Using XCode 6 (6.1.1, I believe) on Yosemite 10.10.1, I was able to get openssl-1.0.1j from OpenSSL.org and extract it. I then configured it with:
./Configure --prefix=/usr/openssl/openssl-1.0.1j darwin64-x86_64-cc zlib threads shared
With those, I was able to build, test and install without problem. That's pretty close to what you did; I simply have noted the presence of zlib (compression) and requested thread and shared library support — and specified a slightly out-of-the-way location to install it. (The top-level directory specified with --prefix existed but was empty.) I tried adding sctp to the configuration options, but no dice — an SCTP header is missing, so I didn't bother to try further.

Related

Working cmake/mingw configuration stopped working. The C compiler is not able to compile a simple test program

I write the C program using MinGW on windows 10 with Clion IDE. I had everything working and compiled successfully multiple times before. Can't link the error with any action but now cmake test in Clion fails - "Test Cmake run finished with errors" and I can't compile. Cmake error:
-- The C compiler identification is GNU 9.2.0
-- The CXX compiler identification is GNU 9.2.0
-- Check for working C compiler: C:/msys64/mingw64/bin/gcc.exe
-- Check for working C compiler: C:/msys64/mingw64/bin/gcc.exe -- broken
CMake Error at C:/Users/karol/AppData/Local/JetBrains/Toolbox/apps/CLion/ch-0/193.6015.37/bin/cmake/win/share/cmake-3.15/Modules/CMakeTestCCompiler.cmake:60 (message):
The C compiler
"C:/msys64/mingw64/bin/gcc.exe"
is not able to compile a simple test program.
It fails with the following output:
Change Dir: C:/Users/karol/AppData/Local/Temp/cmake_check_environment/_build11621595605978509144/CMakeFiles/CMakeTmp
Run Build Command(s):C:/msys64/mingw64/bin/mingw32-make.exe cmTC_15aad/fast && C:/msys64/mingw64/bin/mingw32-make.exe -f CMakeFiles\cmTC_15aad.dir\build.make CMakeFiles/cmTC_15aad.dir/build
mingw32-make.exe[1]: Entering directory 'C:/Users/karol/AppData/Local/Temp/cmake_check_environment/_build11621595605978509144/CMakeFiles/CMakeTmp'
Building C object CMakeFiles/cmTC_15aad.dir/testCCompiler.c.obj
C:\msys64\mingw64\bin\gcc.exe -o CMakeFiles\cmTC_15aad.dir\testCCompiler.c.obj -c C:\Users\karol\AppData\Local\Temp\cmake_check_environment\_build11621595605978509144\CMakeFiles\CMakeTmp\testCCompiler.c
Linking C executable cmTC_15aad.exe
C:\Users\karol\AppData\Local\JetBrains\Toolbox\apps\CLion\ch-0\193.6015.37\bin\cmake\win\bin\cmake.exe -E cmake_link_script CMakeFiles\cmTC_15aad.dir\link.txt --verbose=1
C:\Users\karol\AppData\Local\JetBrains\Toolbox\apps\CLion\ch-0\193.6015.37\bin\cmake\win\bin\cmake.exe -E remove -f CMakeFiles\cmTC_15aad.dir/objects.a
C:\msys64\mingw64\bin\ar.exe cr CMakeFiles\cmTC_15aad.dir/objects.a #CMakeFiles\cmTC_15aad.dir\objects1.rsp
C:\msys64\mingw64\bin\gcc.exe -Wl,--whole-archive CMakeFiles\cmTC_15aad.dir/objects.a -Wl,--no-whole-archive -o cmTC_15aad.exe -Wl,--out-implib,libcmTC_15aad.dll.a -Wl,--major-image-version,0,--minor-image-version,0 #CMakeFiles\cmTC_15aad.dir\linklibs.rsp
gcc.exe: fatal error: cannot execute 'ld': CreateProcess: No such file or directory
compilation terminated.
mingw32-make.exe[1]: *** [CMakeFiles\cmTC_15aad.dir\build.make:88: cmTC_15aad.exe] Error 1
mingw32-make.exe[1]: Leaving directory 'C:/Users/karol/AppData/Local/Temp/cmake_check_environment/_build11621595605978509144/CMakeFiles/CMakeTmp'
mingw32-make.exe: *** [Makefile:120: cmTC_15aad/fast] Error 2
CMake will not be able to correctly generate this project.
Call Stack (most recent call first):
CMakeLists.txt:1 (project)
-- Configuring incomplete, errors occurred!
See also "C:/Users/karol/AppData/Local/Temp/cmake_check_environment/_build11621595605978509144/CMakeFiles/CMakeOutput.log".
See also "C:/Users/karol/AppData/Local/Temp/cmake_check_environment/_build11621595605978509144/CMakeFiles/CMakeError.log".
Error code: 1
I don't know what caused it. One thing I did around the time it broke is turn off avast cyber capture. But now I turned off avast antivirus completely and turned off "Check apps and files" option in Defender. The latter I did when Clion popped a notification saying "Windows Defender might be interrupting build speed". I also clicked "fix" in this Clion pop-up and it added project folders to exceptions. Clion notified me of it not immediately after the error but way later.
The directory "C:/Users/karol/AppData/Local/Temp/cmake_check_environment/" mentioned in the error report doesn't exist. I tried unchecking "read-only access" of AppData/Local/temp directory but Windows keeps putting it on. Between those changes and antivirus changes, I was restarting windows many times.
The error message i get when trying to compile:
C:\Users\karol\AppData\Local\JetBrains\Toolbox\apps\CLion\ch-0\193.6015.37\bin\cmake\win\bin\cmake.exe --build C:\Users\karol\Desktop\studia\wstep_do_C\final_project\cmake-build-debug --target final_project -- -j 2
[ 20%] Linking C executable final_project.exe
gcc.exe: fatal error: cannot execute 'ld': CreateProcess: No such file or directory
compilation terminated.
mingw32-make.exe[3]: *** [CMakeFiles\final_project.dir\build.make:134: final_project.exe] Error 1
mingw32-make.exe[2]: *** [CMakeFiles\Makefile2:75: CMakeFiles/final_project.dir/all] Error 2
mingw32-make.exe[1]: *** [CMakeFiles\Makefile2:82: CMakeFiles/final_project.dir/rule] Error 2
mingw32-make.exe: *** [Makefile:117: final_project] Error 2
Many poeple experienced simmilar error caused by non-latin characters in path, not the case here. Also i don't suspect mingw installation as it used to work.
Clion toolchains settings

Make and apply apue.h

I started to learn APUE* and compile the source code
Download the source code from Source Code
Extract it to
$ pwd
/Users/me/Desktop/PubRepo/C/APUE/apue.3e
Read readme
$ cat readme
Read the file called DISCLAIMER.
On Freebsd, type "gmake".
On other platforms, type "make" (as long as this is gnu make).
For FAQs, updated source code, and the lost chapter, see http://www.apuebook.com.
Please direct questions, suggestions, and bug reports to sar#apuebook.com.
Steve Rago
January 2013
I checked make version
$ make --version
GNU Make 3.81
Copyright (C) 2006 Free Software Foundation, Inc.
This is free software; see the source for copying conditions.
There is NO warranty; not even for MERCHANTABILITY or FITNESS FOR A
PARTICULAR PURPOSE.
This program built for i386-apple-darwin11.3.0
make but report error:
gcc -ansi -I../include -Wall -DMACOS -D_DARWIN_C_SOURCE -c -o sleep.o sleep.c
making intro
gcc -ansi -I../include -Wall -DMACOS -D_DARWIN_C_SOURCE getcputc.c -o getcputc -L../lib -lapue
ld: archive has no table of contents file '../lib/libapue.a' for architecture x86_64
clang: error: unable to execute command: Segmentation fault: 11
clang: error: linker command failed due to signal (use -v to see invocation)
make[1]: *** [getcputc] Error 254
make: *** [all] Error 1
I searched and found answer to add cp ./lib/error.c /usr/local/include/
$ cp ./lib/error.c /usr/local/include/
make clean and make
making intro
gcc -ansi -I../include -Wall -DMACOS -D_DARWIN_C_SOURCE getcputc.c -o getcputc -L../lib -lapue
ld: archive has no table of contents file '../lib/libapue.a' for architecture x86_64
clang: error: linker command failed with exit code 1 (use -v to see invocation)
make[1]: *** [getcputc] Error 1
make: *** [all] Error 1
The error is still there.
How could I apply apue.h?
* W Richard Stevens, Stephen A Rago
Advanced Programming in the Unix Environment, 3rd Edn, 2013.
I downloaded the APUE source to a Mac running macOS 10.14.1 Mojave with XCode 10.1 installed (see also Can't compile a C program on a Mac after upgrade to Mojave).
I then ran make CC=/usr/bin/clang (using /usr/bin/gcc is also OK) to use that instead of a home-built GCC 8.2.0, which failed in the db subdirectory. If you don't have any non-standard version of GCC installed on your PATH ahead of /usr/bin/gcc or /usr/bin/clang, you shouldn't need the CC=… argument.
This did a lot of building — all of it successfully (once I'd specified the compiler explicitly; I got an error on the -R. argument with the home-built GCC).
Make sure you have XCode properly installed. Worry about the Command Line Tools — see the "Can't compile" question for information on where to get them. You shouldn't need /usr/include for this, but it is likely to make life easier; again, see the "Can't compiler" question for how to install /usr/include.
There is an answer here from #makhlaghi that helped me a long time ago.
https://unix.stackexchange.com/questions/105483/compiling-code-from-apue.
Here is the answer that worked for me:
A short review of how to write and compile the programs in Advanced Programming in the UNIX® Environment, thanks to slm for helping me understand the steps. You can download the source code from here. I wish this information was included as part of appendix b of the book, where the header file is explained.
The uncompressed file contains directories with the names of the chapters and two others named include and lib. The ones with the names of the chapters have all the programs of that chapter in them.
The include directory contains the header file that is used in most of the programs in the book: apue.h. The lib directory has the source code of the implementations for the that header.
Lets assume the uncompressed file is located at: SCADDRESS/, for example it might be: /home/yourid/Downloads/apue.3e/
Once you uncompress the source code, go in the directory and run make:
$ cd SCADDRESS
$ make
make will compile all the programs in all the chapters. But the important thing is that before that, it will make the library that will contain the implementations of the functions in apue.h.
To compile an example program that you write from the book, run this GCC command (assuming your program's name is myls.c which is the first in the book):
gcc -o myls myls.c -I SCADDRESS/include/ -L SCADDRESS/lib/ -lapue
-I tells gcc which directory to look for the include file. -L tells it the location of the library directory, and -lapue, tells the name of the library file to look for in that directory. Such that -LXXX means to look for a file in the library directory with the name: libXXX.a or libXXX.so.

Failed to build C code by using generated NDK toolchain

I am working on build a c library for android 5.1.1.
First I build a standalone toolchain by following the google ndk standalone toolchain guild.
<prebuilt_ndk_r12b_path>/build/tools/make-standalone-toolchain.sh --platform=android-22 --ndk-dir=<prebuilt_ndk_r12b_path> --install-dir=/home/r0ng/utilities/ndk --toolchain=x86_64-linux-android-4.9
After that, I exported CC, AR and RANLIB in ~/.bashrc
export ANDROID_NDK=/home/r0ng/utilities/ndk
SYSROOT=$ANDROID_NDK/sysroot
export CC="$ANDROID_NDK/bin/arm-linux-androideabi-gcc-4.9.x --sysroot=$SYSROOT"
export AR="$ANDROID_NDK/bin/arm-linux-androideabi-gcc-ar --sysroot=$SYSROOT"
export RANLIB="$ANDROID_NDK/bin/arm-linux-androideabi-gcc-ranlib --sysroot=$SYSROOT"
But when I tried to compile by using cmake ... I had the following errors:
-- The C compiler identification is GNU 4.9.0
-- The CXX compiler identification is GNU 4.9.3
-- Check for working C compiler: /home/r0ng/utilities/ndk/bin/arm-linux-androideabi-gcc
-- Check for working C compiler: /home/r0ng/utilities/ndk/bin/arm-linux-androideabi-gcc -- broken
CMake Error at /usr/share/cmake-3.5/Modules/CMakeTestCCompiler.cmake:61 (message):
The C compiler "/home/r0ng/utilities/ndk/bin/arm-linux-androideabi-gcc" is
not able to compile a simple test program.
It fails with the following output:
Change Dir: /home/r0ng/projects/relic/build/CMakeFiles/CMakeTmp
Run Build Command:"/usr/bin/make" "cmTC_8d7ca/fast"
/usr/bin/make -f CMakeFiles/cmTC_8d7ca.dir/build.make
CMakeFiles/cmTC_8d7ca.dir/build
make[1]: Entering directory
'/home/r0ng/projects/relic/build/CMakeFiles/CMakeTmp'
Building C object CMakeFiles/cmTC_8d7ca.dir/testCCompiler.c.o
/home/r0ng/utilities/ndk/bin/arm-linux-androideabi-gcc
--sysroot=/home/r0ng/utilities/ndk -o
CMakeFiles/cmTC_8d7ca.dir/testCCompiler.c.o -c
/home/r0ng/projects/relic/build/CMakeFiles/CMakeTmp/testCCompiler.c
Linking C executable cmTC_8d7ca
/usr/bin/cmake -E cmake_link_script CMakeFiles/cmTC_8d7ca.dir/link.txt
--verbose=1
/home/r0ng/utilities/ndk/bin/arm-linux-androideabi-gcc
--sysroot=/home/r0ng/utilities/ndk
CMakeFiles/cmTC_8d7ca.dir/testCCompiler.c.o -o cmTC_8d7ca -rdynamic
/home/r0ng/utilities/ndk/bin/../lib/gcc/arm-linux-androideabi/4.9.x/../../../../arm-linux-androideabi/bin/ld:
error: cannot open crtbegin_dynamic.o: No such file or directory
/home/r0ng/utilities/ndk/bin/../lib/gcc/arm-linux-androideabi/4.9.x/../../../../arm-linux-androideabi/bin/ld:
error: cannot open crtend_android.o: No such file or directory
/home/r0ng/utilities/ndk/bin/../lib/gcc/arm-linux-androideabi/4.9.x/../../../../arm-linux-androideabi/bin/ld:
error: cannot find -lc
/home/r0ng/utilities/ndk/bin/../lib/gcc/arm-linux-androideabi/4.9.x/../../../../arm-linux-androideabi/bin/ld:
error: cannot find -ldl
collect2: error: ld returned 1 exit status
CMakeFiles/cmTC_8d7ca.dir/build.make:97: recipe for target 'cmTC_8d7ca'
failed
make[1]: *** [cmTC_8d7ca] Error 1
make[1]: Leaving directory
'/home/r0ng/projects/relic/build/CMakeFiles/CMakeTmp'
Makefile:126: recipe for target 'cmTC_8d7ca/fast' failed
make: *** [cmTC_8d7ca/fast] Error 2
CMake will not be able to correctly generate this project.
Call Stack (most recent call first):
CMakeLists.txt:6 (project)
-- Configuring incomplete, errors occurred!
See also "/home/r0ng/projects/relic/build/CMakeFiles/CMakeOutput.log".
See also "/home/r0ng/projects/relic/build/CMakeFiles/CMakeError.log".
It seems that the compiler is unable to find "crtbegin_dynamic.o", "crtend_android.o", "libc" neither "libdl". But when I checked, those files are all in the folder $HOME/utilities/ndk/sysroot/usr/lib. And I already set the --sysroot in CC, AR and RANLIB.
Update 1 :
After changed the toolchain generation command based on Dan Albert's comment, The command cmake .. is able to be run successfully. But when I run make . I got following error:
arm-linux-androideabi-gcc-4.9.x: error: unrecognized command line option '-m64'
src/CMakeFiles/relic.dir/build.make:62: recipe for target 'src/CMakeFiles/relic.dir/relic_err.c.o' failed
make[2]: *** [src/CMakeFiles/relic.dir/relic_err.c.o] Error 1
CMakeFiles/Makefile2:120: recipe for target 'src/CMakeFiles/relic.dir/all' failed
make[1]: *** [src/CMakeFiles/relic.dir/all] Error 2
Makefile:138: recipe for target 'all' failed
make: *** [all] Error 2
Thanks,
Environment:
OS: Ubuntu 16.04 LTS
gcc / g++: 4.9.3
AOSP: 5.1.1_r30
NDK: android-ndk-r12b
cmake: 3.5.1
If you want to use cmake, you don't need a standalone toolchain. Android Studio natively supports cmake now: http://tools.android.com/tech-docs/external-c-builds
NDK r13 (not released yet) will also ship a cmake toolchain file for using cmake directly (the method shown in https://stackoverflow.com/a/5099229/632035).
You shouldn't add --sysroot= explicitly. Standalone toolchain already knows about proper one.

How to fix "*** [obj/flash_board_cstartup.o] Error 2"

I am trying to get up to speed with the SAM7S examples pack "at91sam7s-ek" available from the Atmel website.
When I load any project into Eclipse I get the following error after building project.
make: *** [obj/flash_board_cstartup.o] Error 2
I have checked that paths are correct and that the files are where they are supposed to be.
Is there anyone that can help me to get this running or can anyone recommend a better set of examples that actually work for the SAM7S devices?
The CDT build console is :
18:58:29 **** Incremental Build of configuration Default for project test_project ****
make all
arm-none-eabi-gcc -g -O0 -I../at91lib/boards/asn442g -I../at91lib/peripherals -I../at91lib/components -I../at91lib -I. -I../at91lib/utility -I../external_libs/ethernet/lwip/src/include -I../external_libs/ethernet/lwip/src/include/lwip -I../external_libs/ethernet/lwip/src/include/ipv4 -I./system/modbus/tcp -I./system/modbus/tcp/arch -I./system/dal/dalAdc -I./system/dal/dalHoldingRegisters -I./system/dal/dalTimer -I./system/bll/bllModbusTCP -I./system/drivers/drvGprsLink -I./system/drivers/drvAtmBus -I./system/hal/halUsart1 -I./system/hal/halGpio -I./system/hal/halUsart0 -I./system/drv/drvAtmBus -Dat91sam7x256 -D__ASSEMBLY__ -Dflash -c -o obj/flash_board_cstartup.o ../at91lib/boards/asn442g/board_cstartup.S
process_begin: CreateProcess(NULL, arm-none-eabi-gcc -g -O0 -I../at91lib/boards/asn442g -I../at91lib/peripherals -I../at91lib/components -I../at91lib -I. -I../at91lib/utility -I../external_libs/ethernet/lwip/src/include -I../external_libs/ethernet/lwip/src/include/lwip -I../external_libs/ethernet/lwip/src/include/ipv4 -I./system/modbus/tcp -I./system/modbus/tcp/arch -I./system/dal/dalAdc -I./system/dal/dalHoldingRegisters -I./system/dal/dalTimer -I./system/bll/bllModbusTCP -I./system/drivers/drvGprsLink -I./system/drivers/drvAtmBus -I./system/hal/halUsart1 -I./system/hal/halGpio -I./system/hal/halUsart0 -I./system/drv/drvAtmBus -Dat91sam7x256 -D__ASSEMBLY__ -Dflash -c -o obj/flash_board_cstartup.o../at91lib/boards/asn442g/board_cstartup.S, ...) failed.
make (e=2): The system cannot find the file specified.
make: *** [obj/flash_board_cstartup.o] Error 2
18:58:33 Build Finished (took 3s.647ms)
When make return Error nn, it means that a command that make has executed has returned a non-zero value nn. You need to look at the error message for teh command that failed, rather than teh final status of make - make has not failed; your build has failed.
In this case, the relevant error message (elided) is:
process_begin: CreateProcess(NULL, arm-none-eabi-gcc [...] obj/flash_board_cstartup.o
../at91lib/boards/asn442g/board_cstartup.S, ...) failed.
It appears on the face of it that the compiler arm-none-eabi-gcc cannot be found. Is it installed, and does the PATH environment variable include its location?

Error occurs when compiling with GCC

I am attempting to compile a C program with multiple files on window platform. However, when I make it, errors are occurred. I have already tried to modify command in makefile but still could not fix it.
This is my GCC command:
gcc -o "SYSMONTR" $(OBJPATH)/chkdsksp ../chkdsksp.c -g -I"$(DB2PATH)/include" -I"$(MYLIBDIR)" $(MYIQDIR)/iqclilib.a $(OBJPATH)/icrou.a -lc -ldb2 -lnsl -L"$(DB2PATH)/lib"
This is result:
gcc -o "SYSMONTR" ../../iLINKOBJ/chkdsksp ../chkdsksp.c -g -I"C:/Program Files/IBM/SQLLIB/include" -I"../../iLINKCLIB" ../../iLINKIQOBJ/iqclilib.a ../../iLINKOBJ/icrou.a -lc -ldb2 -lnsl -L"C:/Program Files/IBM/SQLLIB/lib"
../../iLINKOBJ/chkdsksp: file not recognized: File format not recognized
collect2: error: ld returned 1 exit status
makefile:49: recipe for target `SYSMONTR' failed
make: *** [SYSMONTR] Error 1
What could cause such error and what should I do with it? Using cygwin on Window (IDE: Eclipse).
Any supports will be appreciated.
If chkdsksp is an object file built by another team to run on AIX, you cannot expect it to function -- or even be recognized by your compiler -- on Cygwin. You must contact that team and get a) the source code or b) a version of the object file compiled for your platform (and tested).

Resources