code blocks failed message runing hello code - parallel-processing

I'm trying to run this code and im a beginner at this im really struggling I don't know what to do.
NB: A "MinGW" version of Code::Blocks was used here.
#include <stdio.h>
#include <omp.h>
int main() {
printf ("Hello, world:");
#pragma omp parallel
printf (" %d", omp_get_thread_num ());
printf ("\n");
return 0;
}

Change a debugger setting in the following way.
From the Settings menu click on Debugger..., then on the left of the screen select Default, a debugger type. This should show Executable paths set to:
C:\MinGW\bin\gdb.exe
change this to:
C:\Program Files\Codeblocks\MinGW\bin\gdb.exe
You should then be able to use the debugger.
NB: Other Information
The above type of fix is required if you install the "MinGW" version of 'Code::Blocks 20.03' on Windows, using 'codeblocks-20.03mingw-setup.exe' ( the version relevant on 8th April 2021 , with the default installation type used ).

Related

Prevent visual C++ from closing automatically

I have a new project where I created a HelloWorld.cpp Source file.
But when I am running it in Start without dedugging mode (CTRL+ F5), it opens the console and closes automatically.
#include <iostream>
#include<stdlib.h>
#ifdef _WIN32
#define WINPAUSE system("pause")
#endif
using namespace std;
void main()
{
cout << "Hello, World!" ;
}
Mr. Patel, did you try using the second solution on that linked question and then tried to use the run without debugging option? The Visual Studio will only keep the command prompt open if you set the subsystem option in the linker to console. If it is not set, the window will close as soon as the program finishes running.
At any rate, note that this will only work if you run your program from inside Visual Studio, running your .exe directly will still have it close as soon as possible. If you want your program to wait on the user, you would need to do it yourself (at least as far as I know). A very simple solution would be to write your main function like this:
int main (int argc, char* argv[]) {
...//Your code goes here.
std::cout << "Enter any character to end the program.\n";
char end;
std::cin >> end;
return(0);
}
Note that to use the cin and cout streams, you should include the iostream header in your code.

libssh/libssh.h not found on Windows 10 using gcc

I'm trying to use libssh on Windows 10 with gcc. The work is being done from the command line.
I don't know how to make libssh/ part of the search path.
The #include was libssh/libssh.h, but that failed. (The brackets were left out of this sentence.)
#include <libssh.h>
#include <stdlib.h>
int main()
{
ssh_session my_ssh_session = ssh_new();
if (my_ssh_session == NULL)
exit(-1);
...
ssh_free(my_ssh_session);
}
When I modify the include statement to be just libssh.h and use the following on the command line:
gcc -IC:\libssh\include\libssh ssh.c -oout.exe
That works to get past the libssh.h file not found.
But, the other files that are called, such as libssh/legacy.h are not found.
How do I get the libssh to be part of the search path?
I added c:\libssh\include\libssh to the environment path. That didn't work.
You need to let #include <libssh/libssh.h>
because libssh.h call a header legacy.h which is also located in the libssh folder so if you put directly the header libssh.h it won't be able to locate legacy.h
#include <libssh/libssh.h>
#include <stdlib.h>
int main()
{
ssh_session my_ssh_session = ssh_new();
if (my_ssh_session == NULL)
exit(-1);
// remove the dots it'll create an error
ssh_free(my_ssh_session);
}
to have libssh a part of the path you should do
gcc -I/path/to/libssh/include/directory -L/path/to/libssh/lib/directory -lssh ssh.c oout.exe
I also got stuck into that, now I face another issue, the one to link the libssh.dll or ssh.dll inside the compiled code to use it as stand-alone.

How do I configure CLion standard console output?

Problem:
CLion doesn't output any console output for debugging purposes.
I'm using CLion with the MingW compiler and cmake. No matter whether I use:
std::cout << "Testing" << std::endl;
Or:
printf("Testing");
I don't see any console output.
Attempts at Resolution:
1:
I've checked "Run", "Debug", "Terminal" and "Cmake". I've attempted to edit my configurations but "Debug" doesn't show up.
2:
Next, I went to Settings->Build,Execution,Deployment->CMake to edit the Generation types. I added Debug and RelWithDebInfo and still to no avail.
3:
I also attempted to add "-Debug" to Cmake, but I still have no output.
4:
The closest thing I've received for debugging is using GDB to view variable values at break points. This only works in the "RelWithDebInfo" generation.
Solution:
I ended up figuring out what the problem was.
I'm developing a Qt GUI application within CLion on Windows. You have to specify a console for console output to print onto.
Call this Console() function early in your main for a console prompt to open up. Now, whenever you run
QDebug() << <string>;
or
std::cout << <string> std::endl;
You'll see your debugging statements. Hope this helps somebody else out there with the same problem.
Code:
void Console()
{
AllocConsole();
FILE *pFileCon = NULL;
pFileCon = freopen("CONOUT$", "w", stdout);
COORD coordInfo;
coordInfo.X = 130;
coordInfo.Y = 9000;
SetConsoleScreenBufferSize(GetStdHandle(STD_OUTPUT_HANDLE), coordInfo);
SetConsoleMode(GetStdHandle(STD_OUTPUT_HANDLE),ENABLE_QUICK_EDIT_MODE| ENABLE_EXTENDED_FLAGS);
}
Source:
I found a solution here:
[0] Console output in a Qt GUI app?
There's a simpler solution that doesn't require adding any code. Simply add the following environment variable in your debug configuration:
QT_ASSUME_STDERR_HAS_CONSOLE=1
With this, CLion shows QDebug and QML's console.*() when started with a debugger.

RPi + NetBeans debugging and Hello World

Currently I work with RPi2 and remote connection to NetBeans 8.1 on my laptop.
I can write programs, run it, debug it and go step-by-step through the lines. This tutorial helps me to setup this: Installing NetBeans For C++ Remote Development on A Raspberry Pi
First test: I tried a simple "Hello World" program like this:
#include <stdio.h>
#include <stdlib.h>
void main(void)
{
int i = 0;
printf("Hallo World!\n");
i++;
printf("Hallo World!\n");
i++;
printf("Hallo World!\n");
i++;
printf("Hallo World!\n");
i++;
}
and debug it stepwise with NetBeans. Result: Variable i increments fine, but no printf output comes up! If I run the program without debugging, all works fine. I tried additional fflush and so on but nothing works.
What way can I do to solve the problem?
OK, I found he answer by myself...
First: Disable buffering by
setbuf(stdout, NULL); // disable buffering on stdout
Next: Setup the project by: Right Click on the project name > Properties > Categories = "Run" and here Console type = "Standard output".
This works for me with stepwise debug every printf line-per-line.
Mike.F.

How to run Jruby 1.6.6 on Aptana Studio 3.0.8 *ON WINDOWS*

I have read the launching Jruby from Aptana Studio 3 on Windows XP thread (to be fair, I am on windows 7) and created the wrapper script ruby.bat (#C:\jruby-1.6.6\bin\jruby %* - MY particular path)
Tried naming it "just" ruby, ruby.sh whatever, but Aptana wont find it. From any windows shell (cmd) it works without a hitch.
Also tried copying the JRuby.exe to Ruby.exe. That still won't work. Linking ruby.exe to jruby.exe with the mklink command still wont work.
Looked around the internet, but all I found are dead ends.
Any fix to this? Can't be THAT rare a setup, THAT difficult, or can it?
I did that by a simple trick...
I created a c++ file ruby.cpp:
#include <cstdlib>
#include <iostream>
using namespace std ;
int main( int argc, char *argv[] ) {
string cmd = "jruby.exe" ;
for (int i = 1 ; i < argc ; ++i)
cmd.append( " " ).append( argv[i] ) ;
return system( cmd.c_str() ) ;
}
Compiled as ruby.exe and moved to C:\jruby-1.6.6\bin.
It works...

Resources