NetBeans 7.4 BUILD FAILED (exit value 2, total time: 38s) - netbeans

everyone. I am learning C++ and running basic "Hello, world!" codes.
I am using NetBeans with the minGW compiler.
The problem is every time I build or attempt to run the project, I get an error:
BUILD FAILED (exit value 2, total time: 38s)
"/C/msys/1.0/bin/make.exe" -f nbproject/Makefile-Debug.mk QMAKE= SUBPROJECTS= .build-conf
make.exe[1]: Entering directory `/c/Users/Namen/Documents/NetBeansProjects/CppApplication_1'
"/C/msys/1.0/bin/make.exe" -f nbproject/Makefile-Debug.mk dist/Debug/MinGW-Windows/cppapplication_1.exe
make.exe[2]: Entering directory `/c/Users/Namen/Documents/NetBeansProjects/CppApplication_1'
mkdir -p build/Debug/MinGW-Windows
0 [main] mkdir 5908 open_stackdumpfile: Dumping stack trace to mkdir.exe.stackdump
make.exe[2]: *** [build/Debug/MinGW-Windows/main.o] Error 5
make.exe[2]: Leaving directory `/c/Users/Namen/Documents/NetBeansProjects/CppApplication_1'
make.exe[1]: *** [.build-conf] Error 2
make.exe[1]: Leaving directory `/c/Users/Namen/Documents/NetBeansProjects/CppApplication_1'
make.exe": *** [.build-impl] Error 2
BUILD FAILED (exit value 2, total time: 38s)
What's odd is that I could keep clicking run, and sometimes the project will build and run successfully. Other times it will not...as if it's broken. It's actually not running at all now due to the error, however.
Apparently this is a common problem, yet I haven't been able to successfully use the solutions I've found.
I have the latest version of NetBeans as I've heard that this was a bug. v7.4
I believe I have the proper path in my environment variable: C:\MinGW\msys\1.0\bin\; C:\MinGW\bin
If it helps, this is my code:
#include <iostream>
#include <string>
using namespace std;
int main(){
string Question = "What is your name?\n";
cout << Question;
string Answer;
getline(cin, Answer + " : " + Answer);
cout << Answer + "\n";
}

The code is given us, not even compile.
to time variable Answer in the function is wrong.
getline(cin, Answer + " : " + Answer);
c++
1
istream& getline (istream& is, string& str, char delim);
2
istream& getline (istream& is, string& str);
to have the input in one line, let the new line characters away.
...
string Question = "What is your name? : ";
cout << Question;
string Answer;
getline(cin, Answer);
cout << Answer + "\n";
return 0;
...

Related

Bitbake do image failure

I have been successfully building an image for many days now. I add all of my custom files to GitLab. I have not knowingly made changes to my build environment. I am now getting errors can can not build my image. Can anyone understand what this error is telling me? I have tried looking it up but nothing seems to work.
Initialising tasks: 100% |##################################################################################################################################################################| Time: 0:00:06
Sstate summary: Wanted 5 Local 3 Network 0 Missed 2 Current 1114 (60% match, 99% complete)
NOTE: Executing Tasks
ERROR: evccapplication-1.0-r0 do_image: Error executing a python function in exec_python_func() autogenerated:
The stack trace of python calls that resulted in this exception/failure was:
File: 'exec_python_func() autogenerated', lineno: 2, function: <module>
0001:
*** 0002:do_image(d)
0003:
File: '/home/michael/Documents/evcc_custom/sources/poky/meta/classes/image.bbclass', lineno: 262, function: do_image
0258:
0259: d.setVarFlag('REPRODUCIBLE_TIMESTAMP_ROOTFS', 'export', '1')
0260: pre_process_cmds = d.getVar("IMAGE_PREPROCESS_COMMAND")
0261:
*** 0262: execute_pre_post_process(d, pre_process_cmds)
0263:}
0264:do_image[dirs] = "${TOPDIR}"
0265:addtask do_image after do_rootfs
0266:
File: '/home/michael/Documents/evcc_custom/sources/poky/meta/lib/oe/utils.py', lineno: 263, function: execute_pre_post_process
0259: for cmd in cmds.strip().split(';'):
0260: cmd = cmd.strip()
0261: if cmd != '':
0262: bb.note("Executing %s ..." % cmd)
*** 0263: bb.build.exec_func(cmd, d)
0264:
0265:# For each item in items, call the function 'target' with item as the first
0266:# argument, extraargs as the other arguments and handle any exceptions in the
0267:# parent thread
File: '/home/michael/Documents/evcc_custom/sources/poky/bitbake/lib/bb/build.py', lineno: 256, function: exec_func
0252: with bb.utils.fileslocked(lockfiles):
0253: if ispython:
0254: exec_func_python(func, d, runfile, cwd=adir)
0255: else:
*** 0256: exec_func_shell(func, d, runfile, cwd=adir)
0257:
0258: try:
0259: curcwd = os.getcwd()
0260: except:
File: '/home/michael/Documents/evcc_custom/sources/poky/bitbake/lib/bb/build.py', lineno: 503, function: exec_func_shell
0499: with open(fifopath, 'r+b', buffering=0) as fifo:
0500: try:
0501: bb.debug(2, "Executing shell function %s" % func)
0502: with open(os.devnull, 'r+') as stdin, logfile:
*** 0503: bb.process.run(cmd, shell=False, stdin=stdin, log=logfile, extrafiles=[(fifo,readfifo)])
0504: except bb.process.ExecutionError as exe:
0505: # Find the backtrace that the shell trap generated
0506: backtrace_marker_regex = re.compile(r"WARNING: Backtrace \(BB generated script\)")
0507: stdout_lines = (exe.stdout or "").split("\n")
File: '/home/michael/Documents/evcc_custom/sources/poky/bitbake/lib/bb/process.py', lineno: 186, function: run
0182:
0183: if pipe.returncode != 0:
0184: if log:
0185: # Don't duplicate the output in the exception if logging it
*** 0186: raise ExecutionError(cmd, pipe.returncode, None, None)
0187: raise ExecutionError(cmd, pipe.returncode, stdout, stderr)
0188: return stdout, stderr
Exception: bb.process.ExecutionError: Execution of '/home/michael/Documents/evcc_custom/build-fb/tmp/work/imx6ull14x14evk-poky-linux-gnueabi/evccapplication/1.0-r0/temp/run.prelink_image.131394' failed with exit code 2
ERROR: Logfile of failure stored in: /home/michael/Documents/evcc_custom/build-fb/tmp/work/imx6ull14x14evk-poky-linux-gnueabi/evccapplication/1.0-r0/temp/log.do_image.131394
ERROR: Task (/home/michael/Documents/evcc_custom/evcc_layers/meta-evccapplication/recipes-core/images/evccapplication.bb:do_image) failed with exit code '1'
NOTE: Tasks Summary: Attempted 3064 tasks of which 3063 didn't need to be rerun and 1 failed.
Summary: 1 task failed:
/home/michael/Documents/evcc_custom/evcc_layers/meta-evccapplication/recipes-core/images/evccapplication.bb:do_image
Summary: There were 2 WARNING messages shown.
Summary: There was 1 ERROR message shown, returning a non-zero exit code.
If you get an error similar to this delete your build folder. Then recreate it. For NXP devices they give you the command
DISTRO=fsl-imx-fb MACHINE=imx6ull14x14evk source imx-setup-release.sh -b build-fb
Save your local.conf and bblayers.bb file to git or to a new location.
Delete the build-fb folder and re-run the command above. Pull in any changes from git or files saved elsewhere.
Re-run bitbake. This got my workspace back. Because you are not deleting any of the downloads folders the build takes little time. All the time is spent compiling sources.

PF_RING 7.9.0 issue with deb package creation

I am trying to create deb packages for my work and have run into the following trouble.
The version of dkms being used as shown in the screen shot is 2.2.1.0. I have tried it out even with dkms 2.8.3 but I get the same error.
I am unsure what to do next or try next as I cannot understand.A little guidance is requested.
the exact issue that is being shown is the following. There is a Perl module named Dh_Lib.pm with a subroutine should_use_root() as shown below the error and the issue has been marked there.
Building binary package...dpkg-buildpackage: warning: using a gain-root-command while being root
dpkg-source --before-build .
fakeroot debian/rules clean
Initialization of state variables in list context currently forbidden at /usr/share/perl5/Debian/Debhelper/Dh_Lib.pm line 2021, near ");"
BEGIN not safe after errors--compilation aborted at /usr/share/perl5/Debian/Debhelper/Dh_Lib.pm line 2743.
Compilation failed in require at /usr/bin/dh_testdir line 11.
BEGIN failed--compilation aborted at /usr/bin/dh_testdir line 11.
make[1]: *** [debian/rules:25: clean] Error 2
dpkg-buildpackage: error: fakeroot debian/rules clean subprocess returned exit status 2
(bad exit status: 2)
Error! There was a problem creating your deb.
make: *** [Makefile.dkms:28: deb] Error 7
root#VEHERE:/home/vehere/Release/probe/deps/PF_RING-7.9.0/kernel#
# Return true if we should use root.
# - Takes an optional keyword; if passed, this will return true if the keyword is listed in R^3 (Rules-Requires-Root)
# - If the optional keyword is omitted or not present in R^3 and R^3 is not 'binary-targets', then returns false
# - Returns true otherwise (i.e. keyword is in R^3 or R^3 is 'binary-targets')
sub should_use_root {
my ($keyword) = #_;
my $rrr_env = $ENV{'DEB_RULES_REQUIRES_ROOT'} // 'binary-targets';
$rrr_env =~ s/^\s++//;
$rrr_env =~ s/\s++$//;
return 0 if $rrr_env eq 'no';
return 1 if $rrr_env eq 'binary-targets';
return 0 if not defined($keyword);
state %rrr = map { $_ => 1 } split(' ', $rrr_env); << ---- issues
return 1 if exists($rrr{$keyword});
return 0;
}
The version of perl being used is 5.24.1

C Program in Netbeans Compiles correctly but will not run

I wrote the following C program in Netbeans. It compiles correctly but won't run. When I copied the code into Codeblocks it worked perfectly.
//Demonstrates variables and constants
#include <stdio.h>
// Define a constant to convert a number of laps to miles
#define LAPS_PER_MILE 4
//Define a constant for the current year
const int CURRENT_YEAR = 2017;
//Declare the needed variables
float miles_covered;
int laps_run, year_of_birth, current_age;
int main (void)
{
// Input data from user
printf("How many laps did you run: ");
scanf("%d", &laps_run);
printf("Enter your year of birth: ");
scanf("%d", &year_of_birth);
// Perform Conversion
miles_covered = (float) laps_run/LAPS_PER_MILE;
current_age = CURRENT_YEAR - year_of_birth;
//Display results on screen
printf("\nYou ran %.2f miles.", miles_covered);
printf("\nNot bad for someone turning %d this year!\n", current_age);
}
Compile message:
cd 'C:\Users\User\OneDrive\Computer Science\Projects\Netbeans\Laps_to_miles'
C:\MinGW\msys\1.0\bin\make.exe -f Makefile CONF=Debug
"/C/MinGW/msys/1.0/bin/make.exe" -f nbproject/Makefile-Debug.mk QMAKE= SUBPROJECTS= .build-conf
make.exe[1]: Entering directory `/c/Users/User/OneDrive/Computer Science/Projects/Netbeans/Laps_to_miles'
"/C/MinGW/msys/1.0/bin/make.exe" -f nbproject/Makefile-Debug.mk dist/Debug/MinGW-Windows/laps_to_miles.exe
make.exe[2]: Entering directory `/c/Users/User/OneDrive/Computer Science/Projects/Netbeans/Laps_to_miles'
make.exe[2]: `dist/Debug/MinGW-Windows/laps_to_miles.exe' is up to date.
make.exe[2]: Leaving directory `/c/Users/User/OneDrive/Computer Science/Projects/Netbeans/Laps_to_miles'
make.exe[1]: Leaving directory `/c/Users/User/OneDrive/Computer Science/Projects/Netbeans/Laps_to_miles'
BUILD SUCCESSFUL (total time: 2s)
The code worked in codeblock. I just copied and pasted

"error: variable length array of non-POD element type" when compiling re::engine::RE2

I'm trying to install the re::engine::RE2 module with cpan.
When building, the compiler emits the error message:
re2_xs.cc:254:25: error: variable length array of non-POD element type
're2::StringPiece'
re2::StringPiece res[re->nparens + 1];
^
What does that mean? How can I fix that? I'm using a 2011 Macbook Air and Perl 5.12.
re::engine::RE2 was never successfully tested on darwin/Perl 5.12.
Googling for the error message suggests that this is a flaw in old clang that ships with Xcode, and not present in newer versions.
Upgrade your software, you're out of support, perhaps use Macports to get a fresh gcc.
True, re::engine::RE2 never compiled on OS X. But you can get it to compile. Locate the cpan directory. For me it is ~/.cpan/build/re-engine-RE2-0.13-BY20k3/. Then within there, you change two C++ source files.
$ diff -p re2_xs.cc.old re2_xs.cc
*** re2_xs.cc.old 2015-04-20 20:20:15.000000000 +0200
--- re2_xs.cc 2015-04-20 20:22:24.000000000 +0200
*************** RE2_exec(pTHX_ REGEXP * const rx, char *
*** 229,236 ****
RE2 * ri = (RE2*) SvANY(rx)->pprivate;
regexp * re = SvANY(rx);
- re2::StringPiece res[re->nparens + 1];
-
#ifdef RE2_DEBUG
Perl_warner(aTHX_ packWARN(WARN_MISC), "RE2: Matching '%s' (%p, %p) against '%s'", stringarg, strbeg, stringarg, RX_WRAPPED(rx));
#endif
--- 229,234 ----
*************** RE2_exec(pTHX_ REGEXP * const rx, char *
*** 241,246 ****
--- 239,246 ----
return 0;
}
+ re2::StringPiece *res = new re2::StringPiece[re->nparens + 1];
+
bool ok = ri->Match(
re2::StringPiece(strbeg, strend - strbeg),
stringarg - strbeg,
*************** RE2_exec(pTHX_ REGEXP * const rx, char *
*** 250,255 ****
--- 250,256 ----
/* Matching failed */
if (!ok) {
+ delete [] res;
return 0;
}
*************** RE2_exec(pTHX_ REGEXP * const rx, char *
*** 266,271 ****
--- 267,274 ----
}
}
+ delete [] res;
+
return 1;
}
Attempting to compile after that will get you to a tr1 issue.
/usr/bin/clang -o obj/util/arena.o -xc++ -O3 -DHAVE_PTHREAD -pthread -Wno-sign-compare -c -I. -DNDEBUG util/arena.cc
In file included from util/arena.cc:5:
./util/util.h:45:10: fatal error: 'tr1/unordered_set' file not found
I'm sure there are simpler -D fixes for the Makefile but I changed the code.
# diff -p re2/util/util.h.old re2/util/util.h
*** re2/util/util.h.old 2015-04-20 20:29:01.000000000 +0200
--- re2/util/util.h 2015-04-20 20:29:26.000000000 +0200
*************** using std::make_pair;
*** 42,49 ****
#if defined(__GNUC__) && !defined(USE_CXX0X)
! #include <tr1/unordered_set>
! using std::tr1::unordered_set;
#else
--- 42,51 ----
#if defined(__GNUC__) && !defined(USE_CXX0X)
! //#include <tr1/unordered_set>
! //using std::tr1::unordered_set;
! #include <unordered_set>
! using std::unordered_set;
#else
Now just
make && make install
and you now have re::engine::RE2 available for OS X.
The answer by Douglas Scofield is correct, but one additional change is needed. In re2_xs.cc you also must change line 244 as follows:
bool ok = ri->Match(
re2::StringPiece(strbeg, strend - strbeg),
stringarg - strbeg,
strend - strbeg,
RE2::UNANCHORED,
! res, re->nparens + 1);
Douglas Scofield's answer changes the array res to pointer *res to avoid the compiler error of variable length array. However, after this change the line
sizeof res / sizeof *res
does not work because you would be taking the size of the pointer and dividing by the size of the array. Therefore, you have to make the change above to
re->nparens + 1
to get the size of the array pointed to by *res, which is what was desired in the original code.
If you don't make the change then capture groups will not work in re2. You will get errors that your capture groups like $1, $2, etc. are uninitialized.
So great answer above, just needs one addendum.

Why system doesn't return main's value?

[root# test]$ cat return10.c
#include <stdio.h>
int main(int argc, char *argv[]){
return 10;
}
[root# test]$ perl -e 'print system("/path_to_return10")'
2560
I was expecting 10 but got 2560,why?
See $? in perldoc perlvar.
You got 10 * 256 (return value = 10) + 0 * 128 (there was no core dump) + 0 (process wasn't killed by signal).
as specified in the documentation for the system call in perl (http://perldoc.perl.org/functions/system.html):
The return value is the exit status of the program as returned by the
wait call. To get the actual exit value, shift right by eight (see
below).
indeed: 2560 >> 8 = 10