Hi, I'm new to learning to code in C, migrating from MATLAB, so I'm new to using external libraries and things, so please bear with...
I've installed the gnu scientific library to my C:\ drive, and linked it to each codeblocks project following instructions found online
1. copy the .dll files into the project folder
2. project > build options > search directories > compiler , then included the file path C:\...\gsl_x64-windows\include [I've added the dots here for clarity, the full file path is included]
3. project > build options > linker settings , and added C:\...\gsl_x64-windows\lib\gslcblas.lib and C:\...\gsl.lib
The project works fine for the most part. I'm able to use gsl functions, and everything seems to work correctly. The problem occurs when using fprintf to save my data to a .txt file.
It's step 3 that causes the issue for me. I've tried different iterations of each of those steps, and the error only occurs when I've included the .lib files in linker settings.
Every project that I set up in this way has the same problem. The programme runs until it reaches the fprintf line, and then it exits with the return -1073741819 (0xC0000005), which from googling seems to do with permission/access.
The files will be created in the folder (by the fopen command) but nothing gets written in them.
The weirdest part (to me at least) is that I CAN use fprintf when printing a typed out string, but as soon as I use a placeholder:
for (i = 0 ; i < 5 ; i++ ){
fprintf(fTest, "%d\n", array[i]);
}
it no longer works and gives me that error.
I might be missing something obvious, or not... I'm just confused as to why fprintf doesn't work when I include linked libraries.
To clarify, I am able to use fprintf when I don't use linker settings to link libaries, and the results are fine and as expected. However, I then can't use the libraries I need as it comes up with a error "undefined reference to [gsl function name]"
Please can someone let me know what is going on.
Thanks!
EDIT: Forgot to mention, the problem seems to linger after clearing linker settings, unless I click build > clear. Then problem stops then