CFD Online Logo CFD Online URL
www.cfd-online.com
[Sponsors]
Home > Forums > OpenFOAM Programming & Development

Linking GSL to OpenFOAM

Register Blogs Members List Search Today's Posts Mark Forums Read

Reply
 
LinkBack Thread Tools Display Modes
Old   May 9, 2012, 19:17
Default Linking GSL to OpenFOAM
  #1
Senior Member
 
Hisham's Avatar
 
Hisham El Safti
Join Date: Apr 2011
Location: Braunschweig, Germany
Posts: 247
Blog Entries: 10
Rep Power: 7
Hisham is on a distinguished road
Hi Foamers,

I need to use the GSL (Gnu Scientific Library) inside an OpenFOAM application to solve a system of complex linear equations. I want to use the GSL. I installed the libgsl0-dev as stated by the GSL manual. According to the manual one needs to link as:
Code:
$ gcc -L/usr/local/lib example.o -lgsl -lgslcblas -lm
So after including the needed header (a copy paste from a GSL example code from the manual), I added this to the options file:
Code:
EXE_INC = \
    -I$(LIB_SRC)/finiteVolume/lnInclude \
    -I$(LIB_SRC)/meshTools/lnInclude \
    -I/usr/local/include \
    -I/include

EXE_LIBS = -lfiniteVolume

LIB_LIBS = \
    -lOpenFOAM \
    -lmeshTools \
    -lgsl -lgslcblas -lm
I get the error:
Code:
Make/linux64GccDPOpt/seabed.o: In function `main':
seabed.C:(.text+0x14be): undefined reference to `gsl_matrix_view_array'
seabed.C:(.text+0x14d8): undefined reference to `gsl_vector_view_array'
seabed.C:(.text+0x14e2): undefined reference to `gsl_vector_alloc'
seabed.C:(.text+0x14ef): undefined reference to `gsl_permutation_alloc'
seabed.C:(.text+0x150a): undefined reference to `gsl_linalg_LU_decomp'
seabed.C:(.text+0x1525): undefined reference to `gsl_linalg_LU_solve'
seabed.C:(.text+0x1561): undefined reference to `gsl_permutation_free'
seabed.C:(.text+0x1569): undefined reference to `gsl_vector_free'
collect2: ld returned 1 exit status
make: *** [/home/hisham/OpenFOAM/hisham-2.0.1/platforms/linux64GccDPOpt/bin/seabed] Error 1
Which is according to Google most likely a linking problem.

Any ideas?

Best regards,
Hisham El Safti
Hisham is offline   Reply With Quote

Old   May 9, 2012, 20:10
Talking
  #2
New Member
 
Join Date: Apr 2010
Posts: 9
Rep Power: 6
Bandfrosch is on a distinguished road
Good evening Hisham,
my bet :
missing library search path :

Code:
..
..
..
LIB_LIBS = \
     -lOpenFOAM \
     -lmeshTools \
    -L/usr/local/lib \
    -lgsl -lgslcblas -lm
Regards,
Bandfrosch
Bandfrosch is offline   Reply With Quote

Old   May 9, 2012, 20:30
Default
  #3
Senior Member
 
Hisham's Avatar
 
Hisham El Safti
Join Date: Apr 2011
Location: Braunschweig, Germany
Posts: 247
Blog Entries: 10
Rep Power: 7
Hisham is on a distinguished road
Hi Bandfrosch,

No .. It didn't work! I even tried different paths just to make sure! It gives the same error!
Hisham is offline   Reply With Quote

Old   May 10, 2012, 04:07
Default
  #4
Senior Member
 
Christian Lucas
Join Date: Aug 2009
Location: Braunschweig, Germany
Posts: 198
Rep Power: 7
Chris Lucas is on a distinguished road
Hi,

this worked for me without a problem.

options:

LIB_LIBS = \
-lgsl \
-lgslcblas

Did you compile gsl yourself?

Best Regards,
Christian
Chris Lucas is offline   Reply With Quote

Old   May 10, 2012, 04:22
Default
  #5
Senior Member
 
Hisham's Avatar
 
Hisham El Safti
Join Date: Apr 2011
Location: Braunschweig, Germany
Posts: 247
Blog Entries: 10
Rep Power: 7
Hisham is on a distinguished road
Hi Christian

No I used the Ubuntu pre-installed GSL and installed only libgsl0-dev
Hisham is offline   Reply With Quote

Old   May 10, 2012, 04:38
Default
  #6
Senior Member
 
Christian Lucas
Join Date: Aug 2009
Location: Braunschweig, Germany
Posts: 198
Rep Power: 7
Chris Lucas is on a distinguished road
Hi,

I use the provided gsl library from Ubuntu as well. Works without a problem for my case.

I didn't need to define a path to the gsl library, the compiler found the it without the path.

I'm not sure if this works, but could you try the following lines in the option file:

-L/usr/local/lib -lgsl \
-L/usr/local/lib -lgslcblas \

Christian
Chris Lucas is offline   Reply With Quote

Old   May 10, 2012, 04:47
Default
  #7
Senior Member
 
Hisham's Avatar
 
Hisham El Safti
Join Date: Apr 2011
Location: Braunschweig, Germany
Posts: 247
Blog Entries: 10
Rep Power: 7
Hisham is on a distinguished road
It did not work, the same error again. I think as you said the headers are in the default path ... I will just pack the files and post them!
Hisham is offline   Reply With Quote

Old   May 10, 2012, 04:56
Default
  #8
Senior Member
 
Hisham's Avatar
 
Hisham El Safti
Join Date: Apr 2011
Location: Braunschweig, Germany
Posts: 247
Blog Entries: 10
Rep Power: 7
Hisham is on a distinguished road
Download the files from HERE
Hisham is offline   Reply With Quote

Old   May 10, 2012, 05:18
Default
  #9
Senior Member
 
Arne Stahlmann
Join Date: Nov 2009
Location: Hanover, Germany
Posts: 209
Rep Power: 8
Arnoldinho is on a distinguished road
Hi,

for me a simple
Quote:
EXE_INC = \
-I$(LIB_SRC)/OpenFOAM/lnInclude \

EXE_LIBS = \
-lgsl \
-lgslcblas \
in options worked without a problem. I'm using the pre-compiled Ubuntu 10.04. GSL version. But I can't remember if I had to install anything else besides libgsl0-dev.

Arne
Arnoldinho is offline   Reply With Quote

Old   May 10, 2012, 05:24
Default
  #10
Senior Member
 
Hisham's Avatar
 
Hisham El Safti
Join Date: Apr 2011
Location: Braunschweig, Germany
Posts: 247
Blog Entries: 10
Rep Power: 7
Hisham is on a distinguished road
Hi Arne,

Thanks a lot! Your suggestion worked I didn't have to specify a path though

Thanks again to all!

Best regards,
Hisham El Safti
Hisham is offline   Reply With Quote

Old   May 10, 2012, 05:32
Default
  #11
Senior Member
 
Arne Stahlmann
Join Date: Nov 2009
Location: Hanover, Germany
Posts: 209
Rep Power: 8
Arnoldinho is on a distinguished road
You're welcome. Greetings to Braunschweig.
Arnoldinho is offline   Reply With Quote

Old   May 10, 2012, 06:39
Default
  #12
Senior Member
 
Hisham's Avatar
 
Hisham El Safti
Join Date: Apr 2011
Location: Braunschweig, Germany
Posts: 247
Blog Entries: 10
Rep Power: 7
Hisham is on a distinguished road
Greetings to you too and to Hannover of course
Hisham is offline   Reply With Quote

Reply

Tags
complex, gnu, gsl, openfoam, scientific

Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
Linking ALGLIB to OpenFOAM Phicau OpenFOAM Programming & Development 6 January 12, 2012 17:15
How to Install OpenFOAM on 64 Ubuntu 9.04 hansel OpenFOAM Installation 62 March 19, 2010 16:43
Superlinear speedup in OpenFOAM 13 msrinath80 OpenFOAM Running, Solving & CFD 17 August 22, 2009 04:59
Modified OpenFOAM Forum Structure and New Mailing-List pete Site News & Announcements 0 June 29, 2009 06:56
Adventure of fisrst openfoam installation on Ubuntu 710 jussi OpenFOAM Installation 0 April 24, 2008 15:25


All times are GMT -4. The time now is 15:19.