473,609 Members | 1,972 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

ar loses std::list symbols

Solaris 9, Sun Workshop 5.0

I have ObjectA.o, ObjectB.o. ObjectA.o uses std::list.
I created a archive of the objects: ar cvr libAB.a *.o.

I have example.cc which I am trying to compile against ObjectA ObjectB.

1. CC -I. -o example.bin example.cc ./libAB.a
this fails, on link error to std::list.

2. CC -I. -o example.bin example.cc ObjectA.o ObjectB.o
this works.

Anyone know why method 2 works, and not method 1? I really need those
objects in the archive.

Thanks.

~Shea M.

ps - Not sure if this matters or not (other than the fact it is poor
design, but ObjectA and ObjectB reference one another.

Jul 22 '05 #1
2 1807
Don't use CC, use CXX (or whatever define is set for you c++ compiler). CC
if defined as a C compiler (i.e., gcc) won't link in the standard C++
library. So, for example, use g++ instead of gcc. I use STL and archives
all the time, and never had this problem.
"Shea Martin" <sm*****@arcis. com> wrote in message
news:oAKyb.1610 7$f7.769938@loc alhost...
Solaris 9, Sun Workshop 5.0

I have ObjectA.o, ObjectB.o. ObjectA.o uses std::list.
I created a archive of the objects: ar cvr libAB.a *.o.

I have example.cc which I am trying to compile against ObjectA ObjectB.

1. CC -I. -o example.bin example.cc ./libAB.a
this fails, on link error to std::list.

2. CC -I. -o example.bin example.cc ObjectA.o ObjectB.o
this works.

Anyone know why method 2 works, and not method 1? I really need those
objects in the archive.

Thanks.

~Shea M.

ps - Not sure if this matters or not (other than the fact it is poor
design, but ObjectA and ObjectB reference one another.

Jul 22 '05 #2
Xenos wrote:
Don't use CC, use CXX (or whatever define is set for you c++ compiler). CC
if defined as a C compiler (i.e., gcc) won't link in the standard C++
library. So, for example, use g++ instead of gcc. I use STL and archives
all the time, and never had this problem.


The Sun Workshop Compilers are CC: for C++, cc: for c. Just a different
naming scheme from the GNU compilers.
Solaris 9, Sun Workshop 5.0

I have ObjectA.o, ObjectB.o. ObjectA.o uses std::list.
I created a archive of the objects: ar cvr libAB.a *.o.

I have example.cc which I am trying to compile against ObjectA ObjectB.

1. CC -I. -o example.bin example.cc ./libAB.a
this fails, on link error to std::list.

2. CC -I. -o example.bin example.cc ObjectA.o ObjectB.o
this works.

Anyone know why method 2 works, and not method 1? I really need those
objects in the archive.


Solved:
If anyone is familiar with workshop, then you know that CC generates
SunWS_Cache directories whenever you compile code which uses templates.
Using -pto flag will turn off the creation of this cache directory. I
have always used this flag, b/c I find the directory annoying.

Well I re read Sun's docs on CC, and if you carefully between the lines,
it is inferred that this cache is needed for creating static
archives/libs when the objects use templates.

Removing the -pto flag and recompiling fixes everything. Once the lib
has been created the cache can be removed, and you will still be able to
link to the library.

Hope this one helps someone else in the future, as I wasted a LOT of
time on it!!!

Here are some keywords for people using groups.google.c om:
templates undefined symbol std template list -pto Sun Workshop
SunWS_Cache lib *.a *.o static archive ar -xar Makefile CC

Later,

~S

Jul 22 '05 #3

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

Similar topics

8
2831
by: JustSomeGuy | last post by:
I need to write an new class derived from the list class. This class stores data in the list to the disk if an object that is added to the list is over 1K in size. What methods of the std stl list class must Ioverride in order for this to work?
5
1773
by: Eric Lilja | last post by:
Hello, consider this complete program (sorry, it's not minimal but I hope it's readable at least): #include <algorithm> #include <iostream> #include <vector> class Row { public:
44
3843
by: Josh Mcfarlane | last post by:
Just out of curiosity: When would using std::list be more efficient / effective than using other containers such as vector, deque, etc? As far as I'm aware, list doesn't appear to be specialized for anything. Thanks, Josh McFarlane
7
2964
by: alex221 | last post by:
In need to implement a tree structure in which every node has arbitrary number of children the following code has come into mind: using std::list; template < class Contents class Tree_node{ Contents cn; list < BTree_node < Contents children; ........
8
3414
by: Spoon | last post by:
Hello, Could someone explain why the following code is illegal? (I'm trying to use a list of (C-style) arrays.) #include <list> typedef std::list < int foo_t; int main() { int v = { 12, 34 };
0
1718
by: Javier | last post by:
Hi all, I have this code: class A { std::list<Bm_observadores; void function() {
3
2519
by: Ray D. | last post by:
Hey all, I'm trying to pass a list into a function to edit it but when I compile using g++ I continue to get the following error: maintainNeighbors.cpp:104: error: invalid initialization of non-const reference of type 'std::list<HostID, std::allocator<HostID&' from a temporary of type 'std::list<HostID, std::allocator<HostID*' helpers.cpp:99: error: in passing argument 1 of `void
12
2691
by: isliguezze | last post by:
template <class T> class List { public: List(); List(const List&); List(int, const T&); void push_back(const T &); void push_front(const T &); void pop_back();
17
4164
by: Isliguezze | last post by:
Does anybody know how to make a wrapper for that iterator? Here's my wrapper class for std::list: template <class Tclass List { private: std::list<T*lst; public: List() { lst = new std::list<T>(); } List(const List<T&rhs) { lst = new std::list<T>(*rhs.lst); } List(int n, const T& value) { lst = new std::list<T>(n, value); }
0
8145
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, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
8095
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 effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
8556
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
1
8236
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 Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
8410
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 protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
0
7030
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
0
5526
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
1
2541
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
1
1690
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.

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.