Thread View: gnu.g++.help
4 messages
4 total messages
Started by Jacob Salomon
Thu, 21 Jan 1993 00:44
So close and yet, so far...
Author: Jacob Salomon
Date: Thu, 21 Jan 1993 00:44
Date: Thu, 21 Jan 1993 00:44
88 lines
3533 bytes
3533 bytes
WOW! I finally got a complete, clean configure, compile, link, and
install of gcc-2.3.3, as well as the same for libg++-2.3 on my
HP-9000/827 under HP-UX A.08.02 - Sure kept me busy on coffee breaks!
So I get around to my fist c++ program: y'know, hello.. But first, I
set my environment variable: INCLUDE=/usr/gnu/lib/g++-include
Here is the source file:
: $ cat hello.C
: #include <iostream.h>
: main()
: {
: cout << "Hello world\n";
: return 0;
: }
FIrst pass: g++ hello.C
hello.C:1: iostream.h: No such file or directory
A quick ls of the $INCLUDE directory shows it is there. OK, so that
environment variable is not working (yes, I had exported it!). So I
try the direct assault:
$ g++ -I$INCLUDE hello.C
+ g++ -I/usr/gnu/lib/g++-include hello.C
ld: Can't find library for -lg++
collect: /bin/ld returned 1 exit status
Obviously I have missed some fine points in the build. Or maybe the
configure.
Q1: How do I get g++ to search any particular directory for include
files? I'm sure it's somewhere in the 55-page man-page for GCC
and G++ but it's hard to locate anything by sight and vi searching
is of no help (no, I haven't installed or learned how to use emacs
yet) because the man-text is peppered with embedded back-spaces.
If the INCLUDE environment variable is not the key, what is?
Q2: The error message for -lg++ - It is searching for the library:
libg++.a, which I have found in 2 subdirectories of where I
built it:
71681 1 660084 Jan 19 19:43 /lox/g2.3/libg++-2.3/lib/libg++.a
4116 1 660084 Jan 19 19:43 /lox/g2.3/libg++-2.3/libg++/libg++.a
I don't know why there are 2 copies of this - They are not links
to the same file - not even symbolic links. Where is the linker
(or collect) looking for them? in a subdirectory of /usr/gnu/lib?
I think all I need is to see exactly where it needs to go. I
already have a symbolic link:
$ ls -l /usr/gnu/lib
lrwxr-xr-x /usr/gnu/lib -> /lox/g2.3/libg++-2.3/lib
Observe the following output:
$ pwd
/usr/gnu/lib
$ ls -l
total 1318
drwxr-xr-x 4 gnu 2048 Jan 19 19:44 g++-include
drwxr-xr-x 2 gnu 24 Jan 19 19:43 hppa1.0-hp-hpux
-rw-r--r-- 1 gnu 660084 Jan 19 19:43 libg++.a
So you see, libg++.a is under /usr/gnu/lib.
What am I missing, besides the skill to explain briefly? ;-)
BTW - Note that the configuration was hppa1.0; An addendum in the
README indicates that I should use hppa1.1 for the HP-9000/827.
However, trial and error with 1.37 showed me that 1.0 was the way to
go. If someone can point out what's happenning, it would be very
helpful as well.
Thanks very much.
-- Jake Salomon
jacob@informix.com
Please reply by e-mail.
--
----------------Obligatory smart-$$$ remark:---------------------
| There's two kinds of people: Those who categorize people into |
| two groups and those who don't. (Barth's Aging proverb.) |
-----------------------------------------------jacob@informix.com
Re: So close and yet, so far...
Author: Jacob Salomon
Date: Thu, 21 Jan 1993 23:02
Date: Thu, 21 Jan 1993 23:02
50 lines
2731 bytes
2731 bytes
In article <1993Jan21.004406.6508@informix.com> I asked for help regarding why, after finally getting a clean compile of gcc-2.3.3 the compiler was unable to automatically find <iostream.h>; I was forced to supply the directory in the -I option to g++. When I did this the compile completed the linker (or more accurately, collect) complained it was unable to find libg++.a (library for -lg++). I got back some important answers: Mr. DM and AG (names witheld to protect their mailboxes ;) both replied that I had needed to supply a --prefix parameter to the configure command for both gcc and libg++. Furthermore, the target directory must be the same for both configure commands. Unfortunately, this is documented only in the libg++ README, not in the gcc readme (I just ran a grep on it; it isn't there!) and I really had used the --prefix in the configure on gcc. SHort of going through all that building again (remembering to drop the -g from all Makefiles and uncommenting/commenting for various models! UGH!) what can I do to make use of everything where it is? Mr. JO to the partial rescue: Here is his reply: >I set up libg++ on decstation 5000/240 running Ultrix 4.? >To search the various files the following env var are needed (for me) >COMPILER_PATH (sound ok for you) >LIBRARY_PATH ( I think you need this ) >CPLUS_INCLUDE_PATH ( for includes ) Well, I set up the CPLUS_INCLUDE_PATH to reference where I had put the include directory: /usr/gnu/lib/g++-include .. This helped it find the <iostream.h> without my supplying the -I switch to g++. However the LIBRARY_PATH did not help the linker (or collect) find libg++.a, no matter where I aimed it. BTW, the directory gcc-lib is under /usr/local/lib. Thanks to all who sent me the help so far. I'm almost there with only one screw-up along the way. C'mon Netters, please help hack my way around that screw-up! As before, please reply be e-mail. Thanks again. -- Jake Salomon jacob@informix.com -- ----------------Obligatory smart-$$$ remark:--------------------- | There's two kinds of people: Those who categorize people into | | two groups and those who don't. (Barth's Aging proverb.) | -----------------------------------------------jacob@informix.com
help!
Author: Palmer M J
Date: Mon, 25 Jan 1993 14:00
Date: Mon, 25 Jan 1993 14:00
98 lines
3105 bytes
3105 bytes
I've recently been trying to get to grips with c++. I wrote the following
small programme to implement a list template. However, it does not behave as
I would have expected. If I define a list of chars or ints in main then all is
ok. But defining the list to be of type char* does not work. If I insert a
string item by typing
i aaa
then insert another string by typing
i bbb
then type
d
to display the contents of the list, it prints out
bbb bbb
If I then type
s ccc
and then
d
then what is printed out is
ccc ccc ccc
It seems that by reading in a string to the local char array item in main
causes the value of each element in list to be changed to the value of the
newly read in string. Could someone please put me out of my misery explain
what is going on.
Thanks in advance.
Mike Palmer.
PS. I am using gcc version 2.2.2
//////////////////////////////////////////////////////////////////////////////
// List template definition
//////////////////////////////////////////////////////////////////////////////
#include <assert.h>
#include <iostream.h>
enum Boolean { false = 0, true = 1 };
template <class Type> class Item;
template <class Type>
class List {
public:
List() { firstItem = 0; }
~List() {}
void insert(Type);
void display();
private:
Item<Type> *firstItem;
};
template <class Type>
class Item {
friend class List<Type>;
private:
Item(Type value) { val = value; next = 0; }
Type val;
Item *next;
};
template <class Type>
void List<Type>::insert(Type val) {
Item<Type> *pt = new Item<Type>(val);
assert( pt != 0 ); // catch free store exhaustion
pt->next = firstItem;
firstItem = pt;
}
template <class Type>
void List<Type>::display() {
for ( Item<Type> *pt = firstItem; pt; pt = pt->next )
cout << pt->val << " ";
cout << endl;
}
//////////////////////////////////////////////////////////////////////////////
// Define and test a list of strings.
//////////////////////////////////////////////////////////////////////////////
main () {
typedef char *Type;
List<Type> *list = new List<Type>; // create a list of strings
char ch; // select test operation
char item[10]; // input string buffer
while ( cin >> ch )
switch(ch) {
case 'q':
return 1;
case 's':
cin >> item;
cout << item << '\n';
break;
case 'i':
cin >> item;
list->insert(item);
break;
case 'd':
list->display();
break;
}
}
Re: help!
Author: Klamer Schutte
Date: Wed, 27 Jan 1993 13:30
Date: Wed, 27 Jan 1993 13:30
18 lines
1231 bytes
1231 bytes
In <7684@sersun1.essex.ac.uk> palmm@csc2.essex.ac.uk (Palmer M J) writes: >> dicussion about linked list implementation deleted << The problem you have is in the concept string. You expect the behaviour of a decent string, and you use char *. You get the expected behaviour by using the String type defined by #include <String.h>. Just change your typedef line to: typedef String Type; instead of typedef char * Type; Klamer -- Klamer Schutte Tel: +31-53-892778 Fax: +31-53-340045 Faculty of electrical engineering -- University of Twente, The Netherlands preferred: klamer@mi.el.utwente.nl SMTP: klamer@utelmi01.el.utwente.nl
Thread Navigation
This is a paginated view of messages in the thread with full content displayed inline.
Messages are displayed in chronological order, with the original post highlighted in green.
Use pagination controls to navigate through all messages in large threads.
Back to All Threads