473,397 Members | 1,949 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,397 software developers and data experts.

Error C4439 'main' : function definition with a managed type in the signature must ha

Hi

I am a newbie to VC++ and this is my first independent project so please pardon my ignorance!!

My project compiles and runs perfectly fine in Debug mode.

However, when I try to compile it in Release mode ( I need this to use the Setup wizard for application Deployment) I get the following error:
error C4439: 'main' : function definition with a managed type in the signature must have a __clrcall calling convention
I am using the following parameters:

Calling Convention : _stdcall (/Gz)

Common Language Runtime Support (/clr)

I have also added the library file ole32.lib in the Additional Dependancies in the Project Property.

When I try to use :

Expand|Select|Wrap|Line Numbers
  1. int __clrcall main(array<System::String ^> ^args)
I get the following Link errors:
error LNK2001: unresolved external symbol "extern "C" void __stdcall HidD_GetHidGuid(struct _GUID *)" (?HidD_GetHidGuid@@$$J14YGXPAU_GUID@@@Z)

1>GUI.obj : error LNK2001: unresolved external symbol "extern "C" void * __stdcall SetupDiGetClassDevsA(struct _GUID const *,char const *,struct HWND__ *,unsigned long)" (?SetupDiGetClassDevsA@@$$J216YGPAXPBU_GUID@@PBDPA UHWND__@@K@Z)

1>GUI.obj : error LNK2001: unresolved external symbol "extern "C" int __stdcall SetupDiEnumDeviceInterfaces(void *,struct _SP_DEVINFO_DATA *,struct _GUID const *,unsigned long,struct _SP_DEVICE_INTERFACE_DATA *)" (?SetupDiEnumDeviceInterfaces@@$$J220YGHPAXPAU_SP_ DEVINFO_DATA@@PBU_GUID@@KPAU_SP_DEVICE_INTERFACE_D ATA@@@Z)

1>GUI.obj : error LNK2001: unresolved external symbol "extern "C" int __stdcall SetupDiGetDeviceInterfaceDetailA(void *,struct _SP_DEVICE_INTERFACE_DATA *,struct _SP_DEVICE_INTERFACE_DETAIL_DATA_A *,unsigned long,unsigned long *,struct _SP_DEVINFO_DATA *)" (?SetupDiGetDeviceInterfaceDetailA@@$$J224YGHPAXPA U_SP_DEVICE_INTERFACE_DATA@@PAU_SP_DEVICE_INTERFAC E_DETAIL_DATA_A@@KPAKPAU_SP_DEVINFO_DATA@@@Z)

1>GUI.obj : error LNK2001: unresolved external symbol "extern "C" unsigned char __stdcall HidD_GetAttributes(void *,struct _HIDD_ATTRIBUTES *)" (?HidD_GetAttributes@@$$J18YGEPAXPAU_HIDD_ATTRIBUT ES@@@Z)

1>GUI.obj : error LNK2001: unresolved external symbol "extern "C" int __stdcall SetupDiDestroyDeviceInfoList(void *)" (?SetupDiDestroyDeviceInfoList@@$$J14YGHPAX@Z)

1>GUI.obj : error LNK2001: unresolved external symbol "extern "C" unsigned char __stdcall HidD_SetOutputReport(void *,void *,unsigned long)" (?HidD_SetOutputReport@@$$J212YGEPAX0K@Z)

1>GUI.obj : error LNK2001: unresolved external symbol "extern "C" unsigned char __stdcall HidD_GetInputReport(void *,void *,unsigned long)" (?HidD_GetInputReport@@$$J212YGEPAX0K@Z)

1>GUI.obj : error LNK2001: unresolved external symbol "extern "C" long __stdcall UuidCreate(struct _GUID *)" (?UuidCreate@@$$J14YGJPAU_GUID@@@Z)

1>GUI.obj : error LNK2001: unresolved external symbol "extern "C" long __stdcall UuidToStringA(struct _GUID const *,unsigned char * *)" (?UuidToStringA@@$$J18YGJPBU_GUID@@PAPAE@Z)

1>GUI.obj : error LNK2001: unresolved external symbol "extern "C" long __stdcall RpcStringFreeA(unsigned char * *)" (?RpcStringFreeA@@$$J14YGJPAPAE@Z)

1>C:\Documents and Settings\bandu\My Documents\Visual Studio 2008\Projects\13th July - TES GUI wshid\GUI\Release\GUI.exe : fatal error LNK1120: 11 unresolved externals
Please Help!!

Soorali
Jul 20 '10 #1
6 5324
Banfa
9,065 Expert Mod 8TB
Are you are are you not using .NET?

Does your project require it?
Jul 20 '10 #2
Banfa
9,065 Expert Mod 8TB
I have made a GUI using the Windows Form Application. On button clicks on the GUI the program sends messages via USB to a connected device. Also one of the button connects this device to Skype and interacts with it.

Since I am using the windows Form application I THINK (in the limited knowledge I have) that I would need a .Net environment to run the .exe file.

Please feel free to correct me if I am wrong.
No you do not need to use .NET to create Windows programs, you can call the WIN32 API directly.

I asked because your errors look like they may be being produced by a clash between .NET and non-.NET code.

However I am not an expert on that.
Jul 21 '10 #3
Hi Banfa,

Thanks for your response.

I have checked my project properties and am using the Win32 API.

Do you have any idea what could be causing this??

Regards,
Soorali
Jul 21 '10 #4
Banfa
9,065 Expert Mod 8TB
This

Expand|Select|Wrap|Line Numbers
  1. int __clrcall main(array<System::String ^> ^args)
  2.  
is the managed code version of main, you should be using either

Expand|Select|Wrap|Line Numbers
  1. int main(int argc, char* argp[])
  2.  
Or its Microsoft equivalent wide character version

Expand|Select|Wrap|Line Numbers
  1. int wmain( int argc , wchar_t *argv[]);
  2.  
Or its Microsoft equivalent that automatically selects the single or wide character version

Expand|Select|Wrap|Line Numbers
  1. int _tmain(int argc, _TCHAR* argv[])
  2.  
Using this prototype automatically selects the correct version of the previous 2.


Another alternative is

Expand|Select|Wrap|Line Numbers
  1. int WINAPI _tWinMain(HINSTANCE hInstance,
  2.     HINSTANCE hPrevInstance,
  3.     LPTSTR lpCmdLine,
  4.     int nCmdShow)
  5.  
This is the Windows entry point again the _t indicating that it automatically switches between single byte and multibyte characters. You should be using this if you are compiling as a Windows application as opposed to a console application.
Jul 21 '10 #5
johny10151981
1,059 1GB
Hi,
This answer is obsolet now :)
cause I didnt notice Banfa described it well :)



Hi,
Your main function definition says, its not a GUI program
you are doing console application.
in console application you can define main like this
Expand|Select|Wrap|Line Numbers
  1. int main(int argc, char *argv[]);
  2.  
But if this is a graphical user interface the definition is different
Expand|Select|Wrap|Line Numbers
  1. int __stdcall WinMain(HINSTANCE hPrevInstance,
  2.                      LPTSTR    lpCmdLine,
  3.                      int       nCmdShow)
or
Expand|Select|Wrap|Line Numbers
  1. int APIENTRY _tWinMain(HINSTANCE hInstance,
  2.                      HINSTANCE hPrevInstance,
  3.                      LPTSTR    lpCmdLine,
  4.                      int       nCmdShow)
infact APIENTRY,WINAPI and __stdcall are all same
Expand|Select|Wrap|Line Numbers
  1. #define WINAPI __stdcall 
  2. #define APIENTRY WINAPI
  3.  
and
Expand|Select|Wrap|Line Numbers
  1. #define _tWinMain wWinMain
  2.  
wWinMain is widecharcter version of WinMain

Let me know if my above information is wrong

Johny
Jul 21 '10 #6
Hi Banfa/ Johny,

Thank you for replying to my post.

It finally works!!!

This is what I did:

Changed the call to the main routine to :

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

It did not seem to like the _stdcall before main.


Got the usual 12 Link errors with the __clrcall. Then realised the lib files were missing from the Additional Dependancies from the Project Properties. Included those and after a few hiccups it finally works!!!

One thing I am a bit confused by....in the Project Properties it says I am using the .Net Framework but on a Win32 platform....is that why I need the __clrcall before the main???

Let me know your thoughts please.

Cheers
Soorali
Jul 22 '10 #7

Sign in to post your reply or Sign up for a free account.

Similar topics

0
by: Stefan | last post by:
Hi, Could anyone share some light on this and how I can work around it. If I have 2 managed c++ dlls (A and B) and B tries to use a native class in A this fails to link. It is easily...
1
by: Ghost | last post by:
Hi all, I wrote a program in C# and now I have to "translate" it i visual C++ (MFC) using .NET, but I had a little problem: *ERRORS* error C3181: 'CTestDlg' : invalid operand for __typeof,...
4
by: octavio | last post by:
Hello members of the comp.lang.c newsgroup. Please I need you help on the following one. Compiling the simple code I'm getting this error message. Why ? Please what's the correct type of the fb...
2
by: andy6 via DotNetMonster.com | last post by:
I took a c++ 6.0 project and converted it to c++ .net 2005 project. I want to make a web service out of it. One of the new files I created was a cpp where I have the webmethod pointing to a...
11
by: briankirkpatrick | last post by:
Forgive me if my post seems a little amateurish... I'm requesting assistance from some of you smart folks out there to get the managed calls write that meet the specification in the esa.h for...
0
by: MarukoS | last post by:
I am converting a MFC solution from VS2003 to VS2005. And I got the following error: error C3821: 'System::Xml::XmlDocument *': managed type or function cannot be used in an unmanaged function I...
1
by: =?Utf-8?B?RGlwZXNoX1NoYXJtYQ==?= | last post by:
Hi all, I am porting an code written in VC++ to VC.Net to make it manage. I am getting one error as:: error C4439: 'function_name' : function definition with a managed type in the signature must...
11
by: aarklon | last post by:
Hi all, I have heard many discussions among my colleagues that main is a user defined function or not. arguments in favour:- 1) if it is built in function it must be defined in some header...
9
by: Denny | last post by:
When I compiled this C source, a C compiler spat out a message which was "Declaration syntax error in function main()". I am having tested function pointer example program. Of course, I am a...
9
by: Yannick | last post by:
Hi everyone - I am not quite sure to understand what is really going on when a function defined in one translation unit calls a function defined in a different translation unit without knowing...
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.