[Qt-interest] How can I use gsl in my Qt application?
Srdjan Todorovic
todorovic.s at googlemail.com
Mon Jul 6 12:14:47 CEST 2009
Hi,
You did not specify if you have googled and what you have found.
Because we are all friendly here, and because we are your personal
google service ( ;-) ) here's a possible fix for your problem:
http://lucksus.org/2009/02/12/cygwin-and-undefined-reference-to-__getreent/
This may or may not be a proper fix - I suggest you google for
alternative solutions.
Srdjan
On 06/07/2009, ri at eeda.denso.co.jp <ri at eeda.denso.co.jp> wrote:
> Hi.
>
> I use cygwin on Windows to get the libgsl.a from the source code of gsl.
>
> I found some c++ sample code using gsl:
>
>
> #include <iostream> // note that .h is omitted
> #include <iomanip> // note that .h is omitted
> #include <fstream> // note that .h is omitted
> using namespace std; // we need this when .h is omitted
>
> #include <gsl/gsl_math.h>
> #include <gsl/gsl_sum.h>
>
> main.cpp
> //*********************************************************************//
> int main (void)
> {
> // evaluating zeta(2) = \sum_{n=1}^{\infty} 1/n^2
> const double zeta_2_exact = M_PI * M_PI / 6.0; // exact answer
>
> const int N = 20; // up to N terms
> double t[N]; // array with i'th term
> double sum = 0; // accumulated sum
> for (int n = 0; n < N; n++)
> {
> double nplus = n + 1.;
> t[n] = 1.0 / (nplus * nplus);
> sum += t[n];
> }
>
> double sum_accel, error;
> gsl_sum_levin_u_workspace *work_ptr = gsl_sum_levin_u_alloc (N);
> gsl_sum_levin_u_accel (t, N, work_ptr, &sum_accel, &error);
>
> cout.setf (ios::fixed, ios::floatfield); // output in fixed format
> cout.precision (18); // 18 digits in doubles
>
> const int width = 19;
> cout << "term-by-term sum = " << setw (width) << sum
> << " using " << N << " terms" << endl;
>
> cout << "term-by-term sum = " << setw (width) << work_ptr->sum_plain
> << " using " << work_ptr->terms_used << " terms" << endl;
>
> cout << "exact value = " << setw (width) << zeta_2_exact << endl;
> cout << "accelerated sum = " << setw (width) << sum_accel << " using "
> << work_ptr->terms_used << " terms" << endl;
>
> cout << "estimated error = " << setw (width) << error << endl;
> cout << "actual error = " << setw (width) << sum_accel - zeta_2_exact
> << endl;
>
> gsl_sum_levin_u_free (work_ptr);
> return 0;
> }
>
> I wrote a pro file using main.cpp as the only source file:
>
> ######################################################################
> # Automatically generated by qmake (2.01a) ? 7 6 18:47:36 2009
> ######################################################################
>
> TEMPLATE = app
> TARGET =
> DEPENDPATH += .
> INCLUDEPATH += C:/work/simpleplot/MyWork/gsl/. .
>
> win32-g++:LIBS += -lgsl
>
> # Input
> SOURCES += main.cpp
>
>
> but the compiler complains as:
>
> mingw32-make
> c:/Qt/2009.02/qt/bin/qmake.exe -win32 -o Makefile gsl.pro
> mingw32-make -f Makefile.Debug
> mingw32-make[1]: Entering directory `c:/work/simpleplot/MyWork/gsl'
> g++ -enable-stdcall-fixup -Wl,-enable-auto-import
> -Wl,-enable-runtime-pseudo-reloc -mthreads -Wl -Wl,-subsystem,windows -o
> debug/gsl.exe debug/main.o -L'c:/Qt/2009.02/qt/lib' -lmingw32 -lqtmaind
> -lgsl -lQtGuid4 -lQtCored4
> c:/Qt/2009.02/qt/lib/libgsl.a(error.o)(.text+0x43): In function `gsl_error':
> /cygdrive/c/work/gsl/err/error.c:43: undefined reference to `__getreent'
> c:/Qt/2009.02/qt/lib/libgsl.a(error.o)(.text+0x53):/cygdrive/c/work/gsl/err/error.c:44:
> undefined reference to `__getreent'
> c:/Qt/2009.02/qt/lib/libgsl.a(error.o)(.text+0x7d):/cygdrive/c/work/gsl/err/error.c:45:
> undefined reference to `__getreent'
> c:/Qt/2009.02/qt/lib/libgsl.a(stream.o)(.text+0x82): In function
> `gsl_stream_printf':
> /cygdrive/c/work/gsl/err/stream.c:37: undefined reference to `__getreent'
> c:/Qt/2009.02/qt/lib/libgsl.a(stream.o)(.text+0xd1): In function
> `gsl_set_stream':
> /cygdrive/c/work/gsl/err/stream.c:61: undefined reference to `__getreent'
> collect2: ld returned 1 exit status
> mingw32-make[1]: *** [debug/gsl.exe] Error 1
> mingw32-make[1]: Leaving directory `c:/work/simpleplot/MyWork/gsl'
> mingw32-make: *** [debug] Error 2
>
>
> Can anyone help?
>
>
More information about the Qt-interest-old
mailing list