getting an error of BUILD_FAIL - c++

I am using netbeans IDE on ubuntu for c++ and whenever i am running a program i am getting an error of BUILD_FAIL
"/usr/bin/make" -f nbproject/Makefile-Debug.mk QMAKE= SUBPROJECTS= .build-conf
make[1]: Entering directory `/home/rupesh/NetBeansProjects/Cpp1'
"/usr/bin/make" -f nbproject/Makefile-Debug.mk dist/Debug/GNU-Linux-x86/cpp1
make[2]: Entering directory `/home/rupesh/NetBeansProjects/Cpp1'
mkdir -p dist/Debug/GNU-Linux-x86
g++-o dist/Debug/GNU-Linux-x86/cpp1 build/Debug/GNU-Linux-x86/main.o build/Debug/GNU- Linux-x86/1.o
build/Debug/GNU-Linux-x86/1.o: In function `main':
/home/rupesh/NetBeansProjects/Cpp1/1.cpp:4: multiple definition of `main'
build/Debug/GNU-Linux-x86/main.o:/home/rupesh/NetBeansProjects/Cpp1/main.cpp:15: first defined here
collect2: ld returned 1 exit status
make[2]: *** [dist/Debug/GNU-Linux-x86/cpp1] Error 1
make[2]: Leaving directory `/home/rupesh/NetBeansProjects/Cpp1'
make[1]: *** [.build-conf] Error 2
make[1]: Leaving directory `/home/rupesh/NetBeansProjects/Cpp1'
make: *** [.build-impl] Error 2
BUILD FAILED (exit value 2, total time: 190ms)
I am running a simple program to print hello world.

From what the compiler is spitting out, it seems you have two files that specify a main() being built as one project.
/home/rupesh/NetBeansProjects/Cpp1/1.cpp:4: multiple definition of
`main'
build/Debug/GNU-Linux-x86/main.o:/home/rupesh/NetBeansProjects/Cpp1/main.cpp:15:
first defined here collect2: ld returned 1 exit status make[2]: *
[dist/Debug/GNU-Linux-x86/cpp1] Error 1
check your folders to make sure you have no other files that the compiler is attempting to build in with main.cpp, in this case look for a 1.cpp

Related

C++ application failing to build with 'cannot find -lmysqlpp' but it appears to be there

I'm trying to build an application with Netbeans and getting the following error:
/usr/bin/ld: cannot find -lmysqlpp
I believe this exists as per the below screen shots;
and here in my includes from Netbeans;
The below is the full output from Netbeans;
cd '/media/psf/DL/DL_src/FEC_src/docugirl'
/usr/bin/make -f Makefile CONF=Debug
"/usr/bin/make" -f nbproject/Makefile-Debug.mk QMAKE= SUBPROJECTS= .build-conf
make[1]: Entering directory '/media/psf/DL/DL_src/FEC_src/docugirl'
"/usr/bin/make" -f nbproject/Makefile-Debug.mk /app/bin/docugirl
make[2]: Entering directory '/media/psf/DL/DL_src/FEC_src/docugirl'
mkdir -p /app/bin
g++ -o /app/bin/docugirl build/Debug/GNU-Linux/docugirl.o -lm -lpthread /pcli/library/libcore.a /pcli/library/libsdd.a -lmysqlpp
/usr/bin/ld: cannot find -lmysqlpp
collect2: error: ld returned 1 exit status
make[2]: *** [nbproject/Makefile-Debug.mk:67: /app/bin/docugirl] Error 1
make[2]: Leaving directory '/media/psf/DL/DL_src/FEC_src/docugirl'
make[1]: *** [nbproject/Makefile-Debug.mk:59: .build-conf] Error 2
make[1]: Leaving directory '/media/psf/DL/DL_src/FEC_src/docugirl'
make: *** [nbproject/Makefile-impl.mk:40: .build-impl] Error 2
BUILD FAILED (exit value 2, total time: 472ms)
For completeness, the source exists on a remote Debian server (as has previous successfully created and built mysql type applications).
So, I'm a little confused, I thought and assumed that I had the necessary mysql stuff in order to build this, I am able to build other mysql applications with this setup. Is this mysqlpp different/additional to the /usr/include/mysql and /usr/include/mysql++?
The /usr/include/mysql links to /usr/include/mariadb
Any help would be greatly appreciated here, thanks in advance...
#HEKTO This was indeed the problem but it seemed that the current release of Debian (10.5) did not include the libmysql++-dev package, the reasons for which are as yet unknown to me and although I had copied the mysql++ header files across, the libmysqlpp.so was indeed not there. In this instance, I resorted to using a previous release, although I believe the next release will include this.
See here: https://packages.debian.org/stretch/libmysql++-dev

NetBeans building failure | make Error 1

I get the following errors while building my project (game with C++/SFML):
cd '/home/osboxes/NetBeansProjects/Prueba'
/usr/bin/make -f Makefile CONF=Debug
"/usr/bin/make" -f nbproject/Makefile-Debug.mk QMAKE= SUBPROJECTS= .build-conf
make[1]: Entering directory '/home/osboxes/NetBeansProjects/Prueba'
"/usr/bin/make" -f nbproject/Makefile-Debug.mk dist/Debug/GNU-Linux/prueba
make[2]: Entering directory '/home/osboxes/NetBeansProjects/Prueba'
mkdir -p dist/Debug/GNU-Linux
g++ -o dist/Debug/GNU-Linux/prueba build/Debug/GNU-Linux/AABBCollidable.o build/Debug/GNU-Linux/AABBCollisionDetector.o build/Debug/GNU-Linux/AnimatedSprite.o build/Debug/GNU-Linux/Animation.o build/Debug/GNU-Linux/ConvexCollidable.o build/Debug/GNU-Linux/ConvexCollisionDetector.o build/Debug/GNU-Linux/ConvexShape.o build/Debug/GNU-Linux/Director.o build/Debug/GNU-Linux/Entry.o build/Debug/GNU-Linux/Event.o build/Debug/GNU-Linux/EventManager.o build/Debug/GNU-Linux/FileLogger.o build/Debug/GNU-Linux/GuiElement.o build/Debug/GNU-Linux/GuiSystem.o build/Debug/GNU-Linux/Label.o build/Debug/GNU-Linux/LabelButton.o build/Debug/GNU-Linux/ResourceManager.o build/Debug/GNU-Linux/State.o -L/usr/lib/x86_64-linux-gnu -lsfml-window -lsfml-system -lsfml-graphics -lsfml-audio
/usr/lib/gcc/x86_64-linux-gnu/5/../../../x86_64-linux-gnu/crt1.o: In function `_start':
collect2: error: ld returned 1 exit status
nbproject/Makefile-Debug.mk:79: recipe for target 'dist/Debug/GNU-Linux/prueba' failed
make[2]: *** [dist/Debug/GNU-Linux/prueba] Error 1
make[2]: Leaving directory '/home/osboxes/NetBeansProjects/Prueba'
nbproject/Makefile-Debug.mk:76: recipe for target '.build-conf' failed
make[1]: *** [.build-conf] Error 2
make[1]: Leaving directory '/home/osboxes/NetBeansProjects/Prueba'
nbproject/Makefile-impl.mk:39: recipe for target '.build-impl' failed
make: *** [.build-impl] Error 2
BUILD FAILED (exit value 2, total time: 2s)
I have installed NetBeans IDE 8.1 with SFML libraries. I tried to fix it by clearing cache from NetBeans and then restart IDE but still does the same errors.
My project was compiled with Standard C++ compiler (C++11 version).
Hope you could help me. Thanks by the way...

C++ boost error

I'm building a code based on this fast factorial library, and it depends on boost and mpir. I'm running Ubuntu 14.04 and using Netbeans 8.0.2. To simply test the #include statements of the library I made this silly code:
#include <iostream>
#include <mpir.h>
#include <primeswing.h>
#include <xmath.h>
/*
*
*/
int main() {
long x = 4;
std::cout << x;
return 0;
}
When I try to compile it however I get the following error
"/usr/bin/make" -f nbproject/Makefile-Debug.mk QMAKE= SUBPROJECTS= .build-conf
make[1]: Entering directory `/home/arengorn/NetBeansProjects/BA'
"/usr/bin/make" -f nbproject/Makefile-Debug.mk dist/Debug/GNU-Linux-x86/ba
make[2]: Entering directory `/home/arengorn/NetBeansProjects/BA'
mkdir -p dist/Debug/GNU-Linux-x86
g++ -o dist/Debug/GNU-Linux-x86/ba build/Debug/GNU-Linux-x86/main.o ->lm
build/Debug/GNU-Linux-x86/main.o: In function `__static_initialization_and_destruction_0':
/usr/include/boost/system/error_code.hpp:222: undefined reference to `boost::system::generic_category()'
/usr/include/boost/system/error_code.hpp:223: undefined reference to `boost::system::generic_category()'
/usr/include/boost/system/error_code.hpp:224: undefined reference to `boost::system::system_category()'
collect2: error: ld returned 1 exit status
make[2]: *** [dist/Debug/GNU-Linux-x86/ba] Error 1
make[2]: Leaving directory `/home/arengorn/NetBeansProjects/BA'
make[1]: *** [.build-conf] Error 2
make[1]: Leaving directory `/home/arengorn/NetBeansProjects/BA'
make: *** [.build-impl] Error 2
BUILD FAILED (exit value 2, total time: 114ms)
Can anyone help me with why is the boost library (which is installed and present under /usr/include) is not working?
As commented by Wintermute
You need to link libboost_system.so. Put -lboost_system in your linker flags.
That solved the problem.

Netbeans Building Issues for C++

I'm using the MinGW complier/make/etc files but whenever I try to run my code it spits this back out to me:
"/usr/bin/make" -f nbproject/Makefile-Debug.mk QMAKE= SUBPROJECTS= .build-conf
make[1]: Entering directory `/c/Users/Geneva/workspace/C++ Through Game Programming'
"/usr/bin/make" -f nbproject/Makefile-Debug.mk dist/Debug/MinGW-Windows/c___through_game_programming.exe
make[2]: Entering directory `/c/Users/Geneva/workspace/C++ Through Game Programming'
mkdir -p dist/Debug/MinGW-Windows
g++ -o dist/Debug/MinGW-Windows/c___through_game_programming build/Debug/MinGW-Windows/diceroll.o build/Debug/MinGW-Windows/main.o
build/Debug/MinGW-Windows/main.o: In function `main':
C:\Users\Geneva\workspace\C++ Through Game Programming/main.cpp:35: multiple definition of `main'
build/Debug/MinGW-Windows/diceroll.o:C:\Users\Geneva\workspace\C++ Through Game Programming/diceroll.cpp:16: first defined here
collect2: ld returned 1 exit status
make[2]: *** [dist/Debug/MinGW-Windows/c___through_game_programming.exe] Error 1
make[2]: Leaving directory `/c/Users/Geneva/workspace/C++ Through Game Programming'
make[1]: *** [.build-conf] Error 2
make[1]: Leaving directory `/c/Users/Geneva/workspace/C++ Through Game Programming'
make: *** [.build-impl] Error 2
BUILD FAILED (exit value 2, total time: 1s)
I have my environment variable PATH set right, when I installed the gbd I just extracted it to the normal C:\MinGW\bin so that I wouldn't have to do C:\MinGW\msys\1.0\bin
Can anyone help out? If I can't figure this out I'm going to go back to coding in Java
The compiler message is clear: You have defined multiple main() functions

Compiling cpp code in netbeans produce errors, how to solve it?

i use the netbeans with MinGW and MYSY make /debugger but when i compile a basic cpp code in it and run it it produces two erorrs
this is the code runned and the output![alt text][1] box
#include <iostream>
void main()
{
cout << "Hello World!" << endl;
cout << "Welcome to C++ Programming" << endl;
}
output is
/usr/bin/make -f nbproject/Makefile-Debug.mk SUBPROJECTS= .build-conf
make[1]: Entering directory `/d/Users/Home/Documents/NetBeansProjects/newApp'
/usr/bin/make -f nbproject/Makefile-Debug.mk dist/Debug/MinGW-Windows/newapp.exe
make[2]: Entering directory `/d/Users/Home/Documents/NetBeansProjects/newApp'
mkdir -p dist/Debug/MinGW-Windows
g++.exe -o dist/Debug/MinGW-Windows/newapp build/Debug/MinGW-Windows/newmain.o build/Debug/MinGW-Windows/newfile.o build/Debug/MinGW-Windows/main.o
build/Debug/MinGW-Windows/newfile.o: In function `main':
D:/Users/Home/Documents/NetBeansProjects/newApp/newfile.cpp:5: multiple definition of `main'
build/Debug/MinGW-Windows/newmain.o:D:/Users/Home/Documents/NetBeansProjects/newApp/newmain.c:15: first defined here
build/Debug/MinGW-Windows/main.o: In function `main':
D:/Users/Home/Documents/NetBeansProjects/newApp/main.cpp:13: multiple definition of `main'
build/Debug/MinGW-Windows/newmain.o:D:/Users/Home/Documents/NetBeansProjects/newApp/newmain.c:15: first defined here
collect2: ld returned 1 exit status
make[2]: *** [dist/Debug/MinGW-Windows/newapp.exe] Error 1
make[2]: Leaving directory `/d/Users/Home/Documents/NetBeansProjects/newApp'
make[1]: *** [.build-conf] Error 2
make[1]: Leaving directory `/d/Users/Home/Documents/NetBeansProjects/newApp'
make: *** [.build-impl] Error 2
BUILD FAILED (exit value 2, total time: 1s)
how can i solve this ?
I can see three things here, the first two have been pointed out by Xavier and jwismar, but to consolidate:
Both D:/Users/Home/Documents/NetBeansProjects/newApp/newfile.cpp and D:/Users/Home/Documents/NetBeansProjects/newApp/main.cpp define a main(). You'll need to remove one of these from your project.
You'll need to be using std::cout and using std::endl.
main() should always return an int.
You have two different files in your project that define main(). One is called newfile.cpp, the other one is called newmain.c
And as the earlier comment notes, you will need to specify std::cout and std::endl