make command error: undefined reference to `pthread_create - linux

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

Related

openfst-1.6.5 cross compile failed

I have been working on the cross compilation of openfst-1.6.5.My cross compiler is gcc-linaro-6.3.1-2017.02-x86_64_aarch64-linux-gnu.
Every time I excute the order as below:
./configure --prefix=`pwd` --enable-static --enable-shared --enable-far --enable-ngram-fsts --build=armv8 --host=aarch64-linux-gnu
make -j 4
The result is always as below:
/data/jiachen/gcc-linaro-6.3.1-2017.02-x86_64_aarch64-linux-gnu/bin/../lib/gcc/aarch64-linux-gnu/6.3.1/../../../../aarch64-linux-gnu/bin/ld: warning: libfstfar.so.8, needed by ./.libs/libfstfarscript.so/, datanot/ jiachenfound/ gcc(-trylinaro -using6.3.1 --2017.02rpath- x86_64_aarch64or- linux--rpathgnu-/linkbin)/
...//.liblibs//gcclibfstfarscript.so/:aarch64 -undefinedlinux -referencegnu /to6.3.1 /`.fst.:/:.IsSTList.(/std.:.:/__cxx11.:.:/basic_stringaarch64<-charlinux,- gnustd/:bin:/char_traitsld<:char >warning,: stdlibfstfar.so.8:,: allocatorneeded< charby> .>/ .constlibs&/)libfstfarscript.so',
.not/ .foundlibs /(libfstfarscript.sotry: usingundefined -referencerpath toor `-fstrpath:-:linkIsSTTable)(
std.:/:.__cxx11libs:/:libfstfarscript.sobasic_string:< charundefined, referencestd :to: char_traits`<fstchar:>:,IsSTList (stdstd::::allocator__cxx11<:char:>basic_string <>char ,const &std):':
char_traits<char>, std::allocator<char> > const&)'
./.libs/libfstfarscript.so: undefined reference to `fst::IsSTTable(std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> > const&)'
collect2: error: ld returned 1 exit status
collect2: error: ld returned 1 exit status
make[4]: *** [farcreate] Error 1
make[4]: *** [farprintstrings] Error 1
/data/jiachen/gcc-linaro-6.3.1-2017.02-x86_64_aarch64-linux-gnu/bin/../lib/gcc/aarch64-linux-gnu/6.3.1/../../../../aarch64-linux-gnu/bin/ld: warning: libfstfar.so.8, needed by ./.libs/libfstfarscript.so, not found (try using -rpath or -rpath-link)
./.libs/libfstfarscript.so: undefined reference to `fst::IsSTList(std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> > const&)'
./.libs/libfstfarscript.so: undefined reference to `fst::IsSTTable(std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> > const&)'
collect2: error: ld returned 1 exit status
make[4]: *** [farcompilestrings] Error 1
/data/jiachen/gcc-linaro-6.3.1-2017.02-x86_64_aarch64-linux-gnu/bin/../lib/gcc/aarch64-linux-gnu/6.3.1/../../../../aarch64-linux-gnu/bin/ld: warning: libfstfar.so.8, needed by ./.libs/libfstfarscript.so, not found (try using -rpath or -rpath-link)
./.libs/libfstfarscript.so: undefined reference to `fst::IsSTList(std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> > const&)'
./.libs/libfstfarscript.so: undefined reference to `fst::IsSTTable(std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> > const&)'
collect2: error: ld returned 1 exit status
/data/jiachen/gcc-linaro-6.3.1-2017.02-x86_64_aarch64-linux-gnu/bin/../lib/gcc/aarch64-linux-gnu/6.3.1/../../../../aarch64-linux-gnu/bin/ld: warning: libfstfar.so.8, needed by ./.libs/libfstfarscript.so, not found (try using -rpath or -rpath-link)
./.libs/libfstfarscript.so: undefined reference to `fst::IsSTList(std::__cxx11::basic_string<char, stdmake[4]: :*** [farinfo] Error 1:
char_traits<char>, std::allocator<char> > const&)'
./.libs/libfstfarscript.so: undefined reference to `fst::IsSTTable(std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> > const&)'
collect2: error: ld returned 1 exit status
make[4]: *** [farisomorphic] Error 1
/data/jiachen/gcc-linaro-6.3.1-2017.02-x86_64_aarch64-linux-gnu/bin/../lib/gcc/aarch64-linux-gnu/6.3.1/../../../../aarch64-linux-gnu/bin/ld: warning: libfstfar.so.8, needed by ./.libs/libfstfarscript.so, not found (try using -rpath or -rpath-link)
./.libs/libfstfarscript.so: undefined reference to `fst::IsSTList(std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> > const&)'
./.libs/libfstfarscript.so: undefined reference to `fst::IsSTTable(std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> > const&)'
collect2: error: ld returned 1 exit status
make[4]: *** [farextract] Error 1
make[4]: Leaving directory `/data/jiachen/kaldi-aarch64/tools/openfst-1.6.5/src/extensions/far'
make[3]: *** [all-recursive] Error 1
make[3]: Leaving directory `/data/jiachen/kaldi-aarch64/tools/openfst-1.6.5/src/extensions'
make[2]: *** [all-recursive] Error 1
make[2]: Leaving directory `/data/jiachen/kaldi-aarch64/tools/openfst-1.6.5/src'
make[1]: *** [all-recursive] Error 1
make[1]: Leaving directory `/data/jiachen/kaldi-aarch64/tools/openfst-1.6.5'
make: *** [all] Error 2
The far extension cross compile failed.How can I solve this problem?
Faced the same issue while compiling kaldi. I had to remove --enable-far option from the line OPENFST_CONFIGURE in MakeFile. Source: here

link error with "undefined lua_xxxxx" when building lsnes

In my ubuntu 14.xx, I try to compile lsnes emulator to use the mario-ai script from aleju/mario-ai, and I've tried to google many solutions to solve the problem below:
Here is the output from the console:
make[3]: __all__.files' is up to date.
make[3]: Leaving directory/home/pengsuyu/software/lsnes/sourcecode/src/platform/macosx'
make[2]: Leaving directory /home/pengsuyu/software/lsnes/sourcecode/src/platform'
g++ -o lsnescat all_common.files all_platform.files-pthread -lboost_iostreams -lboost_filesystem -lboost_system -lz -lgcrypt -lgpg-error -L/usr/lib/x86_64-linux-gnu -lcurl -rdynamic -ldlcat core/all.ldflags lua/all.ldflags fonts/all.ldflags library/all.ldflags interface/all.ldflags video/all.ldflags emulation/all.ldflags cmdhelp/all.ldflags platform/all.ldflags
core/multitrack.o: In functionlua::state::get_string(int, std::string const&)':
/home/pengsuyu/software/lsnes/sourcecode/src/core/../../include/library/lua-base.hpp:317: undefined reference to lua_tolstring'
core/multitrack.o: In functionlua::state::get_bool(int, std::string const&)':
/home/pengsuyu/software/lsnes/sourcecode/src/core/../../include/library/lua-base.hpp:334: undefined reference to lua_toboolean'
core/multitrack.o: In functionlua::state::type(int)':
.
.
/home/pengsuyu/software/lsnes/sourcecode/src/library/lua.cpp:536: undefined reference to lua_close'
library/lua.o: In functionlua::state::pushcfunction(int ()(lua_State))':
/home/pengsuyu/software/lsnes/sourcecode/src/library/../../include/library/lua-base.hpp:504: undefined reference to lua_pushcclosure'
library/lua.o: In functionlua::state::getfield(int, char const*)':
/home/pengsuyu/software/lsnes/sourcecode/src/library/../../include/library/lua-base.hpp:506: undefined reference to lua_getfield'
library/lua.o: In functionlua::state::insert(int)':
/home/pengsuyu/software/lsnes/sourcecode/src/library/../../include/library/lua-base.hpp:509: undefined reference to lua_insert'
collect2: error: ld returned 1 exit status
make[1]: *** [lsnes] Error 1
make[1]: Leaving directory/home/pengsuyu/software/lsnes/sourcecode/src'
make: *** [src/all_files] Error 2
==================================
At the beginning, I think, the linker cannot find my lua library. So I tried to compile my main.cpp with test.lua.
main.cpp:
#include <stdio.h>
#include <iostream>
//extern "C"
//{
#include <lua.h>
#include <lualib.h>
#include <lauxlib.h>
//} // liblua5.1-c++.a
lua_State * L;
int main ()
{
L = lua_open();
luaL_openlibs(L);
luaL_dofile(L, "d:\\test.lua");
return 0;
}
test.lua:
print("Hello World");
I write a MakeFile to generate the executable file "main":
main:main.o
gcc -o $# $< -llua5.1 -lstdc++
main.o:
gcc -c main.cpp
clean:
-rm *.o
It works when I add the compile option "-llua5.1" and "-lstdc++" otherwise it throws the same error as I compiled lsnes
I am not familiar with gcc and Makefile. Please help me to solve this problem.
I've solved my question
The way to solve this problem is just to change one line in the file named "options.build".
1. find the line "LUA=lua" in options.build
2. change this line to "LUA=lua5.1"
because the needed library is 5.1, so if you want to build it successfully, you must use the "lua5.1" library however the default configuration is "lua" not "lua5.1"

Error while building OpenSSL for android using 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

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

Resources