R
rsparapa
I've been working on vector/matrix/PRNG class libraries for years, but
I never got around to figuring out how to make them into libraries; I'm
a statistician, not a computer scientist. So, for this example, I'm
using g++ 4.0.0 on Solaris(SPARC) 9, if that makes any difference.
Everything worked fine for the Vector libary, build (Makefile excerpt):
#create shared library in PWD
#with GNU ld
#SHARED=-shared
#with Sun ld
SHARED=-Xlinker -G
#GNU C++ compiler and flags
CXX=g++-4.0.0 -g
#GSL/math libraries
LIBS=-lgsl -lgslcblas -lm
libvector.so : vector.cxx vector.hxx Makefile
$(CXX) -nostartfiles $(SHARED) -o $@ vector.cxx $(LIBS)
vector_main.out : vector_main.cxx libvector.so
$(CXX) -o $@ vector_main.cxx $(LIBS) -lvector
./$@
But, the same thing does not work for the Matrix library. It's not the
code as far as I can tell, because simpy doing an #include "matrix.cxx"
works:
libmatrix.so : matrix.cxx matrix.hxx Makefile
$(CXX) -nostartfiles $(SHARED) -o $@ matrix.cxx $(LIBS)
matrix_main.out : matrix_main.cxx libmatrix.so libvector.so
$(CXX) -o $@ matrix_main.cxx $(LIBS) -lvector -lmatrix
./$@
make matrix_main.out
g++-4.0.0 -g -nostartfiles -Xlinker -G -o libmatrix.so matrix.cxx -lgsl
-lgslcblas -lm
g++-4.0.0 -g -o matrix_main.out matrix_main.cxx -lgsl -lgslcblas -lm
-lvector -lmatrix
Undefined first referenced
symbol in file
Matrix:perator=(Matrix) /var/tmp//ccqgGJUa.o
Matrix::inverse(double) /var/tmp//ccqgGJUa.o
Matrix::Matrix(unsigned int, unsigned int, double,
....)/var/tmp//ccqgGJUa.o
Matrix::Matrix(Matrix const&) /var/tmp//ccqgGJUa.o
Matrix:perator-() /var/tmp//ccqgGJUa.o
Matrix::~Matrix() /var/tmp//ccqgGJUa.o
operator*(Matrix const&, Matrix const&)/var/tmp//ccqgGJUa.o
operator<<(std::basic_ostream<char, std::char_traits<char> >&,
Matrix)/var/tmp//ccqgGJUa.o
ld: fatal: Symbol referencing errors. No output written to
matrix_main.out
collect2: ld returned 1 exit status
*** Error code 1
make: Fatal error: Command failed for target `matrix_main.out'
Any ideas?
Thanks, Rodney
I never got around to figuring out how to make them into libraries; I'm
a statistician, not a computer scientist. So, for this example, I'm
using g++ 4.0.0 on Solaris(SPARC) 9, if that makes any difference.
Everything worked fine for the Vector libary, build (Makefile excerpt):
#create shared library in PWD
#with GNU ld
#SHARED=-shared
#with Sun ld
SHARED=-Xlinker -G
#GNU C++ compiler and flags
CXX=g++-4.0.0 -g
#GSL/math libraries
LIBS=-lgsl -lgslcblas -lm
libvector.so : vector.cxx vector.hxx Makefile
$(CXX) -nostartfiles $(SHARED) -o $@ vector.cxx $(LIBS)
vector_main.out : vector_main.cxx libvector.so
$(CXX) -o $@ vector_main.cxx $(LIBS) -lvector
./$@
But, the same thing does not work for the Matrix library. It's not the
code as far as I can tell, because simpy doing an #include "matrix.cxx"
works:
libmatrix.so : matrix.cxx matrix.hxx Makefile
$(CXX) -nostartfiles $(SHARED) -o $@ matrix.cxx $(LIBS)
matrix_main.out : matrix_main.cxx libmatrix.so libvector.so
$(CXX) -o $@ matrix_main.cxx $(LIBS) -lvector -lmatrix
./$@
make matrix_main.out
g++-4.0.0 -g -nostartfiles -Xlinker -G -o libmatrix.so matrix.cxx -lgsl
-lgslcblas -lm
g++-4.0.0 -g -o matrix_main.out matrix_main.cxx -lgsl -lgslcblas -lm
-lvector -lmatrix
Undefined first referenced
symbol in file
Matrix:perator=(Matrix) /var/tmp//ccqgGJUa.o
Matrix::inverse(double) /var/tmp//ccqgGJUa.o
Matrix::Matrix(unsigned int, unsigned int, double,
....)/var/tmp//ccqgGJUa.o
Matrix::Matrix(Matrix const&) /var/tmp//ccqgGJUa.o
Matrix:perator-() /var/tmp//ccqgGJUa.o
Matrix::~Matrix() /var/tmp//ccqgGJUa.o
operator*(Matrix const&, Matrix const&)/var/tmp//ccqgGJUa.o
operator<<(std::basic_ostream<char, std::char_traits<char> >&,
Matrix)/var/tmp//ccqgGJUa.o
ld: fatal: Symbol referencing errors. No output written to
matrix_main.out
collect2: ld returned 1 exit status
*** Error code 1
make: Fatal error: Command failed for target `matrix_main.out'
Any ideas?
Thanks, Rodney