merging multiple static library

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
::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???
 
J

Jack Klein

Hi 'body,
I'm trying to compile a program which uses two static libraries.

"Static libraries" are not something defined by the C language, they
are a mechanism provided by your compiler and operating system.
One is wrote in C language the other is wrote in C++ but it's
functions are under extern "C" declaration.

Any code written in C++ is off-topic in comp.lang.c. The C language
does not define linkage to any other language at all. C++ defines
linkage mechanisms that can work with code generated by compatible C
compilers, but C does not.
Once I try to compile my file example.c I have to add the option -
lstdc++ 'cause of the C++ library.

[snip]

Don't go asking in comp.lang.c++ either, it's off-topic there as well.
You need to ask this in a group that supports your compiler/operating
system combination.

--
Jack Klein
Home: http://JK-Technology.Com
FAQs for
comp.lang.c http://c-faq.com/
comp.lang.c++ http://www.parashift.com/c++-faq-lite/
alt.comp.lang.learn.c-c++
http://www.club.cc.cmu.edu/~ajo/docs/FAQ-acllc.html
 
F

frakie

Hi 'body,
I'm trying to compile a program which uses two static libraries.

"Static libraries" are not something defined by the C language, they
are a mechanism provided by your compiler and operating system.
One is wrote in C language the other is wrote in C++ but it's
functions are under extern "C" declaration.

Any code written in C++ is off-topic in comp.lang.c. The C language
does not define linkage to any other language at all. C++ defines
linkage mechanisms that can work with code generated by compatible C
compilers, but C does not.
Once I try to compile my file example.c I have to add the option -
lstdc++ 'cause of the C++ library.

[snip]

Don't go asking in comp.lang.c++ either, it's off-topic there as well.
You need to ask this in a group that supports your compiler/operating
system combination.

--
Jack Klein
Home:http://JK-Technology.Com
FAQs for
comp.lang.chttp://c-faq.com/
comp.lang.c++http://www.parashift.com/c++-faq-lite/
alt.comp.lang.learn.c-c++http://www.club.cc.cmu.edu/~ajo/docs/FAQ-acllc.html

I don't think groups are intended to be so strictly binded on a topic,
nevertheless
this is a question on c as long as c++ so I was sure to be able to ask
it
in both topics. And so i did.
And you can see..Someone else is thinking the same.
Thank you for your effort!
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,755
Messages
2,569,536
Members
45,020
Latest member
GenesisGai

Latest Threads

Top