2

I'm a beginner in C++ and I started an Udemy course. In that course they recommend using CodeLite as IDE, so I decided to give it a try. In the course, they write a basic program that displays "Hello world!" to show how the IDE works. They compile then execute it, and a terminal window opens with the "Hello world!" message like normal. In my case, after following the setup process step by step and using the exact same code as them, when I compile and execute the code, my terminal flashes for a split second and then disappears. In their video the terminal remains open but I thought that since they have an older version of CodeLite maybe in the newer one that I have, the terminal is supposed to close by default.

I went online and found people saying that a way of keeping the terminal open is by adding #include and system("pause"); on Windows, but in my case the terminal keeps behaving the same, and CodeLite doesn't report any problems. I've also tried cin.get(); with no success.

Any idea what could be causing this problem?

Daniel Bortan
  • 21
  • 1
  • 2

15 Answers15

2

I had the same problem and I did these steps to solve the problem:

  1. Uninstalled CodeLite.
  2. Installed MinGW correctly.
  3. Then reinstalled CodeLite.
  4. Then did tutorial steps: Click Scan then select MinGW.

After I did these steps, it worked normally.

DFireworks
  • 21
  • 6
1

I had the same problem running Codelite on OpenSuse Leap 15.1. I eventually found a very simple answer. Go to the Settings menu, select Preferences and then Terminal, on the left towards the bottom. Change it to konsole to use the standard terminal, rather than the codelite-terminal.

bob
  • 11
  • 2
1

I know this is an old question, but did not see the answer that worked for me. Debugging (F5) will close the terminal after completion. However, running/executing (CTRL+F5) will not. Leaves terminal open. At least this is the case for me, and hopefully this helps someone out.

Dan Priest
  • 111
  • 4
1

I know this is an old question, but CodeLite has a Project-level setting for "pause when execution ends" which will pause the program before the terminal closes so that you can see outputs and the like.

To turn on just right click on your project, go to settings, and it should be in the center of the general tab.

Kyle
  • 11
  • 1
0

I went online and found people saying that a way of keeping the terminal open is by adding #include and system("pause");

And this is the wrong way to do it - the desire to leave the window open/closed is not meant to be controlled by your program; but the thing calling it. For example, you break the ability to run it as part of a headless script.

Much better would be to run it in debug and put a break point at the return of main, or to find the configuration option in your IDE that stops it closing the window.

UKMonkey
  • 6,941
  • 3
  • 21
  • 30
  • I'm just a beginner, so I have no idea what a headless script is or what debugging is, sorry. I tried searching online for what settings to change to make CodeLite keep the terminal open but all the results I found were from people saying to add lines of code like the ones I wrote above, not what setting to modify in the IDE. – Daniel Bortan Jun 10 '19 at 12:58
  • @DanielBortan consider a script that you want run when someone logs in... the last thing the sysadmin will want is for a message box asking the user to press a key because it's finished doing something; and then when the users presses a key it then does more stuff. They want the script to run, complete; and close. – UKMonkey Jun 10 '19 at 13:02
0

I am not aware why CodeLite would behave like that. If you really added some pause or blocking call and it still closes, it looks like it is not really running the program (e.g. something breaks before that or something is misconfigured).

First, try to open a terminal yourself (e.g. cmd or PowerShell on Windows), and execute your compiled program there -- that way, the terminal will remain open. If that works, then compilation went fine, but something is wrong with CodeLite's configuration, most likely.

Otherwise, as a last resort, since using CodeLite is not strictly required, simply switch to another IDE/toolchain, e.g. Visual Studio (on Windows).

Acorn
  • 24,970
  • 5
  • 40
  • 69
  • I've already used CodeBlocks and it works perfectly, I just wanted to try using CodeLite since it's the one used in that specific Udemy corse so it's easier to follow along, and because it looks a lot better than CodeBlocks in my opinion. When i double click the exe file, it opens a terminal with "Hello world!" in it that remains open, so the only problem seems to be CodeLite not wanting to keep the terminal open when I try to run the program directly from the IDE. – Daniel Bortan Jun 10 '19 at 12:55
  • @DanielBortan Then it looks like something is misconfigured, as if CodeLite cannot find the program to run, or something along those lines. Try checking the settings, or see if CodeLite writes a log somewhere -- that may hint at the actual error. It is also a good idea to ask in their support forums/emails/etc. to see if this is a known issue. – Acorn Jun 10 '19 at 12:57
0

For some reason, after closing and reopening CodeLite, it now works, the terminal remains open when I run it from the IDE. I don't know what solved the problem since I've closed and reopened CodeLite at least 5 times before this without anything happening. Thanks for the help though.

Daniel Bortan
  • 21
  • 1
  • 2
0

I had the same issue. What I found wrong was that the compiler that I installed was 32bit and I was using the 64bit CodeLite version . Try Installing the 32bit CodeLite version and it should work fine. It worked for me.

0

I had this problem also, I tried uninstalling and reinstalling code lite but the problem still occurred. I went back and checked the Environment Variables in control panel and I had placed the systems variables in "Path" to the incorrect Bin directory. I corrected the entry, uninstalled and reinstalled code lite again and the problem was resolved.

0

Hey I also had the same problem, doing the same course! What I did was to relocate my mingw-w64 folder, deleted the earlier path from environment variables and added the new path. I uninstalled CodeLite; not saving the user information. I actually downloaded the 14.0.0(64-bit) instead of the newer version 14.0.1(64 bit) . Then I did the steps that Frank tells you and it worked out for me.

Annie
  • 1
0

I am completing the same Udemy course and encountered a similar problem of the console closing immediately. I encountered the problem for a workspace with 1.) a long name and 2.) ending with an underscore "_". I reduced the size of the folder name which also involved deleting the trailing underscore. This appears to have solved the problem. I encountered this problem with one of Frank's provided workspaces so I knew it was not a compiler issue.

0

I had an issue with section 20 of my Udemy course because it had parenthesis in the workspace folder name. "(STL)" at the end. Once I got rid of the special characters, it worked fine.

Matt
  • 1
0

If pause("system"); or cin or restarting Program and whole PC solutions are not working, then make sure to:

  1. Copy your code.
  2. Create new Project and past your code there.
  3. Make sure the new project is selected before trying to double-click it.

Notes:

  • You can now delete the old not working project and rename your new project.
  • I don't know what's the reason of the problem, but I did that and it worked for me.
xKobalt
  • 1,498
  • 2
  • 13
  • 19
0

You need to make sure if it is 64bits CodeLite then you have installed 64bits MinGW. Through the IDE itself, you can re-run the setup wizard

paradocslover
  • 2,932
  • 3
  • 18
  • 44
-1

Restarting Codelite worked for me ...

Pravin Desai
  • 527
  • 5
  • 18