F
frakie
Hi 'body,
I'm trying to compile a program which uses two static libraries.
One is wrote in C language the other is wrote in C++ but it's
functions are under extern "C" declaration.
Once I try to compile my file example.c I have to add the option -
lstdc++ 'cause of the C++ library.
I would like to avoid this option, so i tried to merge the C++
library
with libstdc++.a as follows:
mkdir junk
cd junk
ar x ../libmyC++lib.a
ar x ../stdlibc++.a
rm -f ../libmergedC++Lib.a
ar r ../libmergedC++Lib.a *.o
compiling my example.c file
gcc example.c -L. -lmyCLib -lmergedC++Lib
i get
home/myUser/lib/libmergedC++lib.a(ios-inst.o)
(.text._ZNKSt9basic_iosIcSt11char_traitsIcEE5widenEc+0xd5): In
function `std::basic_ios<char, std::char_traits<char> >::widen(char)
const':
: undefined reference to `__stack_chk_fail'
/home/myUser/lib/libmergedC++lib.a(istream-inst.o)
(.text._ZNSi5seekgExSt12_Ios_Seekdir+0xb1): In function
`std::basic_istream<char, std::char_traits<char> >::seekg(long long,
std::_Ios_Seekdir)':
: undefined reference to `__stack_chk_fail'
/home/myUser/lib/libmergedC++lib.a(istream-inst.o)
(.text._ZNSi5seekgESt4fposI11__mbstate_tE+0xd1): In function
: undefined reference to `__stack_chk_fail'
/home/myUser/lib/libmergedC++lib.a(istream-inst.o)
(.text._ZNSt13basic_istreamIwSt11char_traitsIwEE5seekgExSt12_Ios_Seekdir
+0xb1): In function `std::basic_istream<wchar_t,
std::char_traits<wchar_t> >::seekg(long long, std::_Ios_Seekdir)':
: undefined reference to `__stack_chk_fail'
/home/myUser/lib/libmergedC++lib.a(istream-inst.o)
(.text._ZNSt13basic_istreamIwSt11char_traitsIwEE5seekgESt4fposI11__mbstate_
tE
+0xd1): In function `std::basic_istream<wchar_t,
std::char_traits<wchar_t> >::seekg(std::fpos<__mbstate_t>)':
: undefined reference to `__stack_chk_fail'
/home/myUser/lib/libmergedC++lib.a(locale-inst.o)
(.text._ZNKSt8time_getIcSt19istreambuf_iteratorIcSt11char_traitsIcEEE15_M_e
xtract_nameES3_S3_RiPPKcjRSt8ios_baseRSt12_Ios_Iostate
+0x602): more undefined references to `__stack_chk_fail' follow
/home/myUser/lib/libmergedC++lib.a(cp-demangle.o)(.text
+0x3fb7): In function `d_demangle':
: undefined reference to `__stack_chk_fail_local'
collect2: ld returned 1 exit status
make[2]: *** [example] Error 1
make[1]: *** [all-recursive] Error 1
make: *** [all] Error 2
What's going wrong???
I'm trying to compile a program which uses two static libraries.
One is wrote in C language the other is wrote in C++ but it's
functions are under extern "C" declaration.
Once I try to compile my file example.c I have to add the option -
lstdc++ 'cause of the C++ library.
I would like to avoid this option, so i tried to merge the C++
library
with libstdc++.a as follows:
mkdir junk
cd junk
ar x ../libmyC++lib.a
ar x ../stdlibc++.a
rm -f ../libmergedC++Lib.a
ar r ../libmergedC++Lib.a *.o
compiling my example.c file
gcc example.c -L. -lmyCLib -lmergedC++Lib
i get
home/myUser/lib/libmergedC++lib.a(ios-inst.o)
(.text._ZNKSt9basic_iosIcSt11char_traitsIcEE5widenEc+0xd5): In
function `std::basic_ios<char, std::char_traits<char> >::widen(char)
const':
: undefined reference to `__stack_chk_fail'
/home/myUser/lib/libmergedC++lib.a(istream-inst.o)
(.text._ZNSi5seekgExSt12_Ios_Seekdir+0xb1): In function
`std::basic_istream<char, std::char_traits<char> >::seekg(long long,
std::_Ios_Seekdir)':
: undefined reference to `__stack_chk_fail'
/home/myUser/lib/libmergedC++lib.a(istream-inst.o)
(.text._ZNSi5seekgESt4fposI11__mbstate_tE+0xd1): In function
::seekg(std::fpos<__mbstate_t>)':
: undefined reference to `__stack_chk_fail'
/home/myUser/lib/libmergedC++lib.a(istream-inst.o)
(.text._ZNSt13basic_istreamIwSt11char_traitsIwEE5seekgExSt12_Ios_Seekdir
+0xb1): In function `std::basic_istream<wchar_t,
std::char_traits<wchar_t> >::seekg(long long, std::_Ios_Seekdir)':
: undefined reference to `__stack_chk_fail'
/home/myUser/lib/libmergedC++lib.a(istream-inst.o)
(.text._ZNSt13basic_istreamIwSt11char_traitsIwEE5seekgESt4fposI11__mbstate_
tE
+0xd1): In function `std::basic_istream<wchar_t,
std::char_traits<wchar_t> >::seekg(std::fpos<__mbstate_t>)':
: undefined reference to `__stack_chk_fail'
/home/myUser/lib/libmergedC++lib.a(locale-inst.o)
(.text._ZNKSt8time_getIcSt19istreambuf_iteratorIcSt11char_traitsIcEEE15_M_e
xtract_nameES3_S3_RiPPKcjRSt8ios_baseRSt12_Ios_Iostate
+0x602): more undefined references to `__stack_chk_fail' follow
/home/myUser/lib/libmergedC++lib.a(cp-demangle.o)(.text
+0x3fb7): In function `d_demangle':
: undefined reference to `__stack_chk_fail_local'
collect2: ld returned 1 exit status
make[2]: *** [example] Error 1
make[1]: *** [all-recursive] Error 1
make: *** [all] Error 2
What's going wrong???