- #1
Angelos K
- 48
- 0
I have an official LAPACK example from here:
https://software.intel.com/sites/pr.../mkl_sa/11/mkl_lapack_examples/dsyev_ex.c.htm
It compiles and runs without errors or warnings after using
Then, I have a very simple programme using ifstream for reading from a file into a vector. It, too, compiles flawlessly using
Here is the latter programme:
I just want to use read_covariance() from the small programme within the first programme. To that end I just modify the start of the LAPACK example, adding the function I want to use. Explicitly, I moddify just the start of the example to
Leaving it otherwise unmodified. I added some unmodified lines to make clear where I am. I immediately get a ton of errors:
ludi@ludi-M17xR4:~/Desktop/tests$ gcc -Ddgeev=dgeev_ -o combo combo.cc -L/usr/local/lib -llapack -lblas && ./combo
combo.cc: In function ‘int main()’:
combo.cc:107:74: warning: deprecated conversion from string constant to ‘char*’ [-Wwrite-strings]
dsyev( "Vectors", "Upper", &n, a, &lda, w, &wkopt, &lwork, &info );
^
combo.cc:107:74: warning: deprecated conversion from string constant to ‘char*’ [-Wwrite-strings]
combo.cc:111:72: warning: deprecated conversion from string constant to ‘char*’ [-Wwrite-strings]
dsyev( "Vectors", "Upper", &n, a, &lda, w, work, &lwork, &info );
^
combo.cc:111:72: warning: deprecated conversion from string constant to ‘char*’ [-Wwrite-strings]
combo.cc:118:49: warning: deprecated conversion from string constant to ‘char*’ [-Wwrite-strings]
print_matrix( "Eigenvalues", 1, n, w, 1 );
^
combo.cc:120:72: warning: deprecated conversion from string constant to ‘char*’ [-Wwrite-strings]
print_matrix( "Eigenvectors (stored columnwise)", n, n, a, lda );
^
/tmp/ccZrNqc0.o: In function `read_covariance()':
combo.cc:(.text+0x3f): undefined reference to `std::basic_ifstream<char, std::char_traits<char> >::basic_ifstream(char const*, std::_Ios_Openmode)'
combo.cc:(.text+0x73): undefined reference to `std::istream:perator>>(double&)'
combo.cc:(.text+0x88): undefined reference to `std::basic_ios<char, std::char_traits<char> >:perator void*() const'
combo.cc:(.text+0xa6): undefined reference to `std::basic_ifstream<char, std::char_traits<char> >::~basic_ifstream()'
combo.cc:(.text+0xda): undefined reference to `std::basic_ifstream<char, std::char_traits<char> >::~basic_ifstream()'
/tmp/ccZrNqc0.o: In function `main':
combo.cc:(.text+0x1af): undefined reference to `dsyev(char*, char*, int*, double*, int*, double*, double*, int*, int*)'
combo.cc:(.text+0x236): undefined reference to `dsyev(char*, char*, int*, double*, int*, double*, double*, int*, int*)'
/tmp/ccZrNqc0.o: In function `std::vector<double, std::allocator<double> >::_M_insert_aux(__gnu_cxx::__normal_iterator<double*, std::vector<double, std::allocator<double> > >, double const&)':
combo.cc:(.text._ZNSt6vectorIdSaIdEE13_M_insert_auxEN9__gnu_cxx17__normal_iteratorIPdS1_EERKd[_ZNSt6vectorIdSaIdEE13_M_insert_auxEN9__gnu_cxx17__normal_iteratorIPdS1_EERKd]+0x263): undefined reference to `__cxa_end_catch'
combo.cc:(.text._ZNSt6vectorIdSaIdEE13_M_insert_auxEN9__gnu_cxx17__normal_iteratorIPdS1_EERKd[_ZNSt6vectorIdSaIdEE13_M_insert_auxEN9__gnu_cxx17__normal_iteratorIPdS1_EERKd]+0x276): undefined reference to `__cxa_begin_catch'
combo.cc:(.text._ZNSt6vectorIdSaIdEE13_M_insert_auxEN9__gnu_cxx17__normal_iteratorIPdS1_EERKd[_ZNSt6vectorIdSaIdEE13_M_insert_auxEN9__gnu_cxx17__normal_iteratorIPdS1_EERKd]+0x2df): undefined reference to `__cxa_rethrow'
/tmp/ccZrNqc0.o: In function `std::vector<double, std::allocator<double> >::_M_check_len(unsigned long, char const*) const':
combo.cc:(.text._ZNKSt6vectorIdSaIdEE12_M_check_lenEmPKc[_ZNKSt6vectorIdSaIdEE12_M_check_lenEmPKc]+0x4c): undefined reference to `std::__throw_length_error(char const*)'
/tmp/ccZrNqc0.o: In function `__gnu_cxx::new_allocator<double>::deallocate(double*, unsigned long)':
combo.cc:(.text._ZN9__gnu_cxx13new_allocatorIdE10deallocateEPdm[_ZN9__gnu_cxx13new_allocatorIdE10deallocateEPdm]+0x1c): undefined reference to `operator delete(void*)'
/tmp/ccZrNqc0.o: In function `__gnu_cxx::new_allocator<double>::allocate(unsigned long, void const*)':
combo.cc:(.text._ZN9__gnu_cxx13new_allocatorIdE8allocateEmPKv[_ZN9__gnu_cxx13new_allocatorIdE8allocateEmPKv]+0x2c): undefined reference to `std::__throw_bad_alloc()'
combo.cc:(.text._ZN9__gnu_cxx13new_allocatorIdE8allocateEmPKv[_ZN9__gnu_cxx13new_allocatorIdE8allocateEmPKv]+0x3c): undefined reference to `operator new(unsigned long)'
/tmp/ccZrNqc0.o:(.eh_frame+0x4b): undefined reference to `__gxx_personality_v0'
collect2: error: ld returned 1 exit status
ludi@ludi-M17xR4:~/Desktop/tests$
Can anyone offer guidance??
https://software.intel.com/sites/pr.../mkl_sa/11/mkl_lapack_examples/dsyev_ex.c.htm
It compiles and runs without errors or warnings after using
ludi@ludi-M17xR4:~/Desktop/tests$ gcc -Ddsyev=dsyev_ -o sylapack sylapack.c -L/usr/local/lib -llapack -lblas && ./sylapack
Then, I have a very simple programme using ifstream for reading from a file into a vector. It, too, compiles flawlessly using
ludi@ludi-M17xR4:~/Desktop/tests$ g++ -Wall -pedantic -o justread.x justread.cc && ./justread.x
#include <fstream>
#include <vector>int read_covariance ()
{
std::vector<double> data;
double tmp;
std::ifstream fin("peano_covariance.data");
while(fin >> tmp)
{
data.push_back(tmp);
}
return 0;
}
int main()
{
read_covariance();
return 0;
}
#include <vector>int read_covariance ()
{
std::vector<double> data;
double tmp;
std::ifstream fin("peano_covariance.data");
while(fin >> tmp)
{
data.push_back(tmp);
}
return 0;
}
int main()
{
read_covariance();
return 0;
}
I just want to use read_covariance() from the small programme within the first programme. To that end I just modify the start of the LAPACK example, adding the function I want to use. Explicitly, I moddify just the start of the example to
#include <stdlib.h>
#include <stdio.h>
#include <fstream>
#include <vector>
int read_covariance ()
{
std::vector<double> data;
double tmp;
std::ifstream fin("peano_covariance.data");
while(fin >> tmp)
{
data.push_back(tmp);
}
return 0;
}/* DSYEV prototype */
extern void dsyev( char* jobz, char* uplo, int* n, double* a, int* lda,
double* w, double* work, int* lwork, int* info );
/* Auxiliary routines prototypes */
extern void print_matrix( char* desc, int m, int n, double* a, int lda );
/* Parameters */
#include <stdio.h>
#include <fstream>
#include <vector>
int read_covariance ()
{
std::vector<double> data;
double tmp;
std::ifstream fin("peano_covariance.data");
while(fin >> tmp)
{
data.push_back(tmp);
}
return 0;
}/* DSYEV prototype */
extern void dsyev( char* jobz, char* uplo, int* n, double* a, int* lda,
double* w, double* work, int* lwork, int* info );
/* Auxiliary routines prototypes */
extern void print_matrix( char* desc, int m, int n, double* a, int lda );
/* Parameters */
Leaving it otherwise unmodified. I added some unmodified lines to make clear where I am. I immediately get a ton of errors:
ludi@ludi-M17xR4:~/Desktop/tests$ gcc -Ddgeev=dgeev_ -o combo combo.cc -L/usr/local/lib -llapack -lblas && ./combo
combo.cc: In function ‘int main()’:
combo.cc:107:74: warning: deprecated conversion from string constant to ‘char*’ [-Wwrite-strings]
dsyev( "Vectors", "Upper", &n, a, &lda, w, &wkopt, &lwork, &info );
^
combo.cc:107:74: warning: deprecated conversion from string constant to ‘char*’ [-Wwrite-strings]
combo.cc:111:72: warning: deprecated conversion from string constant to ‘char*’ [-Wwrite-strings]
dsyev( "Vectors", "Upper", &n, a, &lda, w, work, &lwork, &info );
^
combo.cc:111:72: warning: deprecated conversion from string constant to ‘char*’ [-Wwrite-strings]
combo.cc:118:49: warning: deprecated conversion from string constant to ‘char*’ [-Wwrite-strings]
print_matrix( "Eigenvalues", 1, n, w, 1 );
^
combo.cc:120:72: warning: deprecated conversion from string constant to ‘char*’ [-Wwrite-strings]
print_matrix( "Eigenvectors (stored columnwise)", n, n, a, lda );
^
/tmp/ccZrNqc0.o: In function `read_covariance()':
combo.cc:(.text+0x3f): undefined reference to `std::basic_ifstream<char, std::char_traits<char> >::basic_ifstream(char const*, std::_Ios_Openmode)'
combo.cc:(.text+0x73): undefined reference to `std::istream:perator>>(double&)'
combo.cc:(.text+0x88): undefined reference to `std::basic_ios<char, std::char_traits<char> >:perator void*() const'
combo.cc:(.text+0xa6): undefined reference to `std::basic_ifstream<char, std::char_traits<char> >::~basic_ifstream()'
combo.cc:(.text+0xda): undefined reference to `std::basic_ifstream<char, std::char_traits<char> >::~basic_ifstream()'
/tmp/ccZrNqc0.o: In function `main':
combo.cc:(.text+0x1af): undefined reference to `dsyev(char*, char*, int*, double*, int*, double*, double*, int*, int*)'
combo.cc:(.text+0x236): undefined reference to `dsyev(char*, char*, int*, double*, int*, double*, double*, int*, int*)'
/tmp/ccZrNqc0.o: In function `std::vector<double, std::allocator<double> >::_M_insert_aux(__gnu_cxx::__normal_iterator<double*, std::vector<double, std::allocator<double> > >, double const&)':
combo.cc:(.text._ZNSt6vectorIdSaIdEE13_M_insert_auxEN9__gnu_cxx17__normal_iteratorIPdS1_EERKd[_ZNSt6vectorIdSaIdEE13_M_insert_auxEN9__gnu_cxx17__normal_iteratorIPdS1_EERKd]+0x263): undefined reference to `__cxa_end_catch'
combo.cc:(.text._ZNSt6vectorIdSaIdEE13_M_insert_auxEN9__gnu_cxx17__normal_iteratorIPdS1_EERKd[_ZNSt6vectorIdSaIdEE13_M_insert_auxEN9__gnu_cxx17__normal_iteratorIPdS1_EERKd]+0x276): undefined reference to `__cxa_begin_catch'
combo.cc:(.text._ZNSt6vectorIdSaIdEE13_M_insert_auxEN9__gnu_cxx17__normal_iteratorIPdS1_EERKd[_ZNSt6vectorIdSaIdEE13_M_insert_auxEN9__gnu_cxx17__normal_iteratorIPdS1_EERKd]+0x2df): undefined reference to `__cxa_rethrow'
/tmp/ccZrNqc0.o: In function `std::vector<double, std::allocator<double> >::_M_check_len(unsigned long, char const*) const':
combo.cc:(.text._ZNKSt6vectorIdSaIdEE12_M_check_lenEmPKc[_ZNKSt6vectorIdSaIdEE12_M_check_lenEmPKc]+0x4c): undefined reference to `std::__throw_length_error(char const*)'
/tmp/ccZrNqc0.o: In function `__gnu_cxx::new_allocator<double>::deallocate(double*, unsigned long)':
combo.cc:(.text._ZN9__gnu_cxx13new_allocatorIdE10deallocateEPdm[_ZN9__gnu_cxx13new_allocatorIdE10deallocateEPdm]+0x1c): undefined reference to `operator delete(void*)'
/tmp/ccZrNqc0.o: In function `__gnu_cxx::new_allocator<double>::allocate(unsigned long, void const*)':
combo.cc:(.text._ZN9__gnu_cxx13new_allocatorIdE8allocateEmPKv[_ZN9__gnu_cxx13new_allocatorIdE8allocateEmPKv]+0x2c): undefined reference to `std::__throw_bad_alloc()'
combo.cc:(.text._ZN9__gnu_cxx13new_allocatorIdE8allocateEmPKv[_ZN9__gnu_cxx13new_allocatorIdE8allocateEmPKv]+0x3c): undefined reference to `operator new(unsigned long)'
/tmp/ccZrNqc0.o:(.eh_frame+0x4b): undefined reference to `__gxx_personality_v0'
collect2: error: ld returned 1 exit status
ludi@ludi-M17xR4:~/Desktop/tests$
Can anyone offer guidance??
Last edited: