Domanda

I am trying to run some tests with cppUnit tests on NETBEANS on Mac - Lion OS10x but I get this error after i try to compile it:

/usr/bin/make" -f nbproject/Makefile-Debug.mk QMAKE= SUBPROJECTS= .build-conf
"/usr/bin/make"  -f nbproject/Makefile-Debug.mk dist/Debug/GNU-MacOSX/xxx
make[2]: `dist/Debug/GNU-MacOSX/xxx' is up to date.
"/usr/bin/make" -f nbproject/Makefile-Debug.mk SUBPROJECTS= .build-tests-conf
"/usr/bin/make"  -f nbproject/Makefile-Debug.mk dist/Debug/GNU-MacOSX/xxx
make[2]: `dist/Debug/GNU-MacOSX/xxx' is up to date.
mkdir -p build/Debug/GNU-MacOSX/tests/TestFiles
g++       -o build/Debug/GNU-MacOSX/tests/TestFiles/f1 build/Debug/GNU-MacOSX/newmain_nomain.o   
-lcppunit -lcppunit -lcppunit 
Undefined symbols for architecture x86_64:
  "_main", referenced from:
   start in crt1.10.6.o
ld: symbol(s) not found for architecture x86_64
collect2: ld returned 1 exit status
make[1]: *** [build/Debug/GNU-MacOSX/tests/TestFiles/f1] Error 1
make: *** [.build-tests-impl] Error 2

BUILD TESTS FAILED (exit value 2, total time: 11s) 

Can anyone tell me how to resolve this error please?

È stato utile?

Soluzione

That linker error says there is no main() function. You need to create a separate executable containing a main() function to call the unit tests.

CppUnit is a framework, but it doesn't include the actual executable that runs the tests, you have to provide that yourself. Here's a very simple example : https://stackoverflow.com/a/9302288/99027

Autorizzato sotto: CC-BY-SA insieme a attribuzione
Non affiliato a StackOverflow
scroll top