[Test] BOOST_TEST_NO_MAIN with pre-built BoostPro libraries

Is it possible to create one's own main() implementation when using the pre-built Boost libraries from BoostPro? The difficulty seems to be that, even if I define BOOST_TEST_NO_MAIN before including unit_test.hpp, the main method still exists in the pre-built library and this causes a linker conflict. The existing code I'm wokring on specifies /FORCE to the linker to make our main override the library main but I think that's a horrible solution and would really like to try something else. Even better would be if there were a way to only invoke our code, which includes calls to framework::run(test), if a particular command-line argument were present. In all other cases it would be nice to have the default test runner behaviour. I think this may be wishful thinking though. Any advice is greatly appreciated. Alex

Alexander Lamaison
Is it possible to create one's own main() implementation when using the pre-built Boost libraries from BoostPro?
Yes. If you use shared library.
The difficulty seems to be that, even if I define BOOST_TEST_NO_MAIN before including unit_test.hpp, the main method still exists in the pre-built library and this causes a linker conflict. The existing
You can't after the fact (after the library is built) change the symbols which are present there.
code I'm wokring on specifies /FORCE to the linker to make our main override the library main but I think that's a horrible solution and would really like to try something else.
hmm. I wasn't aware about this option.
Even better would be if there were a way to only invoke our code, which includes calls to framework::run(test), if a particular command-line argument were present. In all other cases it would be nice to have the default test runner behaviour. I think this may be wishful thinking though.
As I said. Using shared library you shaould be able to get what you want here. Gennadiy

"Gennadiy Rozental"
Alexander Lamaison
writes: Is it possible to create one's own main() implementation when using the pre-built Boost libraries from BoostPro?
Yes. If you use shared library.
Do I have to manually copy the DLL from the Boost lib directory to my output directory or is there some automagical way this can be found? I try to avoid DLLs like the plague becuase of the hassle of managing the dependencies.
code I'm wokring on specifies /FORCE to the linker to make our main override the library main but I think that's a horrible solution and would really like to try something else.
hmm. I wasn't aware about this option.
Neither was I. And I can't even find where the project specifies this but that's what the linker output warns that it's doing. It also warns that the "image may not run"! Eeek. Thanks Gennadiy :) P.S. I've posted a test program to that thread about ATLTRACE output. It took me a while to see your response because it had dropped so far down my newsreader.

Alexander Lamaison
"Gennadiy Rozental"
wrote in message news:loom.20090808T170230-257 <at> post.gmane.org... Alexander Lamaison
writes: Is it possible to create one's own main() implementation when using the pre-built Boost libraries from BoostPro?
Yes. If you use shared library.
Do I have to manually copy the DLL from the Boost lib directory to my output directory or is there some automagical way this can be found? I try to avoid DLLs like the plague becuase of the hassle of managing the dependencies.
I think easiest way is to add boost lib directory to the PATH. You can always build Boost.Test library yourself from sources. As far as I know whole process should not take more than 10 min (including bjam compilation).
P.S. I've posted a test program to that thread about ATLTRACE output. It took me a while to see your response because it had dropped so far down my newsreader.
Yes. I've seen it. I'll look into it once I have a bit of free time. Gennadiy
participants (2)
-
Alexander Lamaison
-
Gennadiy Rozental