forum.alglib.net
http://forum.alglib.net/

strange error
http://forum.alglib.net/viewtopic.php?f=2&t=530
Page 1 of 1

Author:  jrieger [ Sat Jan 28, 2012 11:54 am ]
Post subject:  strange error

Hi everybody,

I am not very good at C++, but I can program reasonably well in C. Now I try to use
alglib in order to obtain a singular value decomposition of a square matrix, but when I
try to define a matrix, I already get a strange error which I don't understand. I paste
a reduced example below.


#include <iostream>
#include "ap.h"
#include "linalg.h"

using namespace std;
using namespace alglib;

int main() {
alglib::real_2d_array r2;
//removing alglib:: does not improve the situation
system("pause");
}


I receive the following error:

[Linker error] undefined reference to `alglib::real_2d_array::real_2d_array()'
[Linker error] undefined reference to `alglib::real_2d_array::~real_2d_array()'
[Linker error] undefined reference to `alglib::real_2d_array::~real_2d_array()'
ld returned 1 exit status


I am using the old Bloodshed Dev-C++ system, and this error occurs no matter if I put
the alglib source and header files into the source folder or the folder where the standard
libraries are located.

I know that my problem is probably something silly like a missing declaration, but I would
be very happy if someone could help me with it.

Janosch

Author:  Sergey.Bochkanov [ Sat Jan 28, 2012 6:04 pm ]
Post subject:  Re: strange error

You should add .cpp files from ALGLIB folder to your project and compile them along with it. Just having them in your include path (or current folder) is not enough.

Author:  jrieger [ Sat Jan 28, 2012 6:49 pm ]
Post subject:  Re: strange error

Oh, thanks a lot. That really does it. But could you explain why I have to
do that? Usually it is enough to include the header files. What makes the
difference here?

Author:  Sergey.Bochkanov [ Sun Jan 29, 2012 6:25 am ]
Post subject:  Re: strange error

Because you have to compile source code in order for your program to work. When you reference standard libraries (stdlib.h, stdio.h, ...), precompiled libs are implicitly added to your project. ALGLIB is a custom code, which have to be compiled explicitly.

Author:  jrieger [ Sun Jan 29, 2012 8:19 am ]
Post subject:  Re: strange error

ah, thanks for the explanation.

Page 1 of 1 All times are UTC
Powered by phpBB © 2000, 2002, 2005, 2007 phpBB Group
http://www.phpbb.com/