User forums > Using Code::Blocks
Can't use standard functions like fprintf when using linker to link libraries
cacb:
--- Quote from: chris on December 22, 2022, 12:35:53 pm ---This code works fine when I don't link any libraries.
--- End quote ---
That's a clue. Make sure those libraries are built with the compiler you are using.
jordi:
You are not using any gsl function in your code. I would remove the include.
Weird but maybe some lib you are including have redefined the printf symbol
Try the next code with the libraries included.
--- Code: --- #include <stdio.h>
#include <gsl/gsl_vector.h>
int
main (void)
{
int i;
gsl_vector * v = gsl_vector_alloc (100);
for (i = 0; i < 100; i++)
{
gsl_vector_set (v, i, 1.23 + i);
}
{
FILE * f = fopen ("test.dat", "w");
gsl_vector_fprintf (f, v, "%.5g");
fclose (f);
}
return 0;
}
--- End code ---
chris:
--- Quote from: cacb on December 22, 2022, 02:39:57 pm ---
--- Quote from: chris on December 22, 2022, 12:35:53 pm ---This code works fine when I don't link any libraries.
--- End quote ---
That's a clue. Make sure those libraries are built with the compiler you are using.
--- End quote ---
LOL thank you! I'm completely new to using libraries, and followed instructions from stackexchange on how to install the library. The isntructions I followed were for MS Visual Studio. The confusing part for me was that it worked nearly perfectly (for my purposes) in C::B, until it didnt!
I've switched to using VS for now, and it works and prints as you would expect.
Anyone got any good recommendations on resources about what a compiler is... Feeling very out of my depth.
Navigation
[0] Message Index
[*] Previous page
Go to full version