NetBeans Forums

 FAQFAQ   SearchSearch   MemberlistMemberlist   RegisterRegister   ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 
  

BUILD FAILED (exit value 2)

 
Post new topic   Reply to topic    NetBeans Forums -> C/C++ Users
View previous topic :: View next topic  
Author Message
adamhff



Joined: 19 Feb 2017
Posts: 3

PostPosted: Sun Feb 19, 2017 4:56 pm    Post subject: BUILD FAILED (exit value 2) Reply with quote

Hello, I hope I'm in the right spot and that I can get some help. I really want to use netbeans in order to be able to code with it in multiple languages. I'm trying just a simple hello world program and I know my code is fine. (this is a C++ program)

This is my code in main.cpp:
#include <iostream>
using namespace std;

int main ()
{
cout << "Hello World! ";
cout << "I'm a C++ program";
return 0;
}






So I am getting this error:
BUILD FAILED (exit value 2, total time: 302ms)
collect2: error: ld returned 1 exit status
nbproject/Makefile-Debug.mk:62: recipe for target 'dist/Debug/GNU-Linux/cppapplication_3' failed
make[2]: *** [dist/Debug/GNU-Linux/cppapplication_3] Error 1
make[2]: Leaving directory '/home/me/NetBeansProjects/CppApplication_3'
nbproject/Makefile-Debug.mk:59: recipe for target '.build-conf' failed
make[1]: *** [.build-conf] Error 2
make[1]: Leaving directory '/home/me/NetBeansProjects/CppApplication_3'
nbproject/Makefile-impl.mk:39: recipe for target '.build-impl' failed
make: *** [.build-impl] Error 2

- It has something to do with makefile I guess, I am rather new and do not fully understand this. I might have it set up wrong.

I have been trying to solve this for 2 days and only have been able to find things on google and this forum where they talk about this error in relation to cygwin or mingw. I am not running this in windows.I am using Debian Linux.
Also, while doing research I came across stuff about changing things in tools > options > C/C++ > build tools - especially changing the C++ compiler. I am using GCC for that right now.

I also found stuff on changing the PATH, but couldn't really get much help with that if thats the problem.

Anyway, thanks in advance, hope I can get this solved.
Back to top
soldatov



Joined: 05 Nov 2009
Posts: 577

PostPosted: Sun Feb 19, 2017 9:39 pm    Post subject: Re: BUILD FAILED (exit value 2) Reply with quote

You cut all important information from build log. I want to see "g++ ..." lines too.
Back to top
adamhff



Joined: 19 Feb 2017
Posts: 3

PostPosted: Sun Feb 19, 2017 11:03 pm    Post subject: Reply with quote

Ok, here's the rest of it, sorry.

cd '/home/adam/NetBeansProjects/CppApplication_3'
/usr/bin/make -f Makefile CONF=Debug
"/usr/bin/make" -f nbproject/Makefile-Debug.mk QMAKE= SUBPROJECTS= .build-conf
make[1]: Entering directory '/home/adam/NetBeansProjects/CppApplication_3'
"/usr/bin/make" -f nbproject/Makefile-Debug.mk dist/Debug/GNU-Linux/cppapplication_3
make[2]: Entering directory '/home/adam/NetBeansProjects/CppApplication_3'
mkdir -p dist/Debug/GNU-Linux
gcc -o dist/Debug/GNU-Linux/cppapplication_3 build/Debug/GNU-Linux/main.o
build/Debug/GNU-Linux/main.o: In function `main':
/home/adam/NetBeansProjects/CppApplication_3/main.cpp:20: undefined reference to `std::cout'
/home/adam/NetBeansProjects/CppApplication_3/main.cpp:20: undefined reference to `std::basic_ostream<char, std::char_traits<char> >& std::operator<< <std::char_traits<char> >(std::basic_ostream<char, std::char_traits<char> >&, char const*)'
/home/adam/NetBeansProjects/CppApplication_3/main.cpp:21: undefined reference to `std::cout'
/home/adam/NetBeansProjects/CppApplication_3/main.cpp:21: undefined reference to `std::basic_ostream<char, std::char_traits<char> >& std::operator<< <std::char_traits<char> >(std::basic_ostream<char, std::char_traits<char> >&, char const*)'
build/Debug/GNU-Linux/main.o: In function `__static_initialization_and_destruction_0':
/usr/include/c++/4.9/iostream:74: undefined reference to `std::ios_base::Init::Init()'
/usr/include/c++/4.9/iostream:74: undefined reference to `std::ios_base::Init::~Init()'
collect2: error: ld returned 1 exit status
nbproject/Makefile-Debug.mk:62: recipe for target 'dist/Debug/GNU-Linux/cppapplication_3' failed
make[2]: *** [dist/Debug/GNU-Linux/cppapplication_3] Error 1
make[2]: Leaving directory '/home/adam/NetBeansProjects/CppApplication_3'
nbproject/Makefile-Debug.mk:59: recipe for target '.build-conf' failed
make[1]: *** [.build-conf] Error 2
make[1]: Leaving directory '/home/adam/NetBeansProjects/CppApplication_3'
nbproject/Makefile-impl.mk:39: recipe for target '.build-impl' failed
make: *** [.build-impl] Error 2

BUILD FAILED (exit value 2, total time: 181ms)
Back to top
soldatov



Joined: 05 Nov 2009
Posts: 577

PostPosted: Mon Feb 20, 2017 8:18 am    Post subject: Reply with quote

In your case IDE uses gcc instead of g++. You needs to check:
a) Tools > Options > C/C++ > Build Tools > GNU
expected value: C++ Compiler = /usr/bin/g++
b) Tools > Options > C/C++ > Other > File Extensions
expected values:
C++ File = C, c++, cc, cpp, cxx, mm
C File = c, i, m
c) File Properties (context menu on main.cpp) > General > Tool
expected value: C++ Compiler
Back to top
adamhff



Joined: 19 Feb 2017
Posts: 3

PostPosted: Mon Feb 20, 2017 2:47 pm    Post subject: RE: Reply with quote

Awesome sauce! That worked. I only needed to do the first one with G++.

But I'm a bit confused. If I'm using GCC instead of G++ then why would I put G++ there?

Thanks so much!
Back to top
Display posts from previous:   
Post new topic   Reply to topic    NetBeans Forums -> C/C++ Users All times are GMT
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum
You cannot attach files in this forum
You can download files in this forum


Powered by phpBB
By use of this website, you agree to the NetBeans Policies and Terms of Use. © 2012, Oracle Corporation and/or its affiliates. Sponsored by Oracle logo