GSL – GNU Scientific Library
› Forums › on OpenLB › General Topics › GSL – GNU Scientific Library
- This topic has 5 replies, 2 voices, and was last updated 5 years ago by stephan.
-
AuthorPosts
-
October 23, 2020 at 1:13 am #5240guojuwParticipant
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 GuoOctober 23, 2020 at 10:27 am #5241stephanModeratorDear 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 5 years ago by stephan.
October 23, 2020 at 11:04 am #5243stephanModeratorPS: 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 $@)October 23, 2020 at 11:21 am #5247stephanModeratorPPS: 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 $@.October 25, 2020 at 7:24 pm #5249guojuwParticipantDear 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 GUOOctober 26, 2020 at 10:35 am #5250stephanModeratorDear Junwei,
I am glad that it works.
Thanks for letting me know how you did it!BR
Stephan -
AuthorPosts
- You must be logged in to reply to this topic.
