defining entry point (main) in an external static lib for a CLRexecutable

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • nicolas.hognon@gmail.com

    #1

    defining entry point (main) in an external static lib for a CLRexecutable

    Hello,

    With non CLR C++ I am used to have a static library (MyMain.lib) which
    defines the main entry points depending on the plateform (windows,
    unix, mac os x, ps3, ...). We are planning to develop some executable
    using CLR (managed C++ mixed with non managed C++). So I decide to add
    a new entry point to my lib.

    I have something like this :

    #if defined(MSVC_MA NAGED)

    int main(array<Syst em::String ^^args)
    {
    error err = eOk;
    err = MyMain(args);
    return err;
    }

    #endif

    I have a project (MyExe) which create a CLR executable. This project
    define the function MyMain and link with MyMain.lib which define the
    main function. But the linker failed saying it can find the entry
    point. I did not understand why because the entry point is defined in
    a library and I link with it.

    Perhaps static libraries behave in a different way in CLR mode.
    Someone got an idea about my problem ?
  • Ben Voigt [C++ MVP]

    #2
    Re: defining entry point (main) in an external static lib for a CLR executable

    nicolas.hognon@ gmail.com wrote:
    Hello,
    >
    With non CLR C++ I am used to have a static library (MyMain.lib) which
    defines the main entry points depending on the plateform (windows,
    unix, mac os x, ps3, ...). We are planning to develop some executable
    using CLR (managed C++ mixed with non managed C++). So I decide to add
    a new entry point to my lib.
    >
    I have something like this :
    >
    #if defined(MSVC_MA NAGED)
    >
    int main(array<Syst em::String ^^args)
    {
    error err = eOk;
    err = MyMain(args);
    return err;
    }
    >
    #endif
    >
    I have a project (MyExe) which create a CLR executable. This project
    define the function MyMain and link with MyMain.lib which define the
    main function. But the linker failed saying it can find the entry
    point. I did not understand why because the entry point is defined in
    a library and I link with it.
    >
    Perhaps static libraries behave in a different way in CLR mode.
    Someone got an idea about my problem ?
    Have you tried just using the conventional definition of

    int main(int, char**)

    ?

    Anyway, the correct macro to test would be __cplusplus_cli instead of
    MSVC_MANAGED.


    Comment

    Working...