User forums > Using Code::Blocks
New to Code:.Blocks
stahta01:
--- Quote from: BlueHazzard on July 23, 2015, 05:58:11 pm ---
--- Quote from: lbertolotti on July 23, 2015, 03:38:57 pm ---Well that worked, but wouldn't it be more correct to change the compiler?
--- End quote ---
so you want to compile your program with the c compiler?
then you have to select c at the new project wizard....
(or save your file as .c because c::b distinguishes c and c++ files by their extension...)
--- End quote ---
Also, need to change the CB Compiler config to link with the gcc instead of g++ command.
Tim S.
lbertolotti:
Ok, one more question: what is the preferred method of installation of GSL for working with Code::Blocks in Windows 8?
C++
--- Code: ---#include <stdio.h>
#include <cstdlib>
#include <gsl/gsl_sf_bessel.h>
#include <iostream>
#include <sstream>
#include <fstream>
using namespace std;
int main()
{
/*Summing a bunch of numbers*/
int numero, somma;
somma=0;
printf ("Insert a number other than 0 in the sequence, otherwise 0 to end the insertion\n");
scanf ("%d", &numero);
while (numero != 0)
{
somma=somma+numero;
printf("Insert a number other than 0 in the sequence, otherwise 0 to end the insertion\n");
scanf("%d", &numero);
}
printf("The sum equals: %d\n", somma);
/*GSL Bessel function*/
double x = 5.0;
double y = gsl_sf_bessel_J0(x);
printf("J0(%g) = %.18e\n", x, y);
/*Writing to a text file*/
FILE *tab1;
tab1=fopen ("somma.txt","w");
fprintf(tab1, "%d", somma);
fclose (tab1);
/*Writing to a csv file*/
ofstream tab2("tabela.csv");
double A; int t;
tab2 << "Col 1;Col 2" << endl;
for (t = 0; t <= 10; t++) {
A = t+somma+y;
cout << "t = " << t << "\t\tA = " << A << endl;
tab2 << t << ";" << A << endl;
}
tab2.close();
/*End*/
system("PAUSE");
return 0;
}
--- End code ---
Build log:
--- Code: ---
-------------- Clean: Release in Test Project (compiler: GNU GCC Compiler)---------------
Cleaned "Test Project - Release"
-------------- Build: Release in Test Project (compiler: GNU GCC Compiler)---------------
mingw32-g++.exe -Wall -fexceptions -O2 -ansi -I"C:\Program Files (x86)\GnuWin32\lib" -c "C:\Users\lucas_000\Documents\Test Project\main.cpp" -o obj\Release\main.o
C:\Users\lucas_000\Documents\Test Project\main.cpp:3:31: fatal error: gsl/gsl_sf_bessel.h: No such file or directory
#include <gsl/gsl_sf_bessel.h>
^
compilation terminated.
Process terminated with status 1 (0 minute(s), 0 second(s))
1 error(s), 0 warning(s) (0 minute(s), 0 second(s))
--- End code ---
oBFusCATed:
Try reading the FAQ on the wiki and especially this page: http://wiki.codeblocks.org/index.php?title=FAQ-Compiling_%28general%29#Q:_I_would_like_to_compile_a_project_using_some_non-standard_libraries._How_can_I_indicate_to_CodeBlocks_that_these_libraries_and_include_files_exist.3F
Also read the manual of your compiler and understand how it handles #includes.
And lastly try to understand what is the difference between "" and <> in the include directive.
BlueHazzard:
And always post the full build log if you want some help...
greetings
lbertolotti:
--- Quote from: BlueHazzard on July 23, 2015, 08:39:42 pm ---And always post the full build log if you want some help...
greetings
--- End quote ---
Done.
Navigation
[0] Message Index
[#] Next page
[*] Previous page
Go to full version