FAQ Database Discussion Community


Code::Blocks - Linux - prints “Hello World” even though it isn't in the “main.cpp” file

c++,linux,codeblocks,archlinux
I have recently started a few projects to help me learn C++, I am creating a program that allows the user to enter a grade score /100, the code is as follows: #include <iostream> #include <cstdio> #include <cstdlib> using namespace std; int main (gradeScore) { int gradeScore cout << "Enter...

How to get the mutlithreaded working in CodeBlocks?

c++,multithreading,c++11,codeblocks
I have code which uses multithread ability of C++11. I am able to execute the code in the terminal using the command: g++ main.cpp -o main -pthread -std=c++11 But I am unable to execute the same code from the CodeBlocks. Whenever I attempt to do it, it throws the error...

Dependencies description of wxWidgets libraries

wxwidgets,codeblocks,windows-7-x64
I simply want to use wxRichTextCtrl, but I have dependencies, dependencies, dependencies... So, libwxmsw30u_richtext.a has this dependencies: libwxmsw30u_html.a, libwxbase30u_xml.a, libwxexpat.a and more more more. Is somewhere FAQ about such dependencies? Because I have one unsolved dependency on "wxToolbook, wxChoiceBook" by now, and I have no idea what library I miss....

Copy/pasting feature in codeblocks

ide,codeblocks
I have installed Code::Blocks 13.12 in my windows 8.1 but pasting input at runtime in the command line(I think it is called command line)doesn't seem to work.I have to type the whole input inorder to get output.Can anybody tell me how to fix this? P.S :- I have tied ctrl+V...

Linking problems with GLFW MinGW

c,codeblocks,linker-error,glfw
I'm having some linking problems with GLFW (version 3.1) in Code::blocks. I've done a lot of searching around and nothing I can find seems to be correcting anything. I am currently using the 32-bit binary of the library and have these linker options in my project -lmingw32 -lglew32 -lglfw3 -lopengl32...

code blocks and g++ error “is private”

c++,c++11,g++,codeblocks
I'm getting these errors with the code blocks IDE(with g++ compiler) "is private" for every member variable. As far as I know it is only legal to use the private variables within the other members, which is what i'm doing. This is the code of my cpp: /* bullsAndCows.cpp */...

Code::blocks complaining about type of parameter

c++,reference,compiler-errors,codeblocks
I am building a 3D Game Engine. I have build many in other languages, but finally decided to reap the speed benefits of C++ (despite not knowing it particularly well). I have a class called EngineOptions that I use to store information about how the engine is to be initialized....

Linux - setting Code::Blocks to compile multithreading C++ code

linux,multithreading,c++11,codeblocks
I have searched through forums here, but nothing helped to the end in my case. I'm trying to write and compile some C++ multithreading code in Code::Blocks 13.12, for now the only code I have is: #include <iostream> #include <thread> void cpp11() { std::cout<<"C++11 MULTITHREADING\n"; } int main() { std::thread...

Reusable Code Chunks - Ruby Blocks, Procs, Lambdas

ruby,lambda,codeblocks,procedures
New to ruby. Wrote a program now trying metaprogramming. As you can see i have the code below. Have marked common statements. How do I write these in one place and use them again and again. The statements are part of a loop. So its like I just want to...

C++ program doesn't run correctly

c++,struct,codeblocks
I have written a note program. Which reads some notes, keeps them and allows the user to delete, select or update a note. It's compiling and running, but it doesn't run correctly. I have this struct: struct List { char title[101]; char text[501]; int cont; struct List* next; };typedef List...

Weird segfaults when calling TTF_OpenFont

c++,linux,segmentation-fault,codeblocks,sdl-2
I ported a game I am making from SDL 1.2 to SDL2. After porting the game and getting it to compile properly I get a segfault when I call TTF_OpenFont here: bool cargararchivos(SDL_Texture* &background,SDL_Texture* &player,TTF_Font* &font,SDL_Texture* &bullet,Config* placlips,SDL_Renderer* renderer) { string playerss; //Open the font font = TTF_OpenFont( "lazy.ttf", 28...

No match for 'operator=' in sort function

c++,c++11,g++,codeblocks
I'm trying to have a program write out all permutations of a string. Here is my code: #include <stdio.h> #include <string> #include <iostream> #include <algorithm> using namespace std; int main () { string input; int length; cin >> input; input = sort(begin(input), end(input)); length = input.length(); do { cout <<...

Loading a c program in another one

c,include,codeblocks
I have written a program and i want to link it to another c program. In the sense, by using the include or any other directive, I need to link the programs, such that a function of the former can be called by the latter. How can i accomplish this...

SFML 2.3 and CodeBlocks error compilation

c++,compilation,codeblocks,sfml
I'm trying to make sfml works with codeblocks. I did everything said in this video tutorial : https://www.youtube.com/watch?v=gEGWO8ug2bY Everything works if I only add SFML/Graphics.hpp, so my config isn't completely bad. But if I try to add SFML/Audio.hpp (I need to add sounds to my project) and write "sf::Music background_music;"...

Error: C++ requires a type specifier for all declarations

c++,compiler-errors,codeblocks,specifier
I'm new to C++ and I've been reading this book. I read a few chapters and I thought of my own idea. I tried compiling the code below and I got the following error: ||=== Build: Debug in Password (compiler: GNU GCC Compiler) ===| /Users/Administrator/Desktop/AppCreations/C++/Password/Password/main.cpp|5|error: C++ requires a type specifier...

Can't link wxWidgets app with Code::Blocks / MinGW

c++,linker,mingw,codeblocks,wxwidgets
I have an already working c++ + wxWidgets app built in Eclipse, with wxWidgets built using MSYS. Now i'd like to try different IDEs, like CodeLite and Code::Blocks, but when i tried them they did'nt work 'cause i was lacking a build.cfg file they wants. So i tried a "clean"...

Setting up a Lib Project and Unit Test Project in same workspace

codeblocks
I have a codeblocks workspace, with a static lib project in it. I wish to add another project with unit tests (gtest) for the lib, and have it link the static lib to test it. Is there an equivalent to Visual studio's adding a reference on the unit test project...

While-loop breaks, and I don't know the reason why

c++,c++11,while-loop,codeblocks
I was writing a code for a counter. If I give 'a' as input, it should +1 the counter and show it on the screen. But when I do it, it shows 1 on the screen and the program ends. I want it to run until and unless i give...

Inserting a text into a specific line

c,codeblocks
I am trying to create a function which inserts texts between lines according to the user input. The user has to specify the line number and the index in order to insert his line. Currently, I have managed to insert the text before the line, but I can't insert it...

CodeBlocks C++ Bug

c++,codeblocks
I was doing something in C++ (CodeBlocks), but I found a weird problem. I sent my code to my friend (he tested it in DevC++) and it worked. I tried these two codes: #include <iostream> #include <math.h> using namespace std; int main() //this function works { if (pow(3, 2) +...

Code::Blocks Can't compile application

c,codeblocks
This is my hello world code: #include <stdio.h> #include <stdlib.h> int main() { printf("Hello world!\n"); return 0; } When I'm trying to run application I'm getting an error: Target uses an invalid compiler; run aborted So I went to Settings->Compiler->Toolchain Executables, and I selected C:\MinGW\bin, I have also tried C:\MinGW...

C Unknown type name 'DATA'

c,compiler-errors,codeblocks,typedef
I don't really understand why I've been getting this error : Unknown type name 'DATA'. #include <stdio.h> #include <stdlib.h> typedef int DATA; #include "PriorityQueue.h" int main(){ int priority; DATA value; LINK *head; createEmpty(&head); add(&head, 1, 7); checkIfEmpty(head); add(&head, 5, 5); add(&head, 3, 4); deleteElement(&head, &priority, &value); add(&head, 1, 3); destroy(head);...

In C++, I'm getting a message “error: 'void*' is not a pointer-to-object type”

c++,compiler-errors,codeblocks,memory-address,void-pointers
Here's my code: #include <iostream> using namespace std; int main() { void *x; int arr[10]; x = arr; *x = 23; //This is where I get the error } As you can see, the code is very simple. It just creates a void pointer x which points to the memory...

Unable to copy an .exe to Start Menu folder

c++,copy,exe,codeblocks
I've been studying Java for about half a year and now I'm learning C++. I'm using CodeBlocks with minGW and Win 8.1. My problem is that I can copy an .exe file to the windows folder like this: string str = string("copy " + currPath + " " + "C:\\\\Users\\\\Johan\\\\AppData\\\\Roaming\\\\Microsoft\\\\Windows\\\\ProgramCopy.exe");...

Error while using Boost Asio

c++,boost,mingw,boost-asio,codeblocks
I get "::UnregisterWaitEx is not declared" inside win_object_handle_service.ipp whenever I try to include < boost/asio.hpp > into my code. Currently I am using Code::Blocks, MinGW compiler (which didn't come bundled with IDE) on Windows 8.1. Boost is built outside of mingw include folder, though is included in project settings. Exact...

fontconfig/fontconfig.h not found in Codeblocks

cocos2d-x,codeblocks
I am trying to build Cocos2d-x project in Codeblocks IDE in Ubuntu 14. I got fontconfig/fontconfig.h not found error during compiling. I'm stuck here. How can I solve this?

Why is the size of files compiled by gnu gcc and cygwin gcc different?

c++,gcc,cygwin,codeblocks,gnu
This is just a small "Hello World" program, which when compiled using Cygwin GCC and GNU GCC is different in size. #include <iostream> main(){ cout<<"Hello World";} The cygwin version is only 60.7 Kb, while for GNU it is 978 Kb. Why is this so, if they both use GCC only?...

C++ Header files (basics)

c++,header,codeblocks
I was trying to use header files and source files but ran into issues. I therefore made a simplified version of what I am trying to do and I am getting the same error in CodeBlocks (undefined reference to add(double, double) in main.cpp). In add.cpp: double add (double x, double...

Trouble using conio.h library [closed]

c++,codeblocks,conio
Am having trouble using the Conio library in my code blocks IDE while doing c++ code. Am using Windows 8.1. To be specific i need to use conio library functions for my c and c++ programs but the header file is not available.am looking for a link or address to...

Why cout is producing no output on Code Blocks?

c++,codeblocks,iostream,cout
#include <iostream> using namespace std; int main(int argc, char** argv) { cout << "Whatever"; return 0; } Cout does not work, nor printf, nor puts, nor anything. Also, I've checked the project properties and both the debug and release are set to "Console Application" and to "Pause in the end"....

Internal Error in codeblocks [closed]

c++,c,c++11,gcc,codeblocks
My code was compiling just fine until recently i started using a pair for stl maps and then their was some issue. Every time i compile any file which was compiling just fine before hand i get the error The same error comes for every file regardless of its function....

What happens when method name and block name are same?

ruby,codeblocks,yield
I am trying to understand the below behavior: def test puts "In Method" end test #=> In Method test {puts "In Block" } #=> In Method My interpretation is that test is a method and I am passing {puts "In Block"} as an argument to this method. Since the method...

How to space first_name + last_name C++

class,codeblocks,spacing
My question is how can i use spaces between first_name and last_name after i instruct the user to input his name. I am using code blocks and I'm kinda confused. In Dev C++ i can do cout<<first_name<<" "<<last_name; Now what I am doing is just practicing C++ using variables in...

'for each' is not a member of std. C++11 support already enabled

c++,c++11,netbeans,std,codeblocks
The code from my professor's homework assignment is as follows. This is straight out of the box, I have not modified my professor's code. There is more to the program, but this is where the error happens. Problem line in bold. std::cout << "\nAll remaining courses with enrollments:\n"; allCourses =...

C++ - stoi() was not declared in this scope

c++,c++11,gcc,compiler-errors,codeblocks
I'm practicing my C++ by coding simple input/ouput from user. I have now been searching for over an hour on how to convert a string to an int. Every answer is different, and require something else. I'm using Code::Blocks v.13.12. MingW32 folder is added to environment variables. I ended up...

User input to break while loop to return to the main

c,codeblocks
So, I need to break the loop with the user input if it was C, but it does not break the loop and return to the main. It sticks to the same loop. void createFile(void) { FILE *NewFile; char *file_name = malloc(sizeof(*file_name)); printf("\nEnter a name of the file you want...

Error : Cmake can't generate openCV

opencv,cmake,codeblocks
I am trying to instal opencv C++ with codeBlocks in Windows 8 by following this http://kevinhughes.ca/tutorials/opencv-install-on-windows-with-codeblocks-and-mingw/ but I am blocked in step 4.when I try to generate Cmake I have this Error : CMake Error: CMake was unable to find a build program corresponding to "MinGW Makefiles". CMAKE_MAKE_PROGRAM is not...

process returned 255 (0xff) code blocks [closed]

c++,codeblocks
I don't know where my problem is. I tried to compile the code once and it worked. However, I copied it in a new project in order to modify it, just the colour or the time to wait, and it just works in the first programme. What is wrong? I...

Missing 407 when print Amstrong Number in C language

c,codeblocks
I use Code::Block 10.02 and When print Amstrong Number in C.I wait a result like this: 153 370 371 407 But It's only print: 153 370 371 This is my code in C: #include <stdio.h> #include <conio.h> #include <math.h> int main() { int a,b,c; for (a=1;a<=9;a++) for(b=0;b<=9;b++) for(c=0;c<=9;c++) { if(pow(a,3)+pow(b,3)+pow(c,3)==100*a+10*b+c)...

Code runs on OSX, Segmentation fault in Codeblocks VMbox

c++,segmentation-fault,codeblocks
So when I run this in OSX it works correctly, but my class requires for it to work in a Xubuntu VMbox using Codeblocks. When I try to run it in Codeblocks or terminal of VMbox I get the error 'Segmentation fault (core dumped)'. Does this maybe have something to...

Undefined reference to `SHA1'

c,windows,openssl,codeblocks,sha1
I'm posting here due to a problem with Code::Blocks I've recently created a project in linux which compiled and executed correctly. Now I am trying to made it work on windows. Problem When I tried to compile thanks to Code::Blocks I received the error : C:\Users\PC\Desktop\Collector\verification.c |44|undefined reference to `SHA1'|...

Code::Blocks isn't executing properly

c++,gcc,codeblocks
I'm new to programming so I feel there is something simple I'm missing here. I'm using the latest version of Mac and I've just installed Code::Blocks along with Xcode so I can use the gcc compiler. I created a new "console application" project and the code for a hello world...

Debugging header files in codeblocks

c,header,codeblocks
I am trying to debug header file in codeblocks. I have tried some options like "run to cursor" and by putting breakpoint in header file but it doesn't stops there and passes through there. How can I debug .h file in it? If you need any information, just comment. I'll...

Incorrect Total in C

c,codeblocks
Ok I have to calculate in C this tax rate. Basically, the first 10,000 isn't taxed, the next 30,000 is taxed 10% and the next 20,000 is taxed 20%. So for example: Your income is 60,000. The first 10,000 isn't taxed, so now there is 50,000 remaining. The next 30,000...

kbhit function in CodeBlock not work in C language

c,codeblocks
I use windows 8, and Code::Block 13.12. I have code C language like that: #include <stdio.h> #include <conio.h> main() { while (!kbhit()) printf("You haven't pressed a key.\n"); return 0; } When I press a key, It not Stop, i don't think my code wrong, have any suggest for me to...

Block syntax translation problems Objective C to Swift

ios,swift,translation,codeblocks,uipickerviewcontroller
TWPhotoPickerController *photoPicker = [[TWPhotoPickerController alloc] init]; photoPicker.cropBlock = ^(UIImage *image) { //do something }; [self presentViewController:photoPicker animated:YES completion:NULL]; Been stuck on this for way too long. I have imported all the correct header files into my bridging header file... just need to know how do I translate this block into...

defining my_each in terms of my_times

ruby,iterator,codeblocks,control-flow,ruby-1.9.1
I'm reading The Well-Grounded Rubyist and have come across an extra credit challenge to which there is no answer. class Array def my_each c = 0 until c == size yield(self[c]) c += 1 end self end end An example is given of creating a my_each with my_times class Array...

c++ How to use a class from another project

c++,class,interface,codeblocks
I've been searching for how to do this for nearly an entire day. At first, I thought that this can be done by... Right click the project name -> "Add files" -> choosing a .cpp file which contains the class you need and the corresponding header file. Then, the .cpp...

code blocks not compiling empty c file in linux lite

c,linux,gcc,codeblocks,permission-denied
I am using linux Lite. I have installed code Blocks. When i am creating any new project then it is working correctly. it compiling codes. But When any empty c file is creating and trying to compile then it is not working.Showing message that permission denied. I have checked the...

SFML code completion not working for Code::Blocks 13.12 on Ubuntu 14.04

c++,ubuntu,codeblocks,sfml,code-completion
EDIT: NOT WORKING ON ANY IDE, SEEMS TO BE A GENERAL MISCONFIG So hello guys. It's taking a bit longer to set my Ubuntu system to code with SFML and C++ than expected. This should be one of the last problems really. So my C::B 13.12 install via apt-get on...

C++: Why Does It Output On Alternative Basis?

c++,gcc,codeblocks
Consider the following C++ code: (codeblocks = IDE) #include <iostream> #include <stdio.h> using namespace std; int main() { int a; while(cin>>a) { cout<<"You sir, Just Entered: "<<a<<endl; if(!(cin>>a)) { cout<<"Exiting"<<endl; break; } } } If I remove the if(!(cin>>a)) { condition and just write cout<<"You sir, Just Entered: "<<a<<endl;, it...

What's wrong with the following arithmetic operation? C++ [duplicate]

c++,codeblocks,long-integer,division
This question already has an answer here: What is the behavior of integer division in C? 5 answers I'm just trying to do a simple arithmetic operation but it returns me the 0 value. Here's the code: main(){ long Population_A, Population_B; cin>>Population_A; cin>>Population_B; float Increase_A, Increase_B; Increase_A = (6*Population_A)/100;...

SFML Networking Error: undefined references des when linking

c++,networking,codeblocks,sfml,mingw32
I recently started learning SFML, but when I got to the section of Networking, I always get a lot of errors: obj\Release\main.o:main.cpp:(.text$_ZN2sf11TcpListenerD1Ev[__ZN2sf11TcpListenerD1Ev]+0x1): undefined reference to `_imp___ZTVN2sf11TcpListenerE' obj\Release\main.o:main.cpp:(.text$_ZN2sf11TcpListenerD1Ev[__ZN2sf11TcpListenerD1Ev]+0xb): undefined reference to `_imp___ZN2sf6SocketD2Ev' obj\Release\main.o:main.cpp:(.text$_ZN2sf9TcpSocketD1Ev[__ZN2sf9TcpSocketD1Ev]+0x1): undefined reference to `_imp___ZTVN2sf9TcpSocketE'...