CodeGuru Home VC++ / MFC / C++ .NET / C# Visual Basic VB Forums Developer.com
Results 1 to 11 of 11
  1. #1
    Join Date
    May 2003
    Location
    Islamabad, Pakistan
    Posts
    284

    RPC Example from MSDN

    Hi Fellows.

    I got the RPC example code from MSDN. I am trying to compile and execute it using visual studio but it is giving me errors. But when i compile it using the makefile and nmake command on commandline it works fine.

    I am creating the .h and _s.c and _c.c using the midl compiler and then i add these files in my server and client application but the both are giving me the error.

    The client application error is
    fatal error C1189: #error : You need a Windows 2000 or later to run this stub because it uses these features:

    The Server application errors are
    Hellos.obj : error LNK2001: unresolved external symbol _hello_ServerIfHandle
    libcmt.lib(wincrt0.obj) : error LNK2001: unresolved external symbol _WinMain@16
    Debug/Server.exe : fatal error LNK1120: 2 unresolved externals

    Thanks

  2. #2
    Join Date
    Aug 2004
    Posts
    184

    Re: RPC Example from MSDN

    From MSDN on the C1189 error.....

    You may also see this error if you build an ATL project with the /robust MIDL compiler option. /robust is only for use when building for a Windows 2000 or later machine. So, either remove /robust or change this line in the dlldatax.c file:

    #define _WIN32_WINNT 0x0400 //for WinNT 4.0 or Win95 with DCOM
    to

    #define _WIN32_WINNT 0x0500 //for WinNT 4.0 or Win95 with DCOM
    For the LNK2001 error....

    This may help for the _WinMain part of the error
    When building a Release version of an ATL project, indicates that CRT startup code is required. To fix, do one of the following,
    Remove _ATL_MIN_CRT from the list of preprocessor defines to allow CRT startup code to be included. See General Configuration Settings Property Page for more information.
    For the _hello_ServerIfHandle part of the error.....
    Make sure sure the .h and .c/.cpp file that contains this function/method is part of the VC++ project so the linker can find the appropriate object files.

    HTH

  3. #3
    Join Date
    May 2003
    Location
    Islamabad, Pakistan
    Posts
    284

    Re: RPC Example from MSDN

    f1shrman
    Thank you very much for the reply.

    You pointed very nicely but still i am unable to solve the problem.

    I looked for the
    #define _WIN32_WINNT 0x0400 //for WinNT 4.0 or Win95 with DCOM
    in dlldatax.c
    but unfortunately there is no such file in my project.

    As there is the concern of _hello_ServerIfHandle i added the idl file and also the .h generated file from MIDL compiler but still the problem remains there.

    As i am trying to compile and run the MSDN project in visual studio. I generated the _c.c _s.c and .h using MIDL compiler on command line and then i added these files in the visualstudio project.

    Can you please do it for me. I am attaching the project files with the post.
    Attached Files Attached Files

  4. #4
    Join Date
    Aug 2004
    Posts
    184

    Re: RPC Example from MSDN

    I dug up the sample in the sdk and from the readme - ran nmake - and everything compiled correctly - here are the results. You might try running nmake cleanall then recompiling
    Attached Files Attached Files

  5. #5
    Join Date
    May 2003
    Location
    Islamabad, Pakistan
    Posts
    284

    Re: RPC Example from MSDN

    f1shrman
    Thank you for spending time for me.

    Dear i can compile ane execute the program using nmake on command line.

    But i want to inject that code in my another application. So when i try this program in MS VisualStudio 6.0 I face the last mentioned problems. Can you compile and execute this project in the MS VisualStudio 6 ?

    Waiting for your reply

    Thanks alot

  6. #6
    Join Date
    Aug 2004
    Posts
    184

    Re: RPC Example from MSDN

    I spent some time looking at this today and did not come up with a solution. I tried various MIDL commandline options - had some luck with /app_config Hello.Acf to get the interfaces set - this got rid of the _hello_ServerIfHandle related error - you will have to change the function name to what ever the compiler creates - i.e. _hello_my_p_handle.

    I was not able to get rid of the C1189 error, but I did a lot of looking at things........

    From the Win32 API:
    BOOL DeleteFile()
    If the function succeeds, the return value is nonzero.
    If the function fails, the return value is zero.
    So based on this I take that BOOL TRUE is non zero and BOOL FALSE is zero

    From MSDN:
    When a postfix or prefix ++ operator is applied to a variable of type bool, the variable is set to true. The postfix or prefix -- operator cannot be applied to a variable of this type.

    The bool type participates in integral promotions. An r-value of type bool can be converted to an r-value of type int, with false becoming zero and true becoming one. As a distinct type, bool participates in overload resolution.
    So based on this I take that bool true can be a non zero value and bool false can be zero. Even though you should probably not use an integer to check for bool true or false - it can be done.

    In RpcNdr.h
    Code:
    #if (0x500 <= _WIN32_WINNT)
    #define TARGET_IS_NT50_OR_LATER                   1
    #else
    #define TARGET_IS_NT50_OR_LATER                   0
    #endif
    On an XP and Win2k box, this fails with fatal error C1189: #error : You need a Windows 2000 or later to run this stub because it uses these features:

    If you change RpcNdr.h to match the BOOL or bool definition above.
    Code:
    #if (0x500 <= _WIN32_WINNT)
    #define TARGET_IS_NT50_OR_LATER                   0 // 1
    #else
    #define TARGET_IS_NT50_OR_LATER                   1 // 0
    #endif
    On the same XP and Win2k box, the C1189 error goes away.

    The check in the _c file is
    Code:
    #if !(TARGET_IS_NT50_OR_LATER)
    What am I missing?
    Last edited by f1shrman; August 27th, 2004 at 07:32 PM. Reason: forgot to explain what error went away

  7. #7
    Join Date
    May 2003
    Location
    Islamabad, Pakistan
    Posts
    284

    Re: RPC Example from MSDN

    f1shrman
    Thank you very much
    that you spent time over it.
    I am trying my best to solve this issue. But if in the mean time you can get some solution please post it.
    Once again thankyou very much

  8. #8
    Join Date
    May 2003
    Location
    Islamabad, Pakistan
    Posts
    284

    Cool Re: RPC Example from MSDN

    I am able to comiple and execute the above project in visualstudio 6.

    Here are the steps
    1, Put the extension .mak to the makefile (makefile -> makefile.mak)
    2, Open it in the visualstudio (Create a project)
    3, Add the .h and .c/.cpp files
    4, Compile / Execute

  9. #9
    Join Date
    Aug 2010
    Posts
    1

    Cool Re: RPC Example from MSDN

    If you are still having troubles, try this; Put back everything as was and remove the rpcndr.lib from the link inputs in the p/s make file(*.mak,*.mk). This file(rpcndr.lib) is vestigal and is not needed any more to link with the SDK you probably have. Cheers.

  10. #10
    Join Date
    Oct 2006
    Location
    Sweden
    Posts
    3,654

    Re: RPC Example from MSDN

    Please note that this thread has been dead since 2004...
    Debugging is twice as hard as writing the code in the first place.
    Therefore, if you write the code as cleverly as possible, you are, by
    definition, not smart enough to debug it.
    - Brian W. Kernighan

    To enhance your chance's of getting an answer be sure to read
    http://www.codeguru.com/forum/announ...nouncementid=6
    and http://www.codeguru.com/forum/showthread.php?t=366302 before posting

    Refresh your memory on formatting tags here
    http://www.codeguru.com/forum/misc.php?do=bbcode

    Get your free MS compiler here
    https://visualstudio.microsoft.com/vs

  11. #11
    Join Date
    May 2003
    Location
    Islamabad, Pakistan
    Posts
    284

    Re: RPC Example from MSDN

    gcam1964,

    Thank you dear but some one could not wait that much for the issues.
    Time is money.

    Regards,
    If this post is helpful, then, Rate this Post.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  





Click Here to Expand Forum to Full Width

Featured