Problems in Visual C++ 2008

Hi,

I have a little but very annoying problem.

When I try to build my program I get linker problems:

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
1
1>Compiling...
1>Transfer_pliku_VC++.cpp
1>Linking...
1>Transfer_pliku_VC++.obj : error LNK2028: unresolved token (0A000044) "public: static void __clrcall WComm::closeConnection(void)" (?closeConnection@WComm@@$$FSMXXZ) referenced in function "private: void __clrcall Transfer_pliku_VC::Form1::ThreadTask(void)" (?ThreadTask@Form1@Transfer_pliku_VC@@$$FA$AAMXXZ)
1>Transfer_pliku_VC++.obj : error LNK2028: unresolved token (0A000046) "public: void __clrcall WComm::fileReceive(char *)" (?fileReceive@WComm@@$$FQAMXPAD@Z) referenced in function "private: void __clrcall Transfer_pliku_VC::Form1::ThreadTask(void)" (?ThreadTask@Form1@Transfer_pliku_VC@@$$FA$AAMXXZ)
1>Transfer_pliku_VC++.obj : error LNK2028: unresolved token (0A000048) "public: int __clrcall WComm::sendData(char *)" (?sendData@WComm@@$$FQAMHPAD@Z) referenced in function "private: void __clrcall Transfer_pliku_VC::Form1::ThreadTask(void)" (?ThreadTask@Form1@Transfer_pliku_VC@@$$FA$AAMXXZ)
1>Transfer_pliku_VC++.obj : error LNK2028: unresolved token (0A000049) "public: int __clrcall WComm::recvData(char *,int)" (?recvData@WComm@@$$FQAMHPADH@Z) referenced in function "private: void __clrcall Transfer_pliku_VC::Form1::ThreadTask(void)" (?ThreadTask@Form1@Transfer_pliku_VC@@$$FA$AAMXXZ)
1>Transfer_pliku_VC++.obj : error LNK2028: unresolved token (0A00004A) "public: void __clrcall WComm::waitForClient(void)" (?waitForClient@WComm@@$$FQAMXXZ) referenced in function "private: void __clrcall Transfer_pliku_VC::Form1::ThreadTask(void)" (?ThreadTask@Form1@Transfer_pliku_VC@@$$FA$AAMXXZ)
1>Transfer_pliku_VC++.obj : error LNK2028: unresolved token (0A00004B) "public: void __clrcall WComm::startServer(int)" (?startServer@WComm@@$$FQAMXH@Z) referenced in function "private: void __clrcall Transfer_pliku_VC::Form1::ThreadTask(void)" (?ThreadTask@Form1@Transfer_pliku_VC@@$$FA$AAMXXZ)
1>Transfer_pliku_VC++.obj : error LNK2028: unresolved token (0A00004C) "public: __clrcall WComm::WComm(void)" (??0WComm@@$$FQAM@XZ) referenced in function "private: void __clrcall Transfer_pliku_VC::Form1::ThreadTask(void)" (?ThreadTask@Form1@Transfer_pliku_VC@@$$FA$AAMXXZ)
1>Transfer_pliku_VC++.obj : error LNK2019: unresolved external symbol "public: static void __clrcall WComm::closeConnection(void)" (?closeConnection@WComm@@$$FSMXXZ) referenced in function "private: void __clrcall Transfer_pliku_VC::Form1::ThreadTask(void)" (?ThreadTask@Form1@Transfer_pliku_VC@@$$FA$AAMXXZ)
1>Transfer_pliku_VC++.obj : error LNK2019: unresolved external symbol "public: void __clrcall WComm::fileReceive(char *)" (?fileReceive@WComm@@$$FQAMXPAD@Z) referenced in function "private: void __clrcall Transfer_pliku_VC::Form1::ThreadTask(void)" (?ThreadTask@Form1@Transfer_pliku_VC@@$$FA$AAMXXZ)
1>Transfer_pliku_VC++.obj : error LNK2019: unresolved external symbol "public: int __clrcall WComm::sendData(char *)" (?sendData@WComm@@$$FQAMHPAD@Z) referenced in function "private: void __clrcall Transfer_pliku_VC::Form1::ThreadTask(void)" (?ThreadTask@Form1@Transfer_pliku_VC@@$$FA$AAMXXZ)
1>Transfer_pliku_VC++.obj : error LNK2019: unresolved external symbol "public: int __clrcall WComm::recvData(char *,int)" (?recvData@WComm@@$$FQAMHPADH@Z) referenced in function "private: void __clrcall Transfer_pliku_VC::Form1::ThreadTask(void)" (?ThreadTask@Form1@Transfer_pliku_VC@@$$FA$AAMXXZ)
1>Transfer_pliku_VC++.obj : error LNK2019: unresolved external symbol "public: void __clrcall WComm::waitForClient(void)" (?waitForClient@WComm@@$$FQAMXXZ) referenced in function "private: void __clrcall Transfer_pliku_VC::Form1::ThreadTask(void)" (?ThreadTask@Form1@Transfer_pliku_VC@@$$FA$AAMXXZ)
1>Transfer_pliku_VC++.obj : error LNK2019: unresolved external symbol "public: void __clrcall WComm::startServer(int)" (?startServer@WComm@@$$FQAMXH@Z) referenced in function "private: void __clrcall Transfer_pliku_VC::Form1::ThreadTask(void)" (?ThreadTask@Form1@Transfer_pliku_VC@@$$FA$AAMXXZ)
1>Transfer_pliku_VC++.obj : error LNK2019: unresolved external symbol "public: __clrcall WComm::WComm(void)" (??0WComm@@$$FQAM@XZ) referenced in function "private: void __clrcall Transfer_pliku_VC::Form1::ThreadTask(void)" (?ThreadTask@Form1@Transfer_pliku_VC@@$$FA$AAMXXZ)
1>H:\MOJE ALGORYTMY\Transfer_pliku_VC++\Transfer_pliku_VC++\Debug\Transfer_pliku_VC++.exe : fatal error LNK1120: 14 unresolved externals
1>Build log was saved at "file://h:\MOJE ALGORYTMY\Transfer_pliku_VC++\Transfer_pliku_VC++\Transfer_pliku_VC++\Debug\BuildLog.htm"
1>Transfer_pliku_VC++ - 15 error(s), 0 warning(s)
========== Build: 0 succeeded, 1 failed, 0 up-to-date, 0 skipped ==========


A word of explain: WComm is a .h and .cpp include which has functions mentioned above.

My code is taken from the following website:

http://www.codeproject.com/Articles/13673/C-Winsock-Client-To-Server-File-Transfer-Made-Easy

My Form1.h file is here: http://pastebin.com/6Y1yqaHc

Maybe I'm doing something wrong (for example not in .h file but other...

If you want me to paste other files, please tell me about it.

Please help me as I have to complete this project before 6 A.M, 17.1.2013
Last edited on
Have you added WComm.cpp to your project?
I tried to add WComm.h, (View->Solution Explorer-> WComm.h; had a red icon with "-" mark; .cpp was already added - there was no red icon next to this) but after this I got:

1
2
3
4
5
6
7
8
1
1>Compiling...
1>wcomm.cpp
1>.\wcomm.cpp(1) : warning C4627: '#include "wcomm.h"': skipped when looking for precompiled header use
1>        Add directive to 'stdafx.h' or rebuild precompiled header
1>.\wcomm.cpp(226) : fatal error C1010: unexpected end of file while looking for precompiled header. Did you forget to add '#include "stdafx.h"' to your source?
1>Build log was saved at "file://h:\MOJE ALGORYTMY\Transfer_pliku_VC++\Transfer_pliku_VC++\Transfer_pliku_VC++\Debug\BuildLog.htm"
1>Transfer_pliku_VC++ - 1 error(s), 1 warning(s)
========== Build: 0 succeeded, 1 failed, 0 up-to-date, 0 skipped ==========


EDIT:

As for now, I managed to solve this problem by including stdafx.h and including WComm.h in it. There were a few warnings about other functions but program is actually running. Thank you ;)
Last edited on
I don't want to start a new thread. I have another problem with my program.

I want to create a server-client file-transfer program. Server and client have to be written in one program, so I decided to use threads.

Here is the problem:

My function is in external .cpp and .h file (WComm.h).

I tried to run this function with program start but I have problems here:

1
2
3
4
5
6
7
8
1
1>Compiling...
1>Transfer_pliku_VC++.cpp
1>h:\moje algorytmy\transfer_pliku_vc++\transfer_pliku_vc++\transfer_pliku_vc++\Form1.h(199) : error C2664: 'pthread_create' : cannot convert parameter 3 from 'void *(__clrcall WComm::* )(void)' to 'void *(__cdecl *)(void *)'
1>        There is no context in which this conversion is possible
1>Build log was saved at "file://h:\MOJE ALGORYTMY\Transfer_pliku_VC++\Transfer_pliku_VC++\Transfer_pliku_VC++\Debug\BuildLog.htm"
1>Transfer_pliku_VC++ - 1 error(s), 0 warning(s)
========== Build: 0 succeeded, 1 failed, 0 up-to-date, 0 skipped ==========


Code which is supposed to run this function in a new thread:

1
2
3
4
5
6
7
private: System::Void Form1_Shown(System::Object^  sender, System::EventArgs^  e) {
			 //WComm::runserver();
			 WComm *w = new WComm();
			 pthread_t server_thread;
			 pthread_create(&server_thread, NULL, &WComm::runserver, NULL);
			 //_beginthread( Form1::runserver, 0, (void*)0 );
		 }


Function:

<WComm.cpp>

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
void *WComm::runserver()
{
	WComm *w = new WComm();
	w->startServer(27015);
	while (true) {
	// Wait until a client connects
		w->waitForClient();

		// Work with client
		while(true)
		{
			char rec[50] = "";
			w->recvData(rec,32);w->sendData("OK");

			if(strcmp(rec,"FileSend")==0)
			{
				char fname[32] ="";
				w->fileReceive(fname);
				printf("File Received.........\n");
			}

			if(strcmp(rec,"EndConnection")==0)break;
			printf("Connection Ended......\n");
			}
		// Disconnect client
		w->closeConnection();
	}
}


<WComm.h>

void *runserver();

As you can see, I also tried to use another way to create a new thread, but also failed:

1
2
3
4
5
6
1
1>Compiling...
1>Transfer_pliku_VC++.cpp
1>h:\moje algorytmy\transfer_pliku_vc++\transfer_pliku_vc++\transfer_pliku_vc++\Form1.h(200) : error C3867: 'WComm::runserver': function call missing argument list; use '&WComm::runserver' to create a pointer to member
1>Build log was saved at "file://h:\MOJE ALGORYTMY\Transfer_pliku_VC++\Transfer_pliku_VC++\Transfer_pliku_VC++\Debug\BuildLog.htm"
1>Transfer_pliku_VC++ - 1 error(s), 0 warning(s)
========== Build: 0 succeeded, 1 failed, 0 up-to-date, 0 skipped ==========


I just smell that I have a little but very annoying bug in my code...
Come here, you little bastard... I will not kill you ;]
I tried to run this function with program start but I have problems here:
if runserver() is a non static member function then it doesn't work. Make the function static
Topic archived. No new replies allowed.