Undefined link to WinMain @ 16 when using boost with MinGW

I am programming in C ++ with Eclipse under Windows 7.

My makefile looks like this:

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 buildor make exec, everything works fine. However, when using, make testI get undefined reference to 'WinMain@16'. The only file in test/this one is using the boost unit test framework:

#define BOOST_TEST_MODULE ChunkTest
#include <boost/test/unit_test.hpp>

#include <Chunk.h>
using namespace CacheOpt;

BOOST_AUTO_TEST_CASE( getChunks )
{
    Chunk::setSize(10);
    BOOST_CHECK_EQUAL(Chunk::getSize(), 11);
}

How can I solve this error?

+3
source share
1 answer

It seems you have no method main. You can create it with BOOST_TEST_MAIN. BOOST_TEST_MODULEdefines mainonly when it is BOOST_TEST_DYN_LINKalready defined.

+3
source

Source: https://habr.com/ru/post/1784860/


All Articles