'static binding' with C++/CLI?

After asking this question in the VC++ Express forum and not receiving a single answer I gather this forum section might be a better place to search for answers.

I have a C++/CLI solution I created in VS2005 Express consisting of a windows forms project (the main programm) and a few libraries - now I'd like to create a single executable instead of an executable and a bunch of dll files. As I can't create static C++/CLI libraries (or can I ) how else can I compile them into a single executable Simply moving the header and cpp files from one project to the other didn't do me any good.

Any ideas what I should look for when trying to combine different projects into one Or IS there a way to create a statically bind a managed code library to a programm I'd rather keep the library code seperate from the main application as I use parts of it in other projects, too.

The reason I want to do this is that this is just a small too that the user should be able to put wherever he wants, without having to be carefull about copying any additional files.


Answer this question

'static binding' with C++/CLI?

  • Vadim Tryshev - Microsoft

    Hi!

    Any progress on this issue I have the same problem when trying to link with a lib containing managed code (unmanaged classes works fine). I guess it is because the lib is not a MSIL-file

    See also:
    http://forums.microsoft.com/MSDN/ShowPost.aspx PostID=463461&SiteID=1&mode=1

    and:
    http://forums.microsoft.com/MSDN/ShowPost.aspx PostID=316940&SiteID=1

    Kind regards

    Dag



  • Radenko Zec

    Thanks - I assume #using is caused by me referencing the library project How do I make VC++ #include the static library instead Simply adding a #include "<path>" to the header files didn't help.
    I'm quite new to VC++, having only a little experience with GCC (but that's also been a long time ago - I'm more familar with VC# 2003). Maybe I looked for the wrong keywords, but the VC++ 2005 Express help didn't turn up anything usefull, and I'm still waiting for my standard edition to arrive.
    So could you give me some more detailed help, please In laymans terms, if possible... ;)

  • Ben Jackson33513

    You don't need #using and it does not work on static library files. Just #include the header files from the library like in a unmanaged c++ project.
  • kdalons

    Why adding #include did not help Some compiler/linker errors
  • kevintw

    Includeing the library needs 2 things:

    1. include the header file with the definitions in your cpp file.

    2. define the LIB file in the input section of the linker. "#using" is not possible!



  • Raymond de Bourbon

    Well, I had tried that before, but it just doesn't work: I always get a 'fatal error C1113: #using error' - all projects are set to /clr:pure and /MD. If I set the libs to be dynamic they compile fine...
     :(

  • Lars E.Nes

     Joltan wrote:
    As I can't create static C++/CLI libraries (or can I ).

    You can create static C++/CLI libraries!!! (wow! I'm as surprised as you are).

    Project Properties -> General -> Configuration Type -> Change to Static Library.

    However, make sure all your libraries compile with the same set of switches (/clr:[pure|safe|oldSyntax] needs to be the same, as does /M[T|D|d|]).

     



  • Ravikumar KPV

    I removed the reference and added an #include statement (with the path to the static libraries main header file) in the header file where I was using the library's classes. The compiler gave me the error that he didn't know these classes (as if I simply didn't have them defined anywhere - the #include itself didn't cause any complaints). I have no access to my solution right now, but I'll post the details later this evening.

    It's most likely some very simple problem with the (obviously wrong) way I try to inlude the library. I just can't find any examples on how to do it correctly, so I could compare it to my desperate efforts... :(

  • 'static binding' with C++/CLI?