When using Boost.Test, there is generally no need to define a main()
function, since Boost.Test provides one itself.
I recently had to convert my project to use static linking of 3rd party libraries (on VS2010). Naturally, I had to link to multiple .lib
s so that the build succeeds, and my build ran just fine.
However, when I ran my test project, something really strange happened. It seems that one of the 3rd party .lib
s (libpng), required by one of my dependent libraries, contained a test file with a main()
function defined within (pngtest.c
, if you must know).
Since my project did not have a main()
function, the linker chose that one as my "test" application. Thus, non of my tests run.
Does anyone know how I prevent this from happening? How can I tell the linker/compiler to use the Boost.Test main()
?
Answering my own question, and clarifying @Tom's answer.
Turns out that the libpng
build script I was using was not the the original shipping with libpng
but one created by the OpenCV build system. The file pngtest.c
was mistakenly included int the build.
The solution to the problem was to remove pngtest.c
from the libpng build script.
The latest OpenCV version, does not include this file anymore.
For more details see my post to Boost mailing list here and my OpenCV bug report here.