This Bugzilla instance is a read-only archive of historic NetBeans bug reports. To report a bug in NetBeans please follow the project's instructions for reporting issues.

Bug 191045 - CppUnit AND multiple definition of `main'
Summary: CppUnit AND multiple definition of `main'
Status: NEW
Alias: None
Product: cnd
Classification: Unclassified
Component: UnitTest Support (show other bugs)
Version: 6.x
Hardware: PC Linux
: P3 normal (vote)
Assignee: issues@cnd
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2010-10-16 00:12 UTC by dix75
Modified: 2014-04-14 14:32 UTC (History)
1 user (show)

See Also:
Issue Type: ENHANCEMENT
Exception Reporter:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description dix75 2010-10-16 00:12:31 UTC
KUbuntu 10.10 with cppunit

Scenario:
- Create Qt project
- Open main.h file
- Create easy function
void c()
{
}
- Call context menu and select "Create Test|New CppUnit Test..."
- Select All and press Next button, Press Finish button
- Run Test alt + F6

Get Error Log (multiple definition of `main')

"/usr/bin/make" -f nbproject/Makefile-Debug.mk QMAKE=/home/dix/qtsdk-2010.05/qt/bin/qmake SUBPROJECTS= .build-conf
make[1]: Вход в каталог `/home/dix/NetBeansProjects/QtApplication_1'
/home/dix/qtsdk-2010.05/qt/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]: Вход в каталог `/home/dix/NetBeansProjects/QtApplication_1'
g++ -m64 -Wl,-rpath,/home/dix/qtsdk-2010.05/qt/lib -o dist/Debug/GNU-Linux-x86/QtApplication_1 build/Debug/GNU-Linux-x86/newsimpletest.o build/Debug/GNU-Linux-x86/main.o    -L/home/dix/qtsdk-2010.05/qt/lib -lQtGui -L/home/dix/qtsdk-2010.05/qt/lib -L/usr/X11R6/lib64 -lQtCore -lpthread 
make[2]: Выход из каталога `/home/dix/NetBeansProjects/QtApplication_1'
build/Debug/GNU-Linux-x86/main.o: In function `main':
make[1]: Выход из каталога `/home/dix/NetBeansProjects/QtApplication_1'
/home/dix/NetBeansProjects/QtApplication_1/main.cpp:13: multiple definition of `main'
build/Debug/GNU-Linux-x86/newsimpletest.o:/home/dix/NetBeansProjects/QtApplication_1/tests/newsimpletest.cpp:24: first defined here
collect2: ld returned 1 exit status
make[2]: *** [dist/Debug/GNU-Linux-x86/QtApplication_1] Ошибка 1
make[1]: *** [.build-conf] Ошибка 2
make: *** [.build-impl] Ошибка 2

ПОСТРОИТЬ FAILED (значение выхода 2, общее время: 698мс)
Comment 1 nnnnnk 2011-10-13 14:45:17 UTC
we do not support unit tests for Qt projects yet.

you could try to create test targets manually:
http://nnnnnk.name/unittests/nb69unittests_for_existing.html
Comment 2 ahontour 2012-11-07 13:19:45 UTC
I don't using QT.

I have a similar problem when generating multiple cppunit tests as described here: http://netbeans.org/kb/docs/cnd/c-unit-test.html#addmore

If I only have one cppunit-test everything compiles fine. Whenever I create a second test then I got following compile warnings and errors:

"make" -f nbproject/Makefile-Debug.mk QMAKE= SUBPROJECTS= .build-conf
make[1]: Entering directory `/home/ha/NetBeansProjects/cpputils/tags/1.0/db'
nbproject/Makefile-Debug.mk:107: warning: overriding commands for target `build/Debug/GNU-Linux-x86/tests/TestFiles/f2'
nbproject/Makefile-Debug.mk:73: warning: ignoring old commands for target `build/Debug/GNU-Linux-x86/tests/TestFiles/f2'
"make"  -f nbproject/Makefile-Debug.mk build/Debug/GNU-Linux-x86/tests/TestFiles/f2
make[2]: Entering directory `/home/ha/NetBeansProjects/cpputils/tags/1.0/db'
nbproject/Makefile-Debug.mk:107: warning: overriding commands for target `build/Debug/GNU-Linux-x86/tests/TestFiles/f2'
nbproject/Makefile-Debug.mk:73: warning: ignoring old commands for target `build/Debug/GNU-Linux-x86/tests/TestFiles/f2'
mkdir -p build/Debug/GNU-Linux-x86/tests/TestFiles
g++ -std=c++0x      -o build/Debug/GNU-Linux-x86/tests/TestFiles/f2 build/Debug/GNU-Linux-x86/tests/tests/DbResultTestClass.o build/Debug/GNU-Linux-x86/tests/tests/dbresulttestrunner.o build/Debug/GNU-Linux-x86/DbRow_nomain.o build/Debug/GNU-Linux-x86/Db_nomain.o build/Debug/GNU-Linux-x86/DbCtrl_nomain.o build/Debug/GNU-Linux-x86/DbResult_nomain.o build/Debug/GNU-Linux-x86/postgre_nomain.o build/Debug/GNU-Linux-x86/DbRow.o build/Debug/GNU-Linux-x86/Db.o build/Debug/GNU-Linux-x86/DbCtrl.o build/Debug/GNU-Linux-x86/DbResult.o build/Debug/GNU-Linux-x86/postgre.o -lcppunit    -lcppunit -lcppunit 
build/Debug/GNU-Linux-x86/DbRow.o: In function `ape::db::operator<<(std::basic_ostream<char, std::char_traits<char> >&, ape::db::DbRow&)':
/home/ha/NetBeansProjects/cpputils/tags/1.0/db/DbRow.cpp:15: multiple definition of `ape::db::operator<<(std::basic_ostream<char, std::char_traits<char> >&, ape::db::DbRow&)'
build/Debug/GNU-Linux-x86/DbRow_nomain.o:/home/ha/NetBeansProjects/cpputils/tags/1.0/db/DbRow.cpp:15: first defined here
build/Debug/GNU-Linux-x86/DbRow.o: In function `ape::db::DbRow::operator bool()':
/home/ha/NetBeansProjects/cpputils/tags/1.0/db/DbRow.cpp:33: multiple definition of `ape::db::DbRow::operator bool()'
build/Debug/GNU-Linux-x86/DbRow_nomain.o:/home/ha/NetBeansProjects/cpputils/tags/1.0/db/DbRow.cpp:33: first defined here
build/Debug/GNU-Linux-x86/DbRow.o: In function `ape::db::DbRow::operator[](int)':
/home/ha/NetBeansProjects/cpputils/tags/1.0/db/DbRow.cpp:45: multiple definition of `ape::db::DbRow::operator[](int)'
build/Debug/GNU-Linux-x86/DbRow_nomain.o:/home/ha/NetBeansProjects/cpputils/tags/1.0/db/DbRow.cpp:45: first defined here
build/Debug/GNU-Linux-x86/DbRow.o: In function `DbRow':
/home/ha/NetBeansProjects/cpputils/tags/1.0/db/DbRow.cpp:23: multiple definition of `ape::db::DbRow::DbRow(ape::db::DbRow const&)'
build/Debug/GNU-Linux-x86/DbRow_nomain.o:/home/ha/NetBeansProjects/cpputils/tags/1.0/db/DbRow.cpp:23: first defined here
build/Debug/GNU-Linux-x86/DbRow.o: In function `ape::db::DbRow::operator=(ape::db::DbRow const&)':
/home/ha/NetBeansProjects/cpputils/tags/1.0/db/DbRow.cpp:27: multiple definition of `ape::db::DbRow::operator=(ape::db::DbRow const&)'
build/Debug/GNU-Linux-x86/DbRow_nomain.o:/home/ha/NetBeansProjects/cpputils/tags/1.0/db/DbRow.cpp:27: first defined here
build/Debug/GNU-Linux-x86/DbRow.o: In function `ape::db::DbRow::operator[](ape::String)':
/home/ha/NetBeansProjects/cpputils/tags/1.0/db/DbRow.cpp:37: multiple definition of `ape::db::DbRow::operator[](ape::String)'
build/Debug/GNU-Linux-x86/DbRow_nomain.o:/home/ha/NetBeansProjects/cpputils/tags/1.0/db/DbRow.cpp:37: first defined here
build/Debug/GNU-Linux-x86/DbRow.o: In function `ape::db::DbRow::operator[](char const*)':
.... and so on