none
Unable to start program *.lib in C++/CLI GUI

    Question

  • I am migrating an application from Visual Studio 2005 to Visual Studio 2015.  One of the solutions in the app is a Tester consisting of a pure C++ library, Tester.lib, a console app that uses the library, UsesTester.exe, and a GUI, TesterDialog.exe, that provides an interface for testing other libraries in the overall application.  Tester.lib and UsesTester.exe are written in C++ (unmanaged) and TesterDialog.exe is written in C++/CLI.  All three of the projects compile and link fine.  UsesTester (which uses Tester.lib) executes properly, but TesterDialog (which worked properly when built under VS2005) generates the following error when it is executed:

    Unable to start program 'U:\URoot\Tester\lib\Debug\Tester.lib'.
    U:\URoot\Tester\lib\Debug\Tester.lib is not a valid Win32 application.

    Its as if main () in TesterDialog is trying to run Tester.lib as an .exe.  What is going on here?

    Thanks, Dick

    Monday, December 5, 2016 10:46 PM

Answers

  • I finally figured this out.

    Forum research indicated that the problem was with the project options specifying an incorrect Entry Point.  But the exact solution mentioned in the forums did not work for me so I created a new C++/CLI win32 app from scratch and made changes to the TesterDialog project to be the values in this new VS2015 generated project.  The changes were

    1) Remove the value ‘main’ from the Linker>Advanced>Entry Point> option.  i.e. leave it blank.

    2) Changed

                    int main (array <System::String^>^ args)

    to

                    int APIENTRY wWinMain (_In_ HINSTANCE hInstance,

                        _In_opt_ HINSTANCE hPrevInstance,

                        _In_ LPWSTR    lpCmdLine,

                        _In_ int       nCmdShow)

    in TesterDialog.cpp.

    There is probably a cleaner way to call main without all of those macros but this works.

    Saturday, December 10, 2016 7:18 PM

All replies

  • Hi Dick Swager,

    Thank you for posting in MSDN forum.

    >>Unable to start program 'U:\URoot\Tester\lib\Debug\Tester.lib'.
    U:\URoot\Tester\lib\Debug\Tester.lib is not a valid Win32 application.

    As you said, this error message usually occurs when directly running the the .lib as exe file.

    To have a better understanding of this issue, there is a clarification with you:

    How do you execute theTester.lib? In the C++ project property configure it or in other way you tried to load it?

    Best Regards,


    MSDN Community Support
    Please remember to click "Mark as Answer" the responses that resolved your issue, and to click "Unmark as Answer" if not. This can be beneficial to other community members reading this thread. If you have any compliments or complaints to MSDN Support, feel free to contact MSDNFSF@microsoft.com.

    Tuesday, December 6, 2016 9:53 AM
    Moderator
  • I finally figured this out.

    Forum research indicated that the problem was with the project options specifying an incorrect Entry Point.  But the exact solution mentioned in the forums did not work for me so I created a new C++/CLI win32 app from scratch and made changes to the TesterDialog project to be the values in this new VS2015 generated project.  The changes were

    1) Remove the value ‘main’ from the Linker>Advanced>Entry Point> option.  i.e. leave it blank.

    2) Changed

                    int main (array <System::String^>^ args)

    to

                    int APIENTRY wWinMain (_In_ HINSTANCE hInstance,

                        _In_opt_ HINSTANCE hPrevInstance,

                        _In_ LPWSTR    lpCmdLine,

                        _In_ int       nCmdShow)

    in TesterDialog.cpp.

    There is probably a cleaner way to call main without all of those macros but this works.

    Saturday, December 10, 2016 7:18 PM
  • Hi Dick,

    Glad to hear you have had your issue resolved. And thanks for sharing us your solution and result here.

    Please mark your reply as the answer, it will benefit to other community members who have the same issue.

    Have a nice day:)

    Best Regards,


    MSDN Community Support
    Please remember to click "Mark as Answer" the responses that resolved your issue, and to click "Unmark as Answer" if not. This can be beneficial to other community members reading this thread. If you have any compliments or complaints to MSDN Support, feel free to contact MSDNFSF@microsoft.com.

    Tuesday, December 13, 2016 7:40 AM
    Moderator
  • Hi Dick,

    We haven’t heard from you for a couple of days,  Since you have solved this issue successfully, please mark your reply as answer. it would be much easier for others searching for this solution.

    Thank you for your understanding.

    Best Regards,


    MSDN Community Support
    Please remember to click "Mark as Answer" the responses that resolved your issue, and to click "Unmark as Answer" if not. This can be beneficial to other community members reading this thread. If you have any compliments or complaints to MSDN Support, feel free to contact MSDNFSF@microsoft.com.

    Friday, December 16, 2016 7:57 AM
    Moderator