Suppress popup console in apps created using Code::Blocks IDE - codeblocks

I am using Code::Blocks version 13.12 with the GNU GCC Compiler. I recently installed and started using these tools on Windows 7. Although I do not believe language is a contributing factor, I use this environment to create both C and C++ applications.
After getting a clean build for either a debug or release target executable, and click on either the green "Run" or the red "Debug/Run" toolbar button, I see a console popup flicker (appear, then close) even for code that writes nothing to stdout. For example...
int main(void)
{
int a = 1;
return 0;
}
...produces a console popup.
Can anyone describe how to set the Code::Blocks IDE to suppress the console popup?
Note: I have reviewed answers related to this question here and here. These posts are related in that one is closed as a duplicate of the other, but answers for neither address this question. (i.e. Because my systems do not use Avast, Avast is completely unrelated to the issue)

You can change the settings in Code::Blocks to run as a GUI application. This will tell it to compile as such and it will not produce a console window on startup. And this is how you do so:
1. Click Project on the CodeBlocks menu.
2. Click Properties.
3. Click the second tab, Build Targets.
4. On the right, where it says Type: Console application, change it to GUI application.
5. Rebuild the project.
This is where the information was gather if you have further questions: How to get ride of console box of a GUI program compile by MinGW + Code::Block

Related

Viewing cout Output From CLion C++ file

I recently downloaded CLion to use with C++ and it's working fine, I just wanted to know if/how I could view std::cout. If not in the CLion output console, then maybe in a separate terminal window using the CMakeLists.txt file? Again, my code is building fine, I just want to know how/if I can view the output (similar to what I'd be able to do in Eclipse, XCode, or even Sublime).
You'll see it in the "run" tab, not the "terminal" tab
From the dropdown box at the top, make sure you have the correct target selected and hit the play button.

GNAT GPS Debugger - Could not initialize the debugger

I am attempting to debug my project in GNAT's GPS IDE. Every time I chose Debug->Initialize->"program name" the gui of GPS switches to that of the debug GUI, and then an error pops up with "could not initialize the debugger".
The two possible solutions I have found are that gdb.exe may be out of date and it suggests running it outside of GPS, which it does run fine. The other possible solution is to make sure the -g tags are applied when building the project, as those are necessary for gnatlink and gcc for debugging. It also states that the -g tag is applied to a new project by default, unless you have specifically removed it. I doubt I have, but I am not sure where I would check that to make sure it is still included.
The other odd thing is that the tutorial that comes with GPS that runs through how to build and debug your code works perfectly fine when I initialize debugging on it. That tutorial I am referring to can be accessed through Help->GPS->GNAT Programming Studio Tutorial. It references the program 'sdc' which comes in the GNAT/2012/share/examples/gps/tutorial directory.
Any ideas on what I am doing incorrectly, since the error isnt very helpful?
Thanks!
At first it sorta sounds like a path problem, but if you're able to run a debugger tutorial that's probably not the case.
The behavior you're seeing if the program isn't compiled with the debug (-g) flag doesn't quite match my experience, but let's go ahead and check/set the debug flag anyway.
Select Project/Edit Project_Properties
Click the Switches tab.
Click the Gnatmake tab.
Check "Debug information". Note that a -g now shows up in the text box at the bottom of the tab page. Click OK on the dialog.
Recompile your code so that it uses the changed option. Select Build/Clean/Clean All, and OK any dialog that pops up.
Then do your build (you can just press F4).

Debugging with unity

At the current moment, what I'm doing is that I'm opening Unity, double click on one of those scripts I've written, then MonoDevelop gets opened, now I have to close unity and in MonoDevelop I do Run >> Run with >> Unity Debugger.
After this Unity gets opened and when I press the play button in unity the debugging session starts. But once only. If I stop this session in either Unity or MonoDevelop I have to repeat this whole procedure all over again, which is very tedious. I have to open Unity, close Unity, (I have to close it because next step which is Run >> Run with >> Unity Debugger will open unity and if unity is already opened I'm getting error saying that only one instance of unity can open one project at a time).
What I'm asking is:
Is there any better workflow which would free me from this tedious switching on and off Unity, and every time I stop debugging session I would just start normally without doing these tedious repetitions?
Use 'Attach' in MonoDevelop's debug menu; you should be able to attach to the running Unity process that way. (You may need to ensure that the appropriate option is turned on in Unity's preferences).
Another way to debug is by using the:
Debug.LogError("foo");
or
Debug.LogWarning("foo");
Another note is that you can actually bind objects to the Log. This will cause the editor to highlight the object is question in the event you are iterating over a list of GameObjects. i.e.:
Debug.LogWarning("this object broke", gameObject);
If you turn on "Error Pause" in the console window, the game will automatically pause when the LogError is met. But be warned, it will pause whenever an error is thrown.
I've always changed the default script editor (unity preferences -> external tools -> external script editor) to visual studio. This lets you use breakpoints and preprocessor macros to make debugging much easier. When you want to start debugging press f5 in visual studio to connect it to unity then play like normal and if a breakpoint is hit visual studio takes over.
You don't have to change anything else and you won't have to keep opening and closing things like you are now.
UnityVS is now officially part of Microsoft and is available as an add-on for vs 2010,12 and 13. Here's the MSDN blogpost linking to the various versions: http://blogs.msdn.com/b/visualstudio/archive/2014/07/29/visual-studio-tools-for-unity-1-9.aspx
Do you know about the Unity "Console" window? You should be able to open it from Menu/Windows/Console. It will act as a debugger giving you errors and warnings both while pre-compiled and at runtime. If I misunderstood the question, let me know.
Recently, Microsoft Acquired SyntaxTree, the creator of UnityVS plugin for Visual Studio, so it is going to get released for free very soon. UnityVS is a must-have plugin for every Unity3D developer, due to it's productivity and the ability or debugging of Unity3D games in Visual Studio.
http://unityvs.com/
In MonoDevelop, there's a button near the top of the window that says "attach to unity". If you do this before you play your scene, any breakpoints set in MonoDevelop will halt the main thread there.
If you're just trying to inspect values, Debug.log(message) prints data directly to unity console.
Both of these can be used while in regular play mode.
Easiest way to debug is using Debug.log("");
but this does cost you your performance so how can you debug easier?
well here is the answer:
To start debugging, press your mouse to the far left edge of the editor (next to the line number) and a red dot will appear, you would have just created a breakpoint!
This will not do anything for now, however, if you now go to Unity and press play in your editor window something great will happen…
At the very bottom of the window, if you have the locals window open (if not, Go to View > Debug Windows > Locals), you will see all of the variables that currently exist in the local instance and their values at the time of the breakpoint being hit.
To continue the applications execution, just press the “Play” button in MonoDevelop.
Your script will continue its execution (and Unity’s editor will no longer be frozen). Of course in this instance, the script will hit the breakpoint again on the next frame. So just left click the breakpoint in MonoDevelop and hit the Play button again so it doesn’t execute the breakpoint again.
You can do more things with it for example:
With breakpoints, you can make them stop the application running when certain conditions are met. For example, imagine you want to check what the values are when the fSpeed variable reaches 10. To do that, press the Stop button in MonoDevelop, and Right click on your breakpoint, then press Breakpoint Properties.
Set the condition to “Break when condition is true” and set the “Condition Expression” to “fSpeed >= 10” and then press OK.
Re-attach the editor to Unity and press the Play button in Unity, when the condition is met the breakpoint will fire and stop the application.
A note about using Condition Breakpoints: They cause performance issues as it has to validate the expression each time it is run.
this should in general be better then debug.log(""); atleast if this is what you desire.
The best way using Debug.Log() for debugging in Unity if your problem is suitable to apply this.
I'm using the plugins UnityVS, which can debug Unity projects with Visual Studio.
Very convinient.
Have a google with UnityVS
You could check out using MS Visual Studio Community and getting the Unity integration they also provide on their website. I recently tried it and it's great, you get pretty much full debugging functionality using one of the best IDE available. Paired with Unity you can get some nice productivity boosts, not just in terms of debugging capabilities, but also in terms of feature set.
In case you want to check it out, here is a link to the Community version of the IDE: https://www.visualstudio.com/en-us/products/visual-studio-community-vs.aspx
Here is also a link to the Unity integraiton I mentioned: https://www.visualstudio.com/features/unitytools-vs
Hope it helps, a fellow developer converted me from Mono and honestly I couldn't be any happier with that setup (unless some IDE integrates the "make it work" button once and for all ;) ).
With Unity 5.5 visual studio tools are built in, you can attach unity and start debugging with a single click
i.e after Edit > Preferences > External tools > External script editor > Visual studio
There are two ways of debbuging in unity once is by Log which is console basically within Unity and the other is Debugger which is VS and Mono both supporting .
Yes you are right its very awfull process to check by debug point tha what is the value of a and b etc
so here is my opinion that use only what is best suiteable for you i mean you do not need of debugging point for just know the value of a and b just log it.
and when there is need for debugging point you already know the method.
You can use the Run button (looks like a play button in the top left) to connect to the Unity Editor for debugging, but if you're not connecting to Unity successfully this way, you may want to check that the appropriate plugin is enabled in your Add-in Manager preferences.
Windows:
Tools > Add-in Manager > Unity > Mono Soft Debugger Support for Unity
OSX:
Unity > Add-in Manager > Unity > Mono Soft Debugger Support for Unity
(Select and click enable.)
use debug.log("Message"); for debugging
Something I like to do too is making shortcuts for logging useful data within the Unity Editor. For example logging the current state of all my active achievements.
[MenuItem("My Game/Runtime debug/Achievement states")]
public static void LogAchievementStates ()
{
foreach (AchievementState achievementState in Data.achievementStates)
{
Debug.Log ("Achievement " + achievementState.name + " is at " + achievementState.completion + "%");
}
}
Doing this within an editor script will display a menu button to run certain actions.
I think that what the question is after, is a way to launch a "unity built game executable" and attach the debugger to it.
Something like...
creating debugging symbols with gcc, building the application with DEBUG enabled and launching the executable program with gdb to debug it. That way you can launch debugging sessions without using an IDE. But that's in C using gcc... in C# there is no need for debugging symbols for the attached debugger to see the code and it runs over a virtual machine.
There is an open conversation about how this can be done here:
https://github.com/0xd4d/dnSpy/issues/393
Some quick notes for someone not versed in virtual machine languages. C# produces an intermediate language when compiled. Contrary to C for instance that produces machine code, executed directly by the CPU. In the case of C# this intermediate language is call Common Language (because it is common for all .NET languages like VB.NET, C#.NET and C++.NET. This intermediate language is not executed by the CPU directly but by a virtual machine instantiated once per application or process, which is called the CLR (Common Language Runtime). This means that most of the time, if the variables and methods are not replaced by gibberish (which is called obfuscating), the program can be read directly by a debugger attached to the executable.
According to the conversation, the unity engine does not use the .NET CLR but a separate (potentially modified) CLR embedded to the engine. They do describe ways to do that but, I think its safer and easier to use the Unity Editor.
Unity is built around the editor anyway! For instance, within the editor context, you can change public variables and references while playing the game, which is not a "classic" programming approach. But it is a classic debugging approach.
Lastly, there are stuff like the threads of the program that are not open sourced, so I doubt that any external tool would be able to find its way around the code. Even if, it is pure Common Language, which I seriously doubt because if it was pure CL there would be no need for a separate (potentially customized) CLR to be including in the engine.
The whole misunderstanding in my opinion, is caused by the fact that the language that Unity is using, is not exactly C#, but a unity-variant that looks like C# and it may be compatible with C# but I do not know to what degree. So, the "CLR" you are programming in Unity is actually the unity engine itself. A "CLR" focused on rendering games in many platforms and not the classic C# CLR.
About the other answers:
- MonoDevelop lets you use breakpoints and preprocessor macros just as well as any other IDE.
- As for the text debugging using the log. Of course its possible but this is what one does when "real debugging" is not available.
tried visual studio? there you can attach the scripts to unity and debug them.
First you have to attach the C# code present in monodevelop or visual studio to the Unity debugger, than press the play button in the IDE monodevelop and than in last play it on unity.
You can just put some print() or something idono
Just try to open the C# scripts with Visual Studio you want to debug Use Visual Studio 2017 for this purpose and just start the project with debugger and apply breakpoints on your desired location and run the project . I think it will solve you issue and debug the desired piece of code
Unity documentation -- Debugging C# code in Unity provides the complete methods to debug the C# code in the editor and in the player.

Why can't I debug into my C++ code on Xcode 4?

My Xcode 4 project has been working well, but from someday I can't debug into my C++ codes in a cpp file.
When I set a break point at a certain location in the C++ code, the process stops where I want to stop, and I can control the process with 'step over' or 'continue' buttons.
However, the debugger does not show any highlights on the location and I cannot access any information. In the left pane, the navigator of Xcode 4, some threads numbers are shown, but they are useless.
A message appears in the console output window :
"Warning: the current language does not match this frame"
or
"Current language: auto; currently c++ "
Debugging on Objective C/C++ code works well, though.
What should I do to debug into my C++ codes ???
Did you try reinstalling the files? Debugging c++ code on XCode 4.0 works fine for me...

Edit and Continue: "Changes are not allowed when..."

Even if I create a clean WinForms project, Edit and Continue doesn't work and gives me the error:
Changes are not allowed when the debugger has been attached to an already running process or the code being debugged was optimized at build or run time.
Edit and Continue option is checked in Tools → Options → Debugging.
Optimization is not enabled.
Seems like there is no any managed profiler set up.
I am running in Debug mode
I am running on x64 CPU and Windows XP 32-bit, but setting platform target to x86 rather than AnyCpu doesn't help.
Repairing Visual Studio installation doesn't help.
I also found this article on MSDN website:
Unsupported Scenarios
Edit and Continue is not available in the following debugging scenarios:
Debugging on Windows 98.
Mixed-mode (native/managed) debugging.
SQL debugging.
Debugging a Dr. Watson dump.
Editing code after an unhandled exception, when the "Unwind the call stack on unhandled exceptions" option is not selected.
Debugging an embedded runtime application.
Debugging an application with Attach to rather than running the application with Start from the Debug menu.
Debugging optimized code.
Debugging managed code when the target is a 64-bit application. If you want to use Edit and Continue, you must set the target to x86. (Project Properties, Compile tab, Advanced Compiler setting.).
Debugging an old version of your code after a new version failed to build due to build errors.
But I can answer "No" to every item in this list.
It worked before, but several days ago it stopped working, and I don't know what could be the reason.
Other Applicable Solutions:
Below is an incomplete, unordered list of possible solutions to try if you* are trying to fix Edit & Continue quickly.
Make sure you are in Debug Mode
Make sure you're not launching a mixed mode process
Try to set the CPU target to x86 rather than AnyCPU (on x64 machines)
Uncheck the Optimize Code checkbox for Debug Mode in Project Properties->Debug
Uncheck the Optimize Code checkbox in Project Properties->Build
Uncheck Enable Optimizations in Advanced Compiler Settings
(ASP.NET) Check nightcoder's answer if it is the case
(ASP.NET) Check this answer (by matrixugly) if it is the case
(ASP.NET) Ensure you have Edit and Continue enabled on the Web tab (vs2010)
(ASP.NET) Go to Properties > Web > Servers, and make sure that Enable and continue is checked under Use Visual Studio Development Server.
(ASP.NET WebAPI) Make sure you've stopped in the Controller's method using a breakpoint, before trying to edit it.
(vs2017) Go to Tools > Options > Debugging and uncheck (deselect) 'Edit and Continue'. This is actually the opposite of the 'conventional' advice (see some other points in this post). It does not allow you to actually make changes in your running program (i.e. it does not hot-swap the code changes that you make) - it simply allows you to edit your code (i.e. it prevents that annoying message and "locking" your editor).
Go to Tools > Options > Debugging > General and make sure Require source files to exactly match the original version is unchecked.
Check Enable Windows debug heap allocator (Native only) [VS Community 2017]
Are you using Microsoft Fakes? It inhibits Edit & Continue.
Kill all the *.vshost.exe instances by selecting End Process Tree in the Task Manager. VS will regenerate a correct instance.
Remove all the breakpoints with Debug->Delete All Breakpoints
Enable and Continue exists in both the Tools > Options > Debugging menu and also in the Project Settings. Be sure to check both places. edit & Continue is not supported with the extended Intellitrace setting.
Be sure Debug Info in Project Properties > Build > Advanced > Output > Debug Info is set to Full
Some plugin may be interfering. Check by disabling/uninstalling and then trying again the other solutions.
If you're not paying enough attention, the error you get while trying to fix this may change to something else that is easier to diagnose. E.g. A method containing a lambda expression cannot support edit and continue.
Make sure the System variable COR_ENABLE_PROFILING is not set to 1. Some profilers set this when installing and leave it like that after uninstalling. Open a command prompt and type set to quickly check it your system is affected, if so remove the variable or set it to 0:
In Windows 8 and above, search for System (Control Panel).
Click the Advanced system settings link.
Click Environment Variables.
Remove COR_ENABLE_PROFILING
Be aware of unsupported scenarios (as reported in the question) and that unsupported edits.
* by 'you', I mean the visitor of the page who is hammering his head on a keyboard to find The solution.
Feel free to edit this answer to add your workaround if not listed here!
If you're debugging an ASP.NET application, go to properties > web > Servers, and make sure that "enable and continue" is checked under Use Visual Studio Development Server.
I finally got to solve the problem: UNINSTALL Gallio
Gallio seems to have quite some many rough edges and it's better to not use MbUnit 3.0 but use the MbUnit 2.0 framework but use the gallio runner, that you are running without installing from the installer (which also installed a visual studio plugin).
Incidentally, I had the issue even after "disabling" he Gallio plugin. Only the uninstall solved the problem.
PS. Edited by nightcoder:
In my case disabling TypeMock Isolator (mocking framework) finally helped! Edit & Continue now works!!!
Here is the answer from TypeMock support:
After looking further into the edit
and continue issue, and conversing
about it with Microsoft, we reached
the conclusion it cannot be resolved
for Isolator. Isolator implements a
CLR profiler, and according to our
research, once a CLR profiler is
enabled and attached, edit and
continue is automatically disabled.
I'm sorry to say this is no longer
considered a bug, but rather a
limitation of Isolator.
I had the same problem. I even re-installed VS 2008 but the problem did not go away. However, when I deleted all the break points then it started to work.
Debug->Delete All Breakpoints
I think it was happening because I had deleted an aspx page that had break points in its code, and then I created another page with the same name. This probably confused the VS 2008.
"Edit and Continue", when enabled, will only allow you to edit code when it is in break-mode: e.g. by having the execution paused by an exception or by hitting a breakpoint.
This implies you can't edit the code when the execution isn't paused! When it comes to debugging (ASP.NET) web projects, this is very unintuitive, as you would often want to make changes between requests. At this time, the code your (probably) debugging isn't running, but it isn't paused either!
To solve this, you can click "Break all" (or press Ctrl+Alt+Break). Alternatively, set a breakpoint somewhere (e.g. in your Page_Load event), then reload the page so the execution pauses when it hits the breakpoint, and now you can edit code. Even code in .cs files.
Couple of things to check
Make sure your compile is set to Debug vs. Release
Make sure you're not launching a mixed mode process
If on a 64 bit machine Make sure to set the CPU target to x86 rather than AnyCPU
EDIT
I don't believe this should matter but make sure that the hosting process is enabled for the target platform. Probably won't help.
If it repros for new projects then it might be something even more subtle. I would try the following.
Backup HKCU:\Software\Wow6432Node\VisualStudio\9.0 (maybe just rename it)
Delete the same key
Try the repro again
None of the above solutions worked for me(running on a 64x machine).
Finally I clicked on 'advanced compiler settings' and UNCHECKED 'enable optimizations' and I can now step through code and edit while debugging.
For me, for a reason that I don't understand, the setting "Generate debug info" in the "Advanced Compiler Settings" was set to "pdb-only" instead of "Full".
By default, this parameter is always set to "Full" but a mysterious poltergeist has changed this parameter on last night. :)
P.S. I'm in Visual Basic .Net with Visual Studio 2010
If your concern is with an ASP.NET app, ensure you have edit and continue enabled on the web tab (vs2010). There was also a separate setting for ASP.NET debugging in earlier versions.
Regards,
Adam.
I found that even though under project properties build & debug tab are set to Debug and all the other setting are correct I still get the message, however after digging some more
under the Build menu select Configurations Manager... and make sure Debug is selected in two places there as well. go figure...how many different places do they need to set debug?????? even though you set Project - Configuration to Debug then under Build - Manager it is not changed so you have change the same setting there as well Project Configuration - seems like a microsoft issue again.......
This problem is due to Intellitrace setting
If Intellitrace is enabled make sure Intellitrace event only is checked
Otherwise this will not allow edit and continue..
If you will click on Intellitrace options you will see the warnings.
Following shooting helped me using VS2010:
go to Tools, Options, Debugging, General and make sure "Require source files to exactly match the original version" is unchecked.
That happens when the debugger hasn't hit a breakpoint or you haven't hit Break All (pause). It couldn't be that simple could it?
The error says a possible cause is: "the code being debugged was optimized at build or run time". Go to Project Properties->Debug and uncheck the Optimize Code box for Debug mode.
I had this problem in Microsoft Visual Studio 2008 and the solution is easy. when you run your project please set in "Debug" mode not "Release". The another people solution can be useful.
If I create a new project, edits while debugging do not work. If I create a new website, edits while debugging work as expected.
I ran into this today - turns out that having Debug Info set to pdb-only (or none, I'd imagine) will prevent Edit and Continue from working.
Make sure your Debug Info is set to "full" first!
Project Properties > Build > Advanced > Output > Debug Info
In my case just reseting to default debugger settings and setting IntelliTrace-> only intellytrace events helps
Some things that seemed to help using VS2010:
go to Tools, Options, Debugging, General and make sure "Require source files to exactly match the original version" is unchecked.
multiple .vshost.exe instances can be left over from e.g. detaching the VS debugger from a stopped process. This will interfere with breakpoints and compiles as well. Use Task Manager, Processes tab to kill all instances of .vshost.exe by right-clicking each instance and selecting End Process Tree. VS will create a new instance.
I removed a dataset from my project because I didn't use it. After that I could modify the program when debugging.
I did all the changes mentioned in every other answer and none worked. What did I learn? Enable and Continue exists in both the Tools > Options > Debugging menu and also in the Project settings. After I checked both, Enable and Continue worked for me.
Seems illogic, but only way was disabling edit and continue from VS 2017 options... Then AspNet edit and continue began to work...
what worked for me was unchecking "Use Managed Compatibility Mode" under
Tools -> Options -> Debugging
TBN: checking or unchecking "Require source file to exactly match the original version" seems not influences the E&C
Hope this can help.
Enable edit and Continue only work run IIS Express.
Don't work in Local ISS or External Host.
I'm adding my answer because the thing that solved it for me isn't clearly mentioned yet. Actually what helped me was this article:
http://www.rubencanton.com/blog/2012/02/how-to-fix-error-changes-are-not-allowed-while-code-is-running-in-net.html
and here is a short description of the solution:
Stop running your app.
Go to Tools > Options > Debugging > Edit and Continue
Disable “Enable Edit and Continue”
Note how counter-intuitive this is: I had to disable (uncheck) "Enable Edit and Continue".
This will then allow you to change code in your editor without getting that message "Changes are not allowed while code is running".
Note however that the code changes you make will NOT be reflected in your running program - for that you need to stop and restart your program (off the top of my head I think that template/ASPX changes do get reflected, but not VB/C# changes, i.e. "code behind" code).
I install the stackify, when i enable this on icon tray, it stop my debugging with edit, so i found
Close the visual studio , in my case its vs2017
Go to icon tray and right click on stackify icon and disable .NET Profiler
Open Visual studio run application again in debug mode with debugger and it allow me edit while debugging
I had this annoying issue since I upgraded my VS 2019 to 16.4.3 and caused me a lot of headache.
Finally I solved the problem this way:
1. Stop Debugging
2. Select the solution from "Solution Explorer"
3. In the Properties window change the "Active config" Property From "Release|Any CPU" To "Debug|Any CPU"
4. In Debug > Options > General Check the Edit and Continue checkbox
That worked for me, and hope it works for you too.
embed interop types visual studio should be set to false
I had this happen in a linked class file. The rest of the project allowed E&C, but I got the same error editing the linked file. Solution was to break linked file into it's own project and reference the project.
I faced the same problem. My problem was that I could modify a file, but not another (both are in same project). Later I found that the file I couldn't modify was also part of another project. That another project (Unit Test) wasn't loaded, and intelligent VS debugger shows the error that assembly for this given file was not loaded, and changes aren't allowed. How weird!
Hence, I had to unload the unit-test project and continue the EnC debugging.

Resources