VC++ .NET> Release Build results LNK2001, LNK2019 and LNK1120

G

Guest

Hello Developers,
I use VC++ .NET v2003. By using Windows Forms .NET, I am developing an
application which will work with TCP/IP functions. I can Build my application
in Debug Mode normally, but, whenever I want to Build at Release Mode,
compiler gives LNK2001, LNK2019 ve LNK1120 errors. I read the MSDN documents,
unfortunately, I could not solve my problem. I am requesting your help.

All errors are below with my application name "TestFace_v2"

1)TestFace_v2 error LNK2001: unresolved external symbol "int __stdcall
closesocket(unsigned int)" (?closesocket@@$$J14YGHI@Z)

2)TestFace_v2 error LNK2001: unresolved external symbol "int __stdcall
connect(unsigned int,struct sockaddr const *,int)"
(?connect@@$$J212YGHIPBUsockaddr@@H@Z)

3)TestFace_v2 error LNK2001: unresolved external symbol "int __stdcall
recv(unsigned int,char *,int,int)" (?recv@@$$J216YGHIPADHH@Z)

4)TestFace_v2 error LNK2001: unresolved external symbol "int __stdcall
recv(unsigned int,char *,int,int)" (?recv@@$$J216YGHIPADHH@Z)

5)TestFace_v2 error LNK2001: unresolved external symbol "int __stdcall
send(unsigned int,char const *,int,int)" (?send@@$$J216YGHIPBDHH@Z)

6)TestFace_v2 error LNK2001: unresolved external symbol "int __stdcall
setsockopt(unsigned int,int,int,char const *,int)"
(?setsockopt@@$$J220YGHIHHPBDH@Z)

7)TestFace_v2 error LNK2001: unresolved external symbol "int __stdcall
WSAGetLastError(void)" (?WSAGetLastError@@$$J10YGHXZ)

8)TestFace_v2 error LNK2001: unresolved external symbol "int __stdcall
WSAStartup(unsigned short,struct WSAData *)"
(?WSAStartup@@$$J18YGHGPAUWSAData@@@Z)

9)TestFace_v2 error LNK2001: unresolved external symbol "unsigned int
__stdcall socket(int,int,int)" (?socket@@$$J212YGIHHH@Z)

10)TestFace_v2 error LNK2001: unresolved external symbol "unsigned long
__stdcall inet_addr(char const *)" (?inet_addr@@$$J14YGKPBD@Z)

11)TestFace_v2 error LNK2001: unresolved external symbol "unsigned short
__stdcall htons(unsigned short)" (?htons@@$$J14YGGG@Z)

12)TestFace_v2 error LNK2019: unresolved external symbol "int __stdcall
WSAGetLastError(void)" (?WSAGetLastError@@$$J10YGHXZ) referenced in function
"public: __clrcall
TestFace_v2::frmConnectionSettings::frmConnectionSettings(void)__gc "
(??0frmConnectionSettings@TestFace_v2@@$$FQ$AAM@XZ)

13)TestFace_v2 fatal error LNK1120: 10 unresolved externals
 
O

Oleg Starodumov

Is ws2_32.lib present in the list of import libraries in Release configuration?

(Project properties | Configuration Properties | Linker | Input | Additional Dependencies)

Regards,
Oleg
 
G

Guest

Hello,
Yes, "ws2_32.lib" is already in "Additional Dependencies" part where you
mentioned.

Best Regards,
Bil Muh
 
O

Oleg Starodumov

Yes, "ws2_32.lib" is already in "Additional Dependencies" part where you
mentioned.

Add /verbose:lib to the list of linker options. Then when linking, the list
of libraries searched will be displayed in Output window.

Will ws2_32.lib be present in that list, and in the correct location,
when you build the release configuration?

Regards,
Oleg
 
G

Guest

Can you kindly tell me exactly where to put /verbose::lib ? I am sorry, I
didnot understand it
 
O

Oleg Starodumov

Can you kindly tell me exactly where to put /verbose::lib ? I am sorry, I
didnot understand it

Project properties | Configuration Properties | Linker | Command Line |
Additional Options.

Regards,
Oleg
 
G

Guest

I have written /verbose::lib into that place before your answer.
Unfortunately, it still gives the LNK2001 error for all WinSock functions,
when I build in Release Mode.
 
O

Oleg Starodumov

I have written /verbose::lib into that place before your answer.
Unfortunately, it still gives the LNK2001 error for all WinSock functions,
when I build in Release Mode.

/verbose option does not affect the outcome of linking, it only provides
some troubleshooting output in build output window.
Please look at that window and see whether the linker was able to find ws2_32.lib.
Also compare the output with debug build, to see if there are differences.

Regards,
Oleg
 
G

Guest

I re-compile as you mentioned. Unfortunately, ws2_32.lib is not listed at
Release Build at the Output file. Also, I compare the Debug Output file and
Release output File. The only differenece is the lack of "ws2_32.lib" at
Release Build file.

Thank you in advance
Best Regards.
Alper
 
O

Oleg Starodumov

I re-compile as you mentioned. Unfortunately, ws2_32.lib is not listed at
Release Build at the Output file. Also, I compare the Debug Output file and
Release output File. The only differenece is the lack of "ws2_32.lib" at
Release Build file.

It means that ws2_32.lib is not specified in the list of import libraries.

Please check again Project Settings | Configuration Properties | Linker | Input |
Additional Dependencies, and make sure that ws2_32.lib is there.
Make sure that when you check it, Release is selected in Configuration listbox
at the top of the dialog page.

If it does not help, try to add ws2_32.lib to your project explicitly (in the same way
as you would add an ordinary source file).

Regards,
Oleg
 
G

Guest

I thank you very much. With your guidance, I solved the problem. The thing
that I did not noticed that is the "Configuration" combobox at the Project
Properties menu. When I was adding the "ws2_32.lib" to the Linker > Input >
Additional Dependencies, the "Configuration" combobox was setted to Debug.
Now, I added ws2_32.lib to all configurations.
I think that, when adding dependencies, it is better to add when the
"Configuration" combo-box is setted to "All Configurations"
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top