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
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.
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.
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
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 ?
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.
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
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
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.
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
* The Best Reasons to Target Windows 8
Learn some of the best reasons why you should seriously consider bringing your Android mobile development expertise to bear on the Windows 8 platform.