Error while building OpenSSL for android using ndk - android-ndk

I am trying to build openSSL for android using ndk. I am using dockerFile concept. I have set few environment variables as per suggested in http://wiki.openssl.org/index.php/Android. Now I am getting following error:
make[2]: Entering directory `/Android/openssl/apps'
( :; LIBDEPS="${LIBDEPS:--L.. -lssl -L.. -lcrypto -ldl}"; LDCMD="${LDCMD:-arm-l
inux-androideabi-gcc}"; LDFLAGS="${LDFLAGS:--DOPENSSL_THREADS -D_REENTRANT -DDSO
_DLFCN -DHAVE_DLFCN_H --static -Wa,--noexecstack -march=armv7-a -mandroid -I/And
roid/android-ndk-r10c/platforms/android-19/arch-arm/usr/include -B/Android/andro
id-ndk-r10c/platforms/android-19/arch-arm/usr/lib -O3 -fomit-frame-pointer -Wall
-DOPENSSL_BN_ASM_MONT -DOPENSSL_BN_ASM_GF2m -DSHA1_ASM -DSHA256_ASM -DSHA512_AS
M -DAES_ASM -DBSAES_ASM -DGHASH_ASM}"; LIBPATH=`for x in $LIBDEPS; do echo $x; d
one | sed -e 's/^ *-L//;t' -e d | uniq`; LIBPATH=`echo $LIBPATH | sed -e 's/ /:/
g'`; LD_LIBRARY_PATH=$LIBPATH:$LD_LIBRARY_PATH ${LDCMD} ${LDFLAGS} -o ${APPNAME:
=openssl} openssl.o verify.o asn1pars.o req.o dgst.o dh.o dhparam.o enc.o passwd
.o gendh.o errstr.o ca.o pkcs7.o crl2p7.o crl.o rsa.o rsautl.o dsa.o dsaparam.o
ec.o ecparam.o x509.o genrsa.o gendsa.o genpkey.o s_server.o s_client.o speed.o
s_time.o apps.o s_cb.o s_socket.o app_rand.o version.o sess_id.o ciphers.o nseq.
o pkcs12.o pkcs8.o pkey.o pkeyparam.o pkeyutl.o spkac.o smime.o cms.o rand.o eng
ine.o ocsp.o prime.o ts.o srp.o ${LIBDEPS} )
/Android/toolchain-arm/bin/../lib/gcc/arm-linux-androideabi/4.9/../../../../arm-linux-androideabi/bin/ld: error: cannot find -ldl
../libcrypto.a(dso_dlfcn.o):dso_dlfcn.c:function dlfcn_globallookup: error: unde
fined reference to 'dlopen'
../libcrypto.a(dso_dlfcn.o):dso_dlfcn.c:function dlfcn_globallookup: error: unde
fined reference to 'dlsym'
../libcrypto.a(dso_dlfcn.o):dso_dlfcn.c:function dlfcn_globallookup: error: unde
fined reference to 'dlclose'
../libcrypto.a(dso_dlfcn.o):dso_dlfcn.c:function dlfcn_bind_func: error: undefin
ed reference to 'dlsym'
../libcrypto.a(dso_dlfcn.o):dso_dlfcn.c:function dlfcn_bind_func: error: undefin
ed reference to 'dlerror'
../libcrypto.a(dso_dlfcn.o):dso_dlfcn.c:function dlfcn_bind_var: error: undefine
d reference to 'dlsym'
../libcrypto.a(dso_dlfcn.o):dso_dlfcn.c:function dlfcn_bind_var: error: undefine
d reference to 'dlerror'
../libcrypto.a(dso_dlfcn.o):dso_dlfcn.c:function dlfcn_load: error: undefined re
ference to 'dlopen'
../libcrypto.a(dso_dlfcn.o):dso_dlfcn.c:function dlfcn_load: error: undefined re
ference to 'dlclose'
../libcrypto.a(dso_dlfcn.o):dso_dlfcn.c:function dlfcn_load: error: undefined re
ference to 'dlerror'
../libcrypto.a(dso_dlfcn.o):dso_dlfcn.c:function dlfcn_unload: error: undefined
reference to 'dlclose'
collect2: error: ld returned 1 exit status
make[2]: Leaving directory `/Android/openssl/apps'
make[2]: *** [link_app.] Error 1
make[1]: *** [openssl] Error 2
make[1]: Leaving directory `/Android/openssl/apps'
make: *** [build_apps] Error 1
INFO[0135] The command [/bin/sh -c cd openssl && ./config --static no-ssl2 no-ss
l3 no-comp no-hw no-engine && make depend && make && ls -hs . && cp l
ibssl.a /Android/output] returned a non-zero code: 2
docker#boot2docker:/home/curl_ssl$
Do you have suggestions to resolve above error? I am not able to find what is reason behind such error.

Android has openssl already. Perhaps you do not need to compile them. Try answer from this question Compiling OpenSSL on Android

Related

emsdk compilation. what flags do i needfor sucsess?

Here are my compiler logs I don't quite understand what to do
$ emmake make CFLAGS="-fstack-protector-strong" LDFLAGS="-fstack-protector-strong"
make: make CFLAGS=-fstack-protector-strong LDFLAGS=-fstack-protector-strong
emcc -fstack-protector-strong -fstack-protector-strong -o mkp224o.tmp main.c.o worker.c.o yaml.c.o vec.c.o cpucount.c.o base32_to.c.o base32_from.c.o base64_to.c.o base64_from.c.o ioutil.c.o keccak.c.o -lpthread -lsodium && mv mkp224o.tmp mkp224o
wasm-ld-13: error: /usr/share/emscripten/cache/sysroot/lib/wasm32-emscripten/libsodium.a(libsodium_la-hash_sha256_cp.o): undefined symbol: __stack_chk_guard
wasm-ld-13: error: /usr/share/emscripten/cache/sysroot/lib/wasm32-emscripten/libsodium.a(libsodium_la-hash_sha256_cp.o): undefined symbol: __stack_chk_guard
wasm-ld-13: error: /usr/share/emscripten/cache/sysroot/lib/wasm32-emscripten/libsodium.a(libsodium_la-hash_sha256_cp.o): undefined symbol: __stack_chk_guard
wasm-ld-13: error: /usr/share/emscripten/cache/sysroot/lib/wasm32-emscripten/libsodium.a(libsodium_la-hash_sha256_cp.o): undefined symbol: __stack_chk_guard
wasm-ld-13: error: /usr/share/emscripten/cache/sysroot/lib/wasm32-emscripten/libsodium.a(libsodium_la-hash_sha256_cp.o): undefined symbol: __stack_chk_guard
wasm-ld-13: error: /usr/share/emscripten/cache/sysroot/lib/wasm32-emscripten/libsodium.a(libsodium_la-hash_sha256_cp.o): undefined symbol: __stack_chk_guard
wasm-ld-13: error: /usr/share/emscripten/cache/sysroot/lib/wasm32-emscripten/libsodium.a(libsodium_la-hash_sha256_cp.o): undefined symbol: __stack_chk_guard
wasm-ld-13: error: /usr/share/emscripten/cache/sysroot/lib/wasm32-emscripten/libsodium.a(libsodium_la-hash_sha256_cp.o): undefined symbol: __stack_chk_guard
wasm-ld-13: error: /usr/share/emscripten/cache/sysroot/lib/wasm32-emscripten/libsodium.a(libsodium_la-hash_sha256_cp.o): undefined symbol: __stack_chk_guard
wasm-ld-13: error: /usr/share/emscripten/cache/sysroot/lib/wasm32-emscripten/libsodium.a(libsodium_la-hash_sha256_cp.o): undefined symbol: __stack_chk_guard
wasm-ld-13: error: /usr/share/emscripten/cache/sysroot/lib/wasm32-emscripten/libsodium.a(libsodium_la-hash_sha256_cp.o): undefined symbol: __stack_chk_guard
wasm-ld-13: error: /usr/share/emscripten/cache/sysroot/lib/wasm32-emscripten/libsodium.a(libsodium_la-hash_sha256_cp.o): undefined symbol: __stack_chk_guard
wasm-ld-13: error: /usr/share/emscripten/cache/sysroot/lib/wasm32-emscripten/libsodium.a(libsodium_la-hash_sha256_cp.o): undefined symbol: __stack_chk_guard
wasm-ld-13: error: /usr/share/emscripten/cache/sysroot/lib/wasm32-emscripten/libsodium.a(libsodium_la-hash_sha256_cp.o): undefined symbol: __stack_chk_guard
emcc: error: '/usr/bin/wasm-ld-13 -o mkp224o.wasm main.c.o worker.c.o yaml.c.o vec.c.o cpucount.c.o base32_to.c.o base32_from.c.o base64_to.c.o base64_from.c.o ioutil.c.o keccak.c.o /usr/share/emscripten/cache/sysroot/lib/wasm32-emscripten/libsodium.a -L/usr/share/emscripten/cache/sysroot/lib/wasm32-emscripten -lGL -lal -lhtml5 -lstubs-debug -lnoexit -lc-debug -ldlmalloc -lcompiler_rt -lc++-noexcept -lc++abi-noexcept -lsockets -mllvm -combiner-global-alias-analysis=false -mllvm -enable-emscripten-sjlj -mllvm -disable-lsr --import-undefined --strip-debug --export-if-defined=main --export-if-defined=__start_em_asm --export-if-defined=__stop_em_asm --export-if-defined=__stdio_exit --export=emscripten_stack_get_end --export=emscripten_stack_get_free --export=emscripten_stack_get_base --export=emscripten_stack_init --export=stackSave --export=stackRestore --export=stackAlloc --export=__wasm_call_ctors --export=__errno_location --export=malloc --export=free --export=emscripten_main_thread_process_queued_calls --export-table -z stack-size=5242880 --initial-memory=16777216 --no-entry --max-memory=16777216 --global-base=1024' failed (returned 1)
make: *** [GNUmakefile:99: mkp224o] Error 1
emmake: error: 'make CFLAGS=-fstack-protector-strong LDFLAGS=-fstack-protector-strong' failed (returned 2)
The problem is solved, but I did not track at what step it was done, since I walked in circles many times.
From the moment it didn't work for me, I did:
-installed bison and gawk
sudo apt install bison gawk
-copied the "c++" folder from the Include folder to the /usr/share/emscripten/cache/sysroot/include directory.
switched to providing python, with the commands:
python3 '/usr/share/emscripten/emconfigure.py' ./configure --prefix="$(pwd)/install"
python3 '/usr/share/emscripten/emmake.py' make clean
python3 '/usr/share/emscripten/emmake.py' make
when code errors occur, set
sudo apt install python3-pysodium
after I solved a couple of compilation errors (from a very long list of errors) and corrected by type in terminal:
emcc -Wall -Wno-error -Wextra -Wno-unused-function -Wmissing-prototypes -Wstrict-prototypes -x c++ -g -O2 -lm -ldl -Wall -Wpointer-arith -finline-functions -ffast-math -DED25519_donna -fPIE -DSTATISTICS -DPASSPHRASE -DVERSION='"unknown"' -D'CRYPTO_NAMESPACETOP=crypto_sign_ed25519_donna' -D'_CRYPTO_NAMESPACETOP=crypto_sign_ed25519_donna' -D'CRYPTO_NAMESPACE(name)=crypto_sign_ed25519_donna##name' -D'_CRYPTO_NAMESPACE(name)=crypto_sign_ed25519_donna ##name' -c -o main.c.o.tmp main.c && mv main.c.o.tmp main.c.o
and then finished compiling
python3 '/usr/share/emscripten/emmake.py' make

make command error: undefined reference to `pthread_create

I was trying to run the codes from sourceforge.net, but when I was trying to run the "make" command in linux, I got the following error message:
make all-recursive
make[1]: Entering directory `/home/lliu/MyDoc/rsvp-agent/trunk/agent_rsvp'
Making all in src
make[2]: Entering directory `/home/lliu/MyDoc/rsvp-agent/trunk/agent_rsvp/src'
/bin/sh ../libtool --mode=link --tag=CXX g++ -g -O2 -o agent_rsvp agent_rsvp.o configuration.o floatformat.o generic_interface.o ip_mask.o ip_route.o mgmt_interface.o mgmt_packet.o mpls_ioctl.o rsvp_configuration.o rsvp_connection.o rsvp_dispatcher.o rsvp_error.o rsvp_packet.o rsvp_socket.o semaphore.o tools.o verbose.o
g++ -g -O2 -o agent_rsvp agent_rsvp.o configuration.o floatformat.o generic_interface.o ip_mask.o ip_route.o mgmt_interface.o mgmt_packet.o mpls_ioctl.o rsvp_configuration.o rsvp_connection.o rsvp_dispatcher.o rsvp_error.o rsvp_packet.o rsvp_socket.o semaphore.o tools.o verbose.o
mgmt_interface.o: In function `mgmt_interface::init()':
/home/lliu/MyDoc/rsvp-agent/trunk/agent_rsvp/src/mgmt_interface.cpp:108: undefined reference to `pthread_create'
/home/lliu/MyDoc/rsvp-agent/trunk/agent_rsvp/src/mgmt_interface.cpp:109: undefined reference to `pthread_create'
rsvp_connection.o: In function `rsvp_connection::create_refresh_thread()':
/home/lliu/MyDoc/rsvp-agent/trunk/agent_rsvp/src/rsvp_connection.cpp:136: undefined reference to `pthread_create'
rsvp_dispatcher.o: In function `rsvp_dispatcher::init(unsigned int)':
/home/lliu/MyDoc/rsvp-agent/trunk/agent_rsvp/src/rsvp_dispatcher.cpp:72: undefined reference to `pthread_create'
collect2: ld returned 1 exit status
make[2]: *** [agent_rsvp] Error 1
make[2]: Leaving directory `/home/lliu/MyDoc/rsvp-agent/trunk/agent_rsvp/src'
make[1 ]: * ** [all-recursive] Error 1
make[1 ]: Leaving directory `/home/lliu/MyDoc/rsvp-agent/trunk/agent_rsvp'
make: *** [all] Error 2

Trying to bootstrap gcc/glibc toolchain

I'm trying to bootstrap the gcc/glibc toolchain. It always fails to build failures. I have been trying dozens of times with different methods.
Here is how I have been trying to bootstrap:
path:
export PATH=/home/defer/dev/linux/bin:/usr/bin:/bin:/usr/x86_64-pc-linux-gnu/gcc-bin/4.8.2
binutils:
../configure --prefix=/home/defer/dev/linux --target=x86_64-pc-linux-gnu --with-sysroot=/home/defer/dev/linux --with-lib-path=/home/defer/dev/linux/lib --disable-nls --disable-werror
gcc stage1:
../configure --target=x86_64-pc-linux-gnu --prefix=/home/defer/dev/linux --with-sysroot=/home/defer/dev/linux --with-newlib --without-headers --with-native-system-header-dir=/home/defer/dev/linux/include --disable-nls
--disable-shared --disable-multilib --disable-decimal-float --disable-threads --disable-libatomic --disable-libgomp --disable-libitm --disable-libmudflap --disable-libquadmath --disable-libsanitizer --disable-libssp --disable-libstdc++-v3 --enable-languages=c,c++
linux headers:
make INSTALL_HDR_PATH=/home/defer/dev/linux headers_install
glibc:
../configure --prefix=/home/defer/dev/linux --host=x86_64-pc-linux-gnu --build=x86_64-pc-linux-gnu --disable-profile --enable-kernel=2.6.32 --with-headers=/home/defer/dev/linux/include libc_cv_forced_unwind=yes libc_cv_ctors_header=yes libc_cv_c_cleanup=yes
Here are errors I get while building glibc:
a - ns_netint.os
a - ns_ttl.os
a - ns_print.os
a - ns_samedomain.os
a - ns_date.os
cd /home/defer/dev/linux/src/glibc-2.19/glibc-build/resolv && /home/defer/dev/linux/lib/gcc/x86_64-pc-linux-gnu/4.8.2/../../../../x86_64-pc-linux-gnu/bin/ar cruv libnss_dns_pic.a dns-host.os dns-network.os dns-canon.os
cd /home/defer/dev/linux/src/glibc-2.19/glibc-build/resolv && /home/defer/dev/linux/lib/gcc/x86_64-pc-linux-gnu/4.8.2/../../../../x86_64-pc-linux-gnu/bin/ar cruv libanl.a gai_cancel.o gai_error.o gai_misc.o gai_notify.o gai_suspend.o getaddrinfo_a.o
a - dns-host.os
a - dns-network.os
a - dns-canon.os
x86_64-pc-linux-gnu-gcc -shared -static-libgcc -Wl,-O1 -Wl,-z,defs -Wl,-dynamic-linker=/home/defer/dev/linux/lib/ld-linux-x86-64.so.2 -B/home/defer/dev/linux/src/glibc-2.19/glibc-build/csu/ -Wl,--version-script=/home/defer/dev/linux/src/glibc-2.19/glibc-build/libresolv.map -Wl,-soname=libresolv.so.2 -Wl,-z,combreloc -Wl,-z,relro -Wl,--hash-style=both -L/home/defer/dev/linux/src/glibc-2.19/glibc-build -L/home/defer/dev/linux/src/glibc-2.19/glibc-build/math -L/home/defer/dev/linux/src/glibc-2.19/glibc-build/elf -L/home/defer/dev/linux/src/glibc-2.19/glibc-build/dlfcn -L/home/defer/dev/linux/src/glibc-2.19/glibc-build/nss -L/home/defer/dev/linux/src/glibc-2.19/glibc-build/nis -L/home/defer/dev/linux/src/glibc-2.19/glibc-build/rt -L/home/defer/dev/linux/src/glibc-2.19/glibc-build/resolv -L/home/defer/dev/linux/src/glibc-2.19/glibc-build/crypt -L/home/defer/dev/linux/src/glibc-2.19/glibc-build/nptl -Wl,-rpath-link=/home/defer/dev/linux/src/glibc-2.19/glibc-build:/home/defer/dev/linux/src/glibc-2.19/glibc-build/math:/home/defer/dev/linux/src/glibc-2.19/glibc-build/elf:/home/defer/dev/linux/src/glibc-2.19/glibc-build/dlfcn:/home/defer/dev/linux/src/glibc-2.19/glibc-build/nss:/home/defer/dev/linux/src/glibc-2.19/glibc-build/nis:/home/defer/dev/linux/src/glibc-2.19/glibc-build/rt:/home/defer/dev/linux/src/glibc-2.19/glibc-build/resolv:/home/defer/dev/linux/src/glibc-2.19/glibc-build/crypt:/home/defer/dev/linux/src/glibc-2.19/glibc-build/nptl -o /home/defer/dev/linux/src/glibc-2.19/glibc-build/resolv/libresolv.so -T /home/defer/dev/linux/src/glibc-2.19/glibc-build/shlib.lds /home/defer/dev/linux/src/glibc-2.19/glibc-build/csu/abi-note.o -Wl,--whole-archive /home/defer/dev/linux/src/glibc-2.19/glibc-build/resolv/libresolv_pic.a -Wl,--no-whole-archive /home/defer/dev/linux/src/glibc-2.19/glibc-build/elf/interp.os -Wl,--start-group /home/defer/dev/linux/src/glibc-2.19/glibc-build/libc.so /home/defer/dev/linux/src/glibc-2.19/glibc-build/libc_nonshared.a -Wl,--as-needed /home/defer/dev/linux/src/glibc-2.19/glibc-build/elf/ld.so -Wl,--no-as-needed -Wl,--end-group
a - gai_cancel.o
a - gai_error.o
a - gai_misc.o
a - gai_notify.o
a - gai_suspend.o
a - getaddrinfo_a.o
cd /home/defer/dev/linux/src/glibc-2.19/glibc-build/resolv && /home/defer/dev/linux/lib/gcc/x86_64-pc-linux-gnu/4.8.2/../../../../x86_64-pc-linux-gnu/bin/ar cruv libanl_pic.a gai_cancel.os gai_error.os gai_misc.os gai_notify.os gai_suspend.os getaddrinfo_a.os
a - gai_cancel.os
a - gai_error.os
a - gai_misc.os
a - gai_notify.os
a - gai_suspend.os
a - getaddrinfo_a.os
x86_64-pc-linux-gnu-gcc -shared -static-libgcc -Wl,-O1 -Wl,-z,defs -Wl,-dynamic-linker=/home/defer/dev/linux/lib/ld-linux-x86-64.so.2 -B/home/defer/dev/linux/src/glibc-2.19/glibc-build/csu/ -Wl,--version-script=/home/defer/dev/linux/src/glibc-2.19/glibc-build/libanl.map -Wl,-soname=libanl.so.1 -Wl,-z,combreloc -Wl,-z,relro -Wl,--hash-style=both -L/home/defer/dev/linux/src/glibc-2.19/glibc-build -L/home/defer/dev/linux/src/glibc-2.19/glibc-build/math -L/home/defer/dev/linux/src/glibc-2.19/glibc-build/elf -L/home/defer/dev/linux/src/glibc-2.19/glibc-build/dlfcn -L/home/defer/dev/linux/src/glibc-2.19/glibc-build/nss -L/home/defer/dev/linux/src/glibc-2.19/glibc-build/nis -L/home/defer/dev/linux/src/glibc-2.19/glibc-build/rt -L/home/defer/dev/linux/src/glibc-2.19/glibc-build/resolv -L/home/defer/dev/linux/src/glibc-2.19/glibc-build/crypt -L/home/defer/dev/linux/src/glibc-2.19/glibc-build/nptl -Wl,-rpath-link=/home/defer/dev/linux/src/glibc-2.19/glibc-build:/home/defer/dev/linux/src/glibc-2.19/glibc-build/math:/home/defer/dev/linux/src/glibc-2.19/glibc-build/elf:/home/defer/dev/linux/src/glibc-2.19/glibc-build/dlfcn:/home/defer/dev/linux/src/glibc-2.19/glibc-build/nss:/home/defer/dev/linux/src/glibc-2.19/glibc-build/nis:/home/defer/dev/linux/src/glibc-2.19/glibc-build/rt:/home/defer/dev/linux/src/glibc-2.19/glibc-build/resolv:/home/defer/dev/linux/src/glibc-2.19/glibc-build/crypt:/home/defer/dev/linux/src/glibc-2.19/glibc-build/nptl -o /home/defer/dev/linux/src/glibc-2.19/glibc-build/resolv/libanl.so -T /home/defer/dev/linux/src/glibc-2.19/glibc-build/shlib.lds /home/defer/dev/linux/src/glibc-2.19/glibc-build/csu/abi-note.o -Wl,--whole-archive /home/defer/dev/linux/src/glibc-2.19/glibc-build/resolv/libanl_pic.a -Wl,--no-whole-archive /home/defer/dev/linux/src/glibc-2.19/glibc-build/elf/interp.os /home/defer/dev/linux/src/glibc-2.19/glibc-build/nptl/libpthread_nonshared.a /home/defer/dev/linux/src/glibc-2.19/glibc-build/nptl/libpthread.so -Wl,--start-group /home/defer/dev/linux/src/glibc-2.19/glibc-build/libc.so /home/defer/dev/linux/src/glibc-2.19/glibc-build/libc_nonshared.a -Wl,--as-needed /home/defer/dev/linux/src/glibc-2.19/glibc-build/elf/ld.so -Wl,--no-as-needed -Wl,--end-group
rm -f /home/defer/dev/linux/src/glibc-2.19/glibc-build/resolv/libanl.so.1.new
/home/defer/dev/linux/src/glibc-2.19/glibc-build/resolv/libresolv_pic.a(ns_print.os): In function `__GI_ns_sprintrrf':
/home/defer/dev/linux/src/glibc-2.19/resolv/ns_print.c:99: undefined reference to `__stack_chk_guard'
/home/defer/dev/linux/src/glibc-2.19/resolv/ns_print.c:728: undefined reference to `__stack_chk_guard'
/home/defer/dev/linux/src/glibc-2.19/glibc-build/resolv/libresolv_pic.a(gethnamaddr.os): In function `getanswer':
/home/defer/dev/linux/src/glibc-2.19/resolv/gethnamaddr.c:180: undefined reference to `__stack_chk_guard'
/home/defer/dev/linux/src/glibc-2.19/resolv/gethnamaddr.c:483: undefined reference to `__stack_chk_guard'
/home/defer/dev/linux/src/glibc-2.19/glibc-build/resolv/libresolv_pic.a(gethnamaddr.os): In function `__GI_res_gethostbyname2':
/home/defer/dev/linux/src/glibc-2.19/resolv/gethnamaddr.c:510: undefined reference to `__stack_chk_guard'
/home/defer/dev/linux/src/glibc-2.19/glibc-build/resolv/libresolv_pic.a(gethnamaddr.os):/home/defer/dev/linux/src/glibc-2.19/resolv/gethnamaddr.c:636: more undefined references to `__stack_chk_guard' follow
collect2: error: ld returned 1 exit status
/bin/sh ../scripts/rellns-sh /home/defer/dev/linux/src/glibc-2.19/glibc-build/resolv/libanl.so /home/defer/dev/linux/src/glibc-2.19/glibc-build/resolv/libanl.so.1.new
../Makerules:438: recipe for target '/home/defer/dev/linux/src/glibc-2.19/glibc-build/resolv/libresolv.so' failed
make[2]: *** [/home/defer/dev/linux/src/glibc-2.19/glibc-build/resolv/libresolv.so] Error 1
make[2]: *** Waiting for unfinished jobs....
mv -f /home/defer/dev/linux/src/glibc-2.19/glibc-build/resolv/libanl.so.1.new /home/defer/dev/linux/src/glibc-2.19/glibc-build/resolv/libanl.so.1
make[2]: Leaving directory '/home/defer/dev/linux/src/glibc-2.19/resolv'
Makefile:213: recipe for target 'resolv/others' failed
make[1]: *** [resolv/others] Error 2
make[1]: Leaving directory '/home/defer/dev/linux/src/glibc-2.19'
Makefile:9: recipe for target 'all' failed
make: *** [all] Error 2
real 3m23.747s
user 9m57.851s
sys 1m21.334s
I solved the problem. Gentoo GCC had stack smash protection on by default.
I had to use:
CFLAGS="-O2 -fno-stack-protector" ../configure --prefix=/home/defer/dev/linux --host=x86_64-pc-linux-gnu --build=x86_64-pc-linux-gnu --disable-profile --enable-kernel=2.6.32 --with-headers=/home/defer/dev/linux/include libc_cv_forced_unwind=yes libc_cv_ctors_header=yes libc_cv_c_cleanup=yes

Makefile: build of c++ file on linux, unable to locate cuda libraries in opencv 2.4.6

Hopefully someone can help with this.
After rebuilding OpenCV 2.4.6 with Cuda Toolkit 5.5 on linux, an attempt was made to build a single c++ file that references OpenCV and CUDA using via make and a CLI g++ command. The input and output from each approach are shown below.
The Makefile attempts to reference the *.a files from OpenCV, but is not successful. The CLI g++ command attempts to reference *.so files, which it seems to do, however, some methods appear to be undefined.
Is it necessary for the Makefile to access only the OpenCV *.a files?
Makefile:
CFLAGS = -g Wall
LIBPATH = /data/content/cuda/opencv-2.4.6/lib
LIBS = -lopencv_calib3d_pch_dephelp -lopencv_contrib_pch_dephelp -lopencv_core_pch_dephelp -lopencv_features2d_pch_dephelp -lopencv_flann_pch_dephelp -lopencv_gpu_pch_dephelp -lopencv_haartraining_engine -lopencv_highgui_pch_dephelp -lopencv_imgproc_pch_dephelp -lopencv_legacy_pch_dephelp -lopencv_ml_pch_dephelp -lopencv_nonfree_pch_dephelp -lopencv_objdetect_pch_dephelp -lopencv_perf_calib3d_pch_dephelp -lopencv_perf_core_pch_dephelp -lopencv_perf_features2d_pch_dephelp -lopencv_perf_gpu_pch_dephelp -lopencv_perf_highgui_pch_dephelp -lopencv_perf_imgproc_pch_dephelp -lopencv_perf_nonfree_pch_dephelp -lopencv_perf_objdetect_pch_dephelp -lopencv_perf_photo_pch_dephelp -lopencv_perf_stitching_pch_dephelp -lopencv_perf_superres_pch_dephelp -lopencv_perf_video_pch_dephelp -lopencv_photo_pch_dephelp -lopencv_stitching_pch_dephelp -lopencv_superres_pch_dephelp -lopencv_test_calib3d_pch_dephelp -lopencv_test_contrib_pch_dephelp -lopencv_test_core_pch_dephelp -lopencv_test_features2d_pch_dephelp -lopencv_test_flann_pch_dephelp -lopencv_test_gpu_pch_dephelp -lopencv_test_highgui_pch_dephelp -lopencv_test_imgproc_pch_dephelp -lopencv_test_legacy_pch_dephelp -lopencv_test_ml_pch_dephelp -lopencv_test_nonfree_pch_dephelp -lopencv_test_objdetect_pch_dephelp -lopencv_test_photo_pch_dephelp -lopencv_test_stitching_pch_dephelp -lopencv_test_superres_pch_dephelp -lopencv_test_video_pch_dephelp -lopencv_ts_pch_dephelp -lopencv_video_pch_dephelp -lopencv_videostab_pch_dephelp -lopencv_gpu -lopencv_highgui
INCLUDEPATH1 = /usr/include/opencv2/core
INCLUDEPATH2 = /usr/include/opencv2/highgui
INCLUDEPATH3 = /usr/include/opencv2/gpu
all: tiff2png1.so
tiff2png1.so: main.o
g++ -o tiff2png1.so main.o **-L $(LIBPATH) $(LIB)**
main.o: main.cpp
g++ -c main.cpp -g -Wall -I $(INCLUDEPATH1) -I $(INCLUDEPATH2) -I $(INCLUDEPATH3) $(LIBPATH)
.PHONY: clean
clean:
rm -vf tiff2png1.so *.o
Makefile Output:
g++ -o tiff2png1.so main.o -L /data/content/cuda/opencv-2.4.6/lib
main.o: In function main':
/home/.../main.cpp:13: undefined reference tocv::gpu::getCudaEnabledDeviceCount()'
/home/.../main.cpp:15: undefined reference to cv::gpu::getDevice()'
/home/.../main.cpp:21: undefined reference tocv::imread(std::basic_string, std::allocator > const&, int)'
/home/.../main.cpp:27: undefined reference to cv::gpu::GpuMat::GpuMat(cv::Mat const&)'
/home/.../main.cpp:29: undefined reference tocv::gpu::Stream::Null()'
/home/.../main.cpp:29: undefined reference to cv::gpu::resize(cv::gpu::GpuMat const&, cv::gpu::GpuMat&, cv::Size_<int>, double, double, int, cv::gpu::Stream&)'
/home/.../main.cpp:42: undefined reference tocv::Mat::Mat(cv::gpu::GpuMat const&)'
/home/.../main.cpp:49: undefined reference to cv::_InputArray::_InputArray(cv::Mat const&)'
...
main.o: In function~GpuMat': /usr/include/opencv2/core/gpumat.hpp:374: undefined reference to `cv::gpu::GpuMat::release()'
collect2: ld returned 1 exit status
make: * [tiff2png1.so] Error 1
Command Line Build
$ g++ -o tx.exe main.o -L/data/content/cuda/opencv-2.4.6/lib -lopencv_gpu
Command Line Build Output
/data/content/cuda/opencv-2.4.6/lib/libopencv_gpu.so: undefined reference to `cv::gpu::convertTo(cv::gpu::GpuMat const&, cv::gpu::GpuMat&, double, double, CUstream_st*)'
/data/content/cuda/opencv-2.4.6/lib/libopencv_gpu.so: undefined reference to `cv::gpu::setTo(cv::gpu::GpuMat&, cv::Scalar_, cv::gpu::GpuMat const&, CUstream_st*)'
/data/content/cuda/opencv-2.4.6/lib/libopencv_gpu.so: undefined reference to `cv::gpu::setTo(cv::gpu::GpuMat&, cv::Scalar_, CUstream_st*)'
collect2: ld returned 1 exit status
It looks like you may have omitted an 'S' at the end of your variable in the linker target
**LIBS** = -lopencv_calib3d_pch_dephelp ...
tiff2png1.so: main.o
g++ -o tiff2png1.so main.o -L $(LIBPATH) $(**LIB**)
and so the -l options aren't being passed to the linker
g++ -o tiff2png1.so main.o -L /data/content/cuda/opencv-2.4.6/lib **should be here** main.o

Compiling wmii on Fedora 15 x86_64

I'm having trouble compiling wmii v3.9.2 on Fedora 15; Here's the interesting part (things break down at the linking stage):
% bmake -de
MAKE all libbio/
MAKE all libfmt/
MAKE all libregexp/
MAKE all libutf/
MAKE all libixp/
MAKE all doc/
MAKE all man/
MAKE all cmd/
MAKE all cmd/wmii/
MAKE all cmd/menu/
LD cmd/wmii9menu.out
/usr/bin/ld: wmii/xext.o: undefined reference to symbol 'XRenderFindVisualFormat'
/usr/bin/ld: note: 'XRenderFindVisualFormat' is defined in DSO /usr/lib64/libXrender.so.1 so try adding it to the linker command line
/usr/lib64/libXrender.so.1: could not read symbols: Invalid operation
collect2: ld returned 1 exit status
*** Failed target: wmii9menu.out
*** Failed command: ../util/link "cc" "$(pkg-config --libs 2>/dev/null) -g -L../lib -L/usr/lib64 ../lib/libregexp9.a ../lib/libbio.a ../lib/libfmt.a ../lib/libutf.a -L../lib -L/usr/lib64 ../lib/libregexp9.a ../lib/libbio.a ../lib/libfmt.a ../lib/libutf.a" wmii9menu.out wmii9menu.o clientutil.o wmii/x11.o wmii/xext.o wmii/geom.o wmii/map.o util.o ../lib/libixp.a $(pkg-config --libs xft xrandr xinerama) -lXext
*** Error code 1
Stop.
bmake: stopped in /srv/redhat/BUILD/wmii+ixp-3.9.2/cmd
*** Failed target: dall
*** Failed command: dirs="libbio libfmt libregexp libutf libixp doc man cmd libwmii_hack rc alternative_wmiircs"; set -e; targ=dall; targ=${targ#d}; for i in $dirs; do export WMII_HGVERSION=""; export BASE=$i/; if [ ! -d $i ]; then echo Skipping nonexistent directory: $i 1>&2; else echo MAKE $targ $BASE; (cd $i && bmake $targ) || exit ; fi; done
*** Error code 1
Stop.
bmake: stopped in /srv/redhat/BUILD/wmii+ixp-3.9.2
Finally, in config.mk, I have the following settings:
...
INCLUDES = -I. -I$(ROOT)/include -I$(INCLUDE) -I/usr/include
LIBS = -L$(ROOT)/lib -L/usr/lib64
...
LDFLAGS += -g $(LIBS)
SOLDFLAGS += $(LDFLAGS)
SHARED = -shared -Wl,-soname=$(SONAME)
STATIC = -static
...
With a little more manual resolution, the statement generating the error is essentially as follows:
gcc \
-o wmii9menu.out\
-L../lib -L/usr/lib $(pkg-config --libs xft xrandr xinerama xext)\
../lib/libregexp9.a ../lib/libbio.a ../lib/libfmt.a\
../lib/libutf.a ../lib/libixp.a\
wmii9menu.o clientutil.o util.o\
wmii/x11.o wmii/xext.o wmii/geom.o wmii/map.o
Here, the pkg-config resolves to the following, which by itself is perfectly correct:
-lXft -lXrandr -lXinerama -lXext
And the solution is as follows:
--- wmii+ixp-3.9.2/config.mk 2011-06-03 14:03:22.950163074 +1000
+++ wmii+ixp-3.9.2/config.mk 2011-06-03 14:03:16.086129011 +1000
## -32 +32 ##
-X11PACKAGES = xft
+X11PACKAGES = xft xext xrandr xrender xinerama

Resources