forum.alglib.net

ALGLIB forum
It is currently Mon Dec 23, 2024 1:06 am

All times are UTC


Forum rules


1. This forum can be used for discussion of both ALGLIB-related and general numerical analysis questions
2. This forum is English-only - postings in other languages will be removed.



Post new topic Reply to topic  [ 5 posts ] 
Author Message
 Post subject: strange error
PostPosted: Sat Jan 28, 2012 11:54 am 
Offline

Joined: Sat Jan 28, 2012 11:09 am
Posts: 3
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


Top
 Profile  
 
 Post subject: Re: strange error
PostPosted: Sat Jan 28, 2012 6:04 pm 
Offline
Site Admin

Joined: Fri May 07, 2010 7:06 am
Posts: 927
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.


Top
 Profile  
 
 Post subject: Re: strange error
PostPosted: Sat Jan 28, 2012 6:49 pm 
Offline

Joined: Sat Jan 28, 2012 11:09 am
Posts: 3
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?


Top
 Profile  
 
 Post subject: Re: strange error
PostPosted: Sun Jan 29, 2012 6:25 am 
Offline
Site Admin

Joined: Fri May 07, 2010 7:06 am
Posts: 927
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.


Top
 Profile  
 
 Post subject: Re: strange error
PostPosted: Sun Jan 29, 2012 8:19 am 
Offline

Joined: Sat Jan 28, 2012 11:09 am
Posts: 3
ah, thanks for the explanation.


Top
 Profile  
 
Display posts from previous:  Sort by  
Post new topic Reply to topic  [ 5 posts ] 

All times are UTC


Who is online

Users browsing this forum: No registered users and 31 guests


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot post attachments in this forum

Search for:
Jump to:  
Powered by phpBB © 2000, 2002, 2005, 2007 phpBB Group