I am encountering a strange problem (at least for me) with compiling a
rather simple program in a single step or in multiple steps into an
executable.
I am using Solaris Sparc 2.7 and WorkShop 5.
Two scenarios's:
1) I use CC to directly build the source code from Appendix A into an
executable that works.
2) I build step by step a) compiling into an object b) making a lib
out of it and c) finally the executable itself but know I have a bunch
of unresolved symbols (see Appendix B).
Anybody ideas ?
Appendix A:
========== file: foo.cpp
#include <map>
#include <string>
#include <stdio.h>
using namespace std;
typedef map<string, string> STRINGMAP;
int main()
{
#ifdef USE_MAP
STRINGMAP mymap;
STRINGMAP::iterator iter;
iter = mymap.begin();
#endif
string mystring = "Hello World";
string str2 = "Goodbye";
#ifdef USE_MAP
mymap[mystring] = str2;
iter = mymap.find(mystring);
printf("Mystring is %s, stored string is %s\n", mystring.c_str(),
(*iter).second.c_str() );
#else
printf("Mystring is %s, str2 is %s\n", mystring.c_str(),
str2.c_str() );
#endif
return 0;
Appendix B:
==========
CC -c foo.cpp -o foo.o -DUSE_MAP ld: fatal: Symbol referencing errors. No output written to foo1 Compilation exited abnormally with code 1 at Tue Jun 20 21:14:}
ld -r -o foo.lib foo.o
CC foo.lib -o foo1
Undefined first referenced
symbol in file
void
__rwstd::__rb_tree<std::basic_string<char,std::char_traits<char>,std::alloc
...
>,std::basic_string<char,std::char_traits<char>,std::allocator<char> >
>,__rwstd::__select1st<std::pair<std::basic_string<char,std::char_traits<ch
>,std::basic_string<char,std::char_traits<char>,std::allocator<char> >
>,std::basic_string<char,std::char_traits<char>,std::allocator<char> >
>,std::less<std::basic_string<char,std::char_traits<char>,std::allocator<ch
*** Error code 1
make: Fatal error: Command failed for target `foo1'