1

I'm trying to use GSL for my project using Code::Blocks. After much searching and googling, I've finally got past the compiler but still the code didn't run because of an undefined reference. My code is just the sample problem given by the GSL manual:

#include <stdio.h>
#include <gsl/gsl_sf_bessel.h>

int main (void)
{
  double x = 5.0;
  double y = gsl_sf_bessel_J0 (x);
  printf ("J0(%g) = %.18e\n", x, y);
  return 0;
}

I followed all the steps everyone on the Internet has told me (putting the include folder in Search directories/Compiler, the lib folder in Search directories/Linker, and the two .a files under Linker settings).

Still the undefined reference error persisted. I'm quite lost at this stage. Any help will be greatly appreciated.

Edit: I'm so sorry I'm new to the rules. Here are the images of the Code::Blocks build options: Search directory for the compiler

Search directory for the linker

Linker setting

Loc Duong
  • 19
  • 2
  • This is a great time, one of the only good times, to use an image. Grab a screenshot of the Code::Blocks library dialogue so we can see exactly what you've got. Sometimes the simplest of little typos can getcha. You don't have permission go make an image visible yet, but there are many here who can help you out if you provide the image.. – user4581301 Oct 17 '22 at 04:47
  • Uugh... no image. You understand what the compiler is looking for, now go confirm each piece. Make sure your compiler options contain an `-I/path/to/gsl/include` and `-L/path/to/gsl/lib` **and** make sure you have included ALL necessary headers **and** make sure you have `-lgsl`for gcc. Just looking at your code, it almost looks like you need an `#include `, but I haven't used gsl on windows, so that may be correct. Regardless, your question states exactly what you need to ensure the configuration is, go double check. I'll boot windows and see if I have gsl installed. – David C. Rankin Oct 17 '22 at 04:51
  • you need to download [GSL](https://mirror.ibcp.fr/pub/gnu/gsl/gsl-latest.tar.gz) and compile it then you need to import the DLLs created upon compilation and put them in the directory where you have your solution/project. [Here](https://solarianprogrammer.com/2020/01/26/getting-started-gsl-gnu-scientific-library-windows-macos-linux/#gsl_installation_linux) an explanation how to do that, – odaiwa Oct 17 '22 at 04:52
  • 1
    Yes, that's my next question. Where did you get your gsl for windows? The last version fpr windows on sourceforge is Ver. 1.8 and is 16 years old that requires vcc6 from before Windows XP days. That won't work. You need to install the latest source (Ver. 2.7.1 and build it -- I'd use Msys2 -- which is an amazing Linux build environment for Windows -- also what you would use for building for Raspberry Pi/Pico, etc.... – David C. Rankin Oct 17 '22 at 05:11
  • Please show a [mre] including all the information people have asked for above including the full build output text – Alan Birtles Oct 17 '22 at 06:08
  • Hi everyone, I've uploaded some screenshots from Code::Blocks there. For David's comment, I used Ubuntu to compile my code but it never got past the header... I may have done something wrong I'll try again. – Loc Duong Oct 17 '22 at 21:25
  • For odaiwa's comment, the link you sent me recommends installing Visual Studio. Is there an advantage to that as compared to Code::Blocks? Also, I couldn't find any .dll file, not in the compressed folder I downloaded or the installed folder... – Loc Duong Oct 17 '22 at 21:29

0 Answers0