User forums > Using Code::Blocks

New to Code:.Blocks

<< < (2/4) > >>

oBFusCATed:

--- Quote from: BlueHazzard on July 23, 2015, 01:33:52 am ---formatting is perfect  :D  , but we still need a full rebuild log to know exactly what you are doing

--- End quote ---
No, we don't need the full rebuild log.
The linker has told him exactly what the problem is.
There are two main functions - one in the main.cpp and one in gsl.cpp obivously this is not allowed,
so one of them should be removed either by deleting it in the code or by removing one of the files from the project.

lbertolotti:
Let's simplify things a little bit:

c++ code


--- Code: ---
#include <iostream>
#include <stdio.h>
using namespace std;

int main()
{
    int numero, somma;
somma=0;
printf ("inserisci un numero diverso da 0 come componente della sequenza, 0 per terminare la fase di acquisizione\n");
scanf ("%d", &numero);
while (numero != 0)
{
somma=somma+numero;
printf("inserisci un numero diverso da 0 come componente della sequenza, 0 per terminare la fase di acquisione\n");
scanf("%d", &numero);
}
printf("La somma dei numeri digitati รจ: %d\n", somma);

    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  -c "C:\Users\lucas_000\Documents\Test Project\main.cpp" -o obj\Release\main.o
mingw32-g++.exe  -o "bin\Release\Test Project.exe" obj\Release\main.o  -s 
Output file is bin\Release\Test Project.exe with size 40.50 KB
Process terminated with status 0 (0 minute(s), 0 second(s))
0 error(s), 0 warning(s) (0 minute(s), 0 second(s))
 

--- End code ---

This works, but I get no exe file. Why?

It says the exe file is saved in the bin\Release folder but... when I try to open it I get:
The program can't start because libgcc_s_dw2-1.dll is missing from computer.

How can that be?

BlueHazzard:
i never got this warning...
but 1 second of using google gave me this: http://stackoverflow.com/questions/4702732/the-program-cant-start-because-libgcc-s-dw2-1-dll-is-missing with the easiest solution:

--- Quote ---Code::Blocks: add '-static' in settings->compiler->Linker settings->Other linker options.
--- End quote ---

why do you add "-fexceptions" to the compiler settings? Aren't they enabled by default? (Ah, i see you are trying to compile pure c code with c++, but i think if you are using g++ as compiler then exception are enabled by default, also if your code is pure c (i don't know this exactly), i don't think that g++ can differentiate between c and c++ code)

lbertolotti:
Well that worked, but wouldn't it be more correct to change the compiler?

BlueHazzard:

--- 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...)

Navigation

[0] Message Index

[#] Next page

[*] Previous page

Go to full version