I'm programming in C++ with Eclipse under Windows 7.
My makefile is as follows:
build:
g++ -shared -o "lib\libCacheOpt.a" "src\*.cpp" -enable-auto-import -I"${CWD}\include" -I"${BOOST}" -L"${BOOST}\lib" -lboost_program_options -lboost_unit_test_framework
exec: build
g++ "src\main.cpp" -enable-auto-import -I"${CWD}\include" -L"${CWD}\lib" -I"${BOOST}" -L"${BOOST}\lib" -lCacheOpt -lboost_program_options -o Simulator.exe
test: build
g++ "test\unit\*.cpp" -enable-auto-import -I"${CWD}\include" -L"${CWD}\lib" -I"${BOOST}" -L"${BOOST}\lib" -lmingw32 -lCacheOpt -lboost_unit_test_framework -o run_tests.exe
clean:
rm Simulator.exe
rm "lib\libCacheOpt.a"
When I do make build
or make exec
everything works fine. However, when using make test
I get undefined reference to 'WinMain@16'
. The only file under test/
is this one, using boost's unit test framework:
#define BOOST_TEST_MODULE ChunkTest
#include <boost/test/unit_test.hpp>
#include <Chunk.h>
using namespace CacheOpt;
BOOST_AUTO_TEST_CASE(开发者_JS百科 getChunks )
{
Chunk::setSize(10);
BOOST_CHECK_EQUAL(Chunk::getSize(), 11);
}
How can I resolve this error?
It looks like you don't have a main
method. You can create one using BOOST_TEST_MAIN
. BOOST_TEST_MODULE
only defines main
if and only if BOOST_TEST_DYN_LINK
is already defined.
精彩评论