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

N

nicolas.hognon

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_MANAGED)

int main(array<System::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 ?
 
B

Ben Voigt [C++ MVP]

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_MANAGED)

int main(array<System::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.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top