Work at SourceForge, help us to make it a better place! We have an immediate need for a Support Technician in our San Francisco or Denver office.

Close

Multiple definitions of main() scenario

Help
Souvik Roy
2010-07-01
2013-04-22
  • Souvik Roy
    Souvik Roy
    2010-07-01

    Hi everyone,
    I've just started with CppUnit this morning and stuck up in a problem. Basically I have a class interface defined in server.h and its definitions along with it's main() method in server.cpp. This file is in my top level of  hierarchy in my project and defines a global variable which is used in the other lower levels.
    I have created a few tests using CppUnit and added neccessary stuffs to my existing makefile , something like:

    bin_PROGRAMS=server tests
    tests_SOURCES=UnitTests/main.cpp UnitTests/FileNamesChecker.cpp server.cpp
    

    Now that naturally gives me a "Multiple Definitions of main()" error, as there UnitTest/main.cpp contains the main method for CppUnit and server.cpp contains the main method for the project. How can I run the test as a separate application ?

    Thanks
    Souvik

     
  • Souvik Roy
    Souvik Roy
    2010-07-01

    Edit: I wanna pull that off without disturbing the existing sources in the project.