Skip to content

GSL – GNU Scientific Library

OpenLB – Open Source Lattice Boltzmann Code Forums on OpenLB General Topics GSL – GNU Scientific Library

Viewing 6 posts - 1 through 6 (of 6 total)
  • Author
    Posts
  • #5240
    guojuw
    Participant

    Dear openLB developers,

    I am currently developing some new features based on openLB. I hope I can use the GSL library (https://www.gnu.org/software/gsl/) to solve some basic algebra related problems.

    May I ask how to compile the openLB with GSL libraries?

    Regards,
    Junwei Guo

    #5241
    stephan
    Moderator

    Dear Junwei,

    thanks for your message.
    In case you installed GSL as suggested on the webpage in its own /gsl directory which is located under the standard search path of your compiler, a simple #include <gsl/… .h> should be enough.

    For more information, please have a look at the GSL user guide (Section 2.2 Compiling and Linking).

    If you have any further questions, please let me know.

    BR
    Stephan

    • This reply was modified 3 years, 5 months ago by stephan.
    #5243
    stephan
    Moderator

    PS: Further below in the GSL user guide (Section 2.2.1 Linking programs with the library), a basic gcc compiliation command is listed with additional compiler flags. You might want to include these flags in the specific Makefile in your OpenLB application. The section in the Makefile typically reads

    ###########################################################################
    ## link
    
    link: $(OUTPUT)
    
    $(OUTPUT): $(OBJECTS) $(ROOT)/$(LIBDIR)/lib$(LIB).a
    	@echo Link $@
    	$(CXX) $(foreach file, $(SRC), $(file:.cpp=.o)) $(LDFLAGS) -L$(ROOT)/$(LIBDIR) -l$(LIB) -lz -o $@
    
    ###########################################################################

    The compiler flags you’d like to use should be added in the last line before $@ (e.g. ... -lgsl -lz -o $@)

    • This reply was modified 3 years, 5 months ago by stephan.
    • This reply was modified 3 years, 5 months ago by stephan.
    • This reply was modified 3 years, 5 months ago by stephan.
    #5247
    stephan
    Moderator

    PPS: GSL typically requires an additional algebra subroutine library. Hence the final compiler command (if the library is linked to the default path) in your Makefile should end with
    ... -lgsl - lgslcblas -lm -lz -o $@.

    #5249
    guojuw
    Participant

    Dear Stephan,

    I worked it out in a different but similar way:

    1. Add “#include ..” in the source code
    2. In $openLBRoot/config.mk, add this line “LDFLAGS := gsl-config --cflags --libs
    3. gsl-config is compiled from GSL source code.

    Thanks for your help.

    Regards,
    Junwei GUO

    #5250
    stephan
    Moderator

    Dear Junwei,

    I am glad that it works.
    Thanks for letting me know how you did it!

    BR
    Stephan

Viewing 6 posts - 1 through 6 (of 6 total)
  • You must be logged in to reply to this topic.