473,395 Members | 1,412 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,395 software developers and data experts.

merging multiple static library

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_traitsIcEE5widen Ec+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
`std::basic_istream<char, std::char_traits<char>

>::seekg(std::fpos<__mbstate_t>)':

: undefined reference to `__stack_chk_fail'
/home/myUser/lib/libmergedC++lib.a(istream-inst.o)
(.text._ZNSt13basic_istreamIwSt11char_traitsIwEE5s eekgExSt12_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_traitsIwEE5s eekgESt4fposI11__mbstate_**
tE
+0xd1): In function `std::basic_istream<wchar_t,
std::char_traits<wchar_t::seekg(std::fpos<__mbstat e_t>)':
: undefined reference to `__stack_chk_fail'
/home/myUser/lib/libmergedC++lib.a(locale-inst.o)
(.text._ZNKSt8time_getIcSt19istreambuf_iteratorIcS t11char_traitsIcEEE15_M_e**
xtract_nameES3_S3_RiPPKcjRSt8ios_baseRSt12_Ios_Ios tate
+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???

Sep 7 '07 #1
2 5890
On Fri, 07 Sep 2007 08:21:04 -0700, frakie <fr*******@gmail.comwrote
in comp.lang.c:
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
Sep 7 '07 #2
On 8 Set, 01:33, Jack Klein <jackkl...@spamcop.netwrote:
On Fri, 07 Sep 2007 08:21:04 -0700, frakie <frakie...@gmail.comwrote
in comp.lang.c:
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!

Sep 10 '07 #3

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

7
by: Ittay Dror | last post by:
Hi I have this peculiar situation. I have a library of utility classes, which I use to compile a binary. I want to reimplement a method in class. The class is only a collection of static...
1
by: rajesh_krec | last post by:
Hello Everybody, I'm using Microsoft Visual Studio .NET 2003 (with Vc7 compiler) I have some 15 projects each of which generate a static library when i build the solution in release mode. ...
3
by: Patrick | last post by:
I have got 2 XML documents, both of which conform to the same XSD Schema, which define possible optional elements. The 2 XML documents contain 2 disjoint set of XML elements. What is the best,...
1
by: svdh | last post by:
I have posed a question last saturday and have advanced alot in the meantime. But I am still not there Problem is that I try to merging various fields from various tables in one document in Word...
1
by: Bruno van Dooren | last post by:
Hi, i am using a third party static library (.lib) that wraps a class interface around an old C-style dll. in the static library they use the STL for some stuff i don't know about. in my own...
1
by: metsys | last post by:
We have an ASP.NET 2.0 (C#) application that is divided into multiple layers. The multiple layers come from having a web project and 2 different class library projects in the same solution. I'm...
31
by: louishong | last post by:
3rd time posting this as the first two simply disappeared! Here's the issue: We currently run an Access application in the West Coast for tracking resource centric data. For those located in the...
4
by: andy143vivi | last post by:
hi, my first time here, great community site, found lots of help for my access development. So here is first question: how do i merge a multiple record and shows the count as well, im making a...
4
by: tvnaidu | last post by:
I created an executable using static library instead shared lib, I am running multipe instances of this executable, does it takes more memory with static library compare to shared library?. Does...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.