Code::Blocks failing to load a project? - c++

Each time I load Code::Blocks by double clicking my Code::Blocks project file it opens up Code::Blocks and the window blinks a bit once it loads, but then it's like it didn't load anything, it acts like I didn't open any project. It also does this if I do File -> Open. What should I do? I already tried to re-install it. Thanks in advanced!

It is the default behaviour of code blocks, when you double click your project file (.cbp) notice the title bar, if it shows the name of your project, it means project is open, and the blank window means that you haven't opened any files of the project yet, open them using file->open.

Related

Why I can not see project files in Dev-C++?

When I create a project in Dev-C++ 5.9.2 save it and open it's *.dev file there is no file below it in the project tree but I can compile and run it!
I am using 5.9.2 and even I create Empty Project there is unsaved file that after compilation ask you to save it.
So be sure you are looking into tree Project and no Classes or Debug.
If you are looking into Project there should be +
However if it runs with black window and you still don't see project files post a screenshot please

png files not visible in xcode + cocos2d

I am developing with cocos2d-iphone under Xcode. The problem seems to be a tool problem. Clicking on a file under the Project Navigator usually shows that file. If it is source code, you see the source text in the main pane. If it is an image file, if you click on the filename the image shows in the main pane.
At the moment, none of my images/png-files show up when I click on them. Yet they are clearly being loaded into the bundle and show up in the app when it is run.
Any ideas how to fix this?

eclipse won't run my exe file

I'm trying to build and run my C++ program in eclipse but it won't work. My program doesn't have a main function, but it does have WinMain and includes < windows.h >. I compile it into an executable and everything works fine, but when I click "run" nothing happens. When I drag the executable to my desktop and double click it it runs no problem. But I would like to be able to run it directly from eclipse.
I've done some research and already tried the following:
I made sure "PE Windows Parser" is checked in "Binary Parsers."
I made sure the working directory is where the executable is (workspace/projectname/Release).
I made sure MinGW is in the PATH (I couldn't find msys, but everything is compiling fine so I don't think this is the problem).
Any thoughts?
1.- Go to Menu Run -> Run Configurations
2.- Double click over C/C++ Application in the left subwindow.
3.- At right subwindow, press button Search_Project and check your binary executable.
4.- Press Run.
If you need to pass arguments to your program, go to Arguments tab.
For next runs, you can use the PLAY toolbar button or use CTRL+F11.
Change your compiler to Visual C++ instead of MinGW GCC. Just copy your code to separate files. Then, you simply create a new project using Visual C++ as your tool-chain. Then you simple paste the files into the directory, and then run it.

Read a file from current directory using ifstream and QtCreator

I'm using Qt Creator for a plain C++ project without the Qt libraries.
I'm trying to open a file like this:
fopen("text.txt", "r");
or
ifstream fin;
fin.open("text.txt");
But it doesn't work with just the filename like in Visual Studio, I have to pass the full path for it to open the file...
Anybody knows why is that? and how can I refer to the current directory without using Qt libs?
You can use QDir::current() to check wether the working directory is what you want it to be. Without Qt you can use the solution TomA linked to.
The run settings allow you to configure it for running the application from the IDE.
It will; your code is fine. But as other answers allude, you need to make sure you're running it in the directory you think you are.
On the left panel select "Projects" then (from the tabs at the top) "Run Settings" and it will show you where it runs the executable from in the field labeled "Working directory". I think by default it's the directory above the release and debug folders.
The difference between Visual Studio and Qt Creator may be that
Each starts the program binary in a different subdirectory of your project structure.
One does copy the text.txt file as part of your project to the same output directory as the binary, the other does not.
Try to get the current directory using this and then see if it actually contains the file.

How to change the default *.exe icon in C/C++?

I want to change the default .exe icon to some other icon in C/C++. Does anybody know how to do that?
Already answered.
Change app icon in Visual Studio 2005?
You have to place your .ico file in the resources folder first of course.
Use this one: http://www.angusj.com/resourcehacker/
Since you specified that you are using VS2008 I can point you here: How do I set the icon for my application in visual studio 2008? (duplicate question)
On Windows, if the executable contains many icons, the 1st of them will be the default.
If you have icons resource in your programming environment, place the icon you want first in the list.
Edit: since you created an empty project, to add an icon, follow these instructions:
(as I said in my comment, I don't have VS2008, but the steps should be the same)
Menu: Insert -> Resource -> Import
Select "Icon", press the import button and select your icon file.
Now, close the icon editor, and save the resource script in the project folder.
Select "Files View" and add the resource script file in the "Resource Files".
That's it.
if you are using any ide like dev c++, then you can specify the icon you want to appear on your file in project options