S
Steven T. Hatton
Scroll to the bottom and read the last part first.
I've been trying very diligently to 'modularize' the code from TC++PL3E
found here: http://www.research.att.com/~bs/matrix.c
I keep getting what I believe are linker errors. For example:
g++ -g -O2 -o rematrix cslice_iter.o main.o matrix.o rematrix.o
slice_iter.o
rematrix.o(.text+0x29b): In function `f(int, int)':
/code/c++/stl/valarray/rematrix/src/rematrix.cpp:43: undefined reference to
`Matrix::column(unsigned)'
rematrix.o(.text+0x3a8):/code/c++/stl/valarray/rematrix/src/rematrix.cpp:51:
undefined reference to `Matrix::row(unsigned)'
collect2: ld returned 1 exit status
make[2]: *** [rematrix] Error 1
The original code compiles and runs just fine. I tried to preserve the
integrity of the overall program while separating it into different files
based on class/template names. You can find the mess I've made here:
http://baldur.globalsymmetry.com/projects/rematrix/rematrix/
The tarball:
http://baldur.globalsymmetry.com/projects/rematrix/rematrix-2004-05-25-09-37-24.tar.gz
has the same content as the directory, and if you have a gnu build system on
you box, you too can ./configure it, and watch it fail. The location
indicated in the error message is
for(int x=0; x<x_max; x++) {
cout << "column " << x << ":\n";
for (Slice_iter<double> c = a.column(x); c!=c.end(); ++c) //<<<<<<<
cout << "\t" << *c <<"\n";
}
http://baldur.globalsymmetry.com/projects/rematrix/rematrix/src/rematrix.cpp
SOB! I just got it to compile!
I moved the implementations of Matrix::row(size_t i) from the source file
(matrix.cpp) and put them (back) in the header file. I would never have
taken them out of the header had it not been for other errors. ODR
violations IIRC.
I still would like to know how to systematically approach this kind of
situation. What does that error I listed indicate? I usually see that
kind of thing when my library references are wrong.
I've been trying very diligently to 'modularize' the code from TC++PL3E
found here: http://www.research.att.com/~bs/matrix.c
I keep getting what I believe are linker errors. For example:
g++ -g -O2 -o rematrix cslice_iter.o main.o matrix.o rematrix.o
slice_iter.o
rematrix.o(.text+0x29b): In function `f(int, int)':
/code/c++/stl/valarray/rematrix/src/rematrix.cpp:43: undefined reference to
`Matrix::column(unsigned)'
rematrix.o(.text+0x3a8):/code/c++/stl/valarray/rematrix/src/rematrix.cpp:51:
undefined reference to `Matrix::row(unsigned)'
collect2: ld returned 1 exit status
make[2]: *** [rematrix] Error 1
The original code compiles and runs just fine. I tried to preserve the
integrity of the overall program while separating it into different files
based on class/template names. You can find the mess I've made here:
http://baldur.globalsymmetry.com/projects/rematrix/rematrix/
The tarball:
http://baldur.globalsymmetry.com/projects/rematrix/rematrix-2004-05-25-09-37-24.tar.gz
has the same content as the directory, and if you have a gnu build system on
you box, you too can ./configure it, and watch it fail. The location
indicated in the error message is
for(int x=0; x<x_max; x++) {
cout << "column " << x << ":\n";
for (Slice_iter<double> c = a.column(x); c!=c.end(); ++c) //<<<<<<<
cout << "\t" << *c <<"\n";
}
http://baldur.globalsymmetry.com/projects/rematrix/rematrix/src/rematrix.cpp
SOB! I just got it to compile!
I moved the implementations of Matrix::row(size_t i) from the source file
(matrix.cpp) and put them (back) in the header file. I would never have
taken them out of the header had it not been for other errors. ODR
violations IIRC.
I still would like to know how to systematically approach this kind of
situation. What does that error I listed indicate? I usually see that
kind of thing when my library references are wrong.