473,405 Members | 2,334 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,405 software developers and data experts.

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 1790
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.16107$f7.769938@localhost...
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.com:
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
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...
5
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
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...
7
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{ ...
8
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
by: Javier | last post by:
Hi all, I have this code: class A { std::list<Bm_observadores; void function() {
3
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...
12
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
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...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
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: 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
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
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...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...

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.