tags:

views:

24

answers:

1

guys i have asked a few times ago about Qt usage then problem was that Qt was not configured properly on my system now i have installed metbeans and everything is ok just i have following problem here is code

#include <QtGui/QApplication>
#include <QDir>
#include <QFileInfo>
#include <QtDebug>
int main(int argc, char **argv) {



    foreach(QFileInfo  drive,QDir::drives()){
        qDebug()<<"Drive: "<<drive.absolutePath();
        QDir dir=drive.dir();
        dir.setFilter(QDir::Dirs);
        foreach(QFileInfo rootDirs,dir.entryInfoList())

        qDebug()<< " "<<rootDirs.fileName();

    }
    return 0;
   // return app.exec();
}

and errors are

/usr/bin/make -f nbproject/Makefile-Debug.mk SUBPROJECTS= .build-conf
make[1]: Entering directory `/home/david/NetBeansProjects/QtApplication_1'
/usr/bin/qmake VPATH=. -o qttmp-Debug.mk nbproject/qt-Debug.pro
mv -f qttmp-Debug.mk nbproject/qt-Debug.mk
/usr/bin/make -f nbproject/qt-Debug.mk dist/Debug/GNU-Linux-x86/QtApplication_1
make[2]: Entering directory `/home/david/NetBeansProjects/QtApplication_1'
g++ -c -pipe -g -Wall -W -D_REENTRANT -DQT_GUI_LIB -DQT_CORE_LIB -DQT_SHARED -I/usr/share/qt4/mkspecs/linux-g++ -Inbproject -I/usr/include/qt4/QtCore -I/usr/include/qt4/QtGui -I/usr/include/qt4 -I. -Inbproject -I. -o build/Debug/GNU-Linux-x86/Qt1.o Qt1.cpp
Qt1.cpp:7: warning: unused parameter ‘argc’
Qt1.cpp:7: warning: unused parameter ‘argv’
g++  -o dist/Debug/GNU-Linux-x86/QtApplication_1 build/Debug/GNU-Linux-x86/Qt1.o build/Debug/GNU-Linux-x86/main.o    -L/usr/lib -lQtGui -lQtCore -lpthread 
build/Debug/GNU-Linux-x86/main.o: In function `main':
/home/david/NetBeansProjects/QtApplication_1/main.cpp:10: multiple definition of `main'
build/Debug/GNU-Linux-x86/Qt1.o:/home/david/NetBeansProjects/QtApplication_1/Qt1.cpp:7: first defined here
collect2: ld returned 1 exit status
make[2]: *** [dist/Debug/GNU-Linux-x86/QtApplication_1] Error 1
make[2]: Leaving directory `/home/david/NetBeansProjects/QtApplication_1'
make[1]: *** [.build-conf] Error 2
make[1]: Leaving directory `/home/david/NetBeansProjects/QtApplication_1'
make: *** [.build-impl] Error 2
BUILD FAILED (exit value 2, total time: 1s)

please help

+2  A: 

According to that output, you are compiling two source files Qt1.cpp and main.cpp, both of which define the function main(). You need to remove one of those two files from your project or remove the definition of main() from one of them.

As an added step to get rid of the warning about unused parameters in main(), change it to

main(int /*argc*/, char **/*argv*/)

until you need to use those arguments.

Arnold Spence
thanks very much