• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 2088
  • Last Modified:

Link Error - error LNK2019: unresolved external symbol - C/C++

remoteSide.cpp includes header called "ConnectToClient.h".

ConnectToClient resides in a header files folder for a different project. Therefore my remoteSide.cpp includes the header as follows:

#include "C:\Users\Admin\Desktop\X-Shab\X-Shab\ConnectToClient.h"

I still get linking error, whether i include the absolute path or not. What can i do? AFAIK, it got to do with additional dependencies or so. Can you explain well - if you don't mind.

Thanks
1>Copyright (C) Microsoft Corporation.  All rights reserved.
1>Linking...
1>remoteSide.obj : error LNK2019: unresolved external symbol "public: __thiscall ConnectToClient::~ConnectToClient(void)" (??1ConnectToClient@@QAE@XZ) referenced in function _main
1>remoteSide.obj : error LNK2019: unresolved external symbol "public: __thiscall ConnectToClient::ConnectToClient(char const *,char const *)" (??0ConnectToClient@@QAE@PBD0@Z) referenced in function _main
1>C:\Users\Admin\Desktop\X-Shab\Debug\RemoteSide.exe : fatal error LNK1120: 2 unresolved externals
1>Build log was saved at "file://c:\Users\Admin\Desktop\X-Shab\RemoteSide\Debug\BuildLog.htm"
1>RemoteSide - 3 error(s), 0 warning(s)
2>ConsoleDesign.cpp

Open in new window

0
F-J-K
Asked:
F-J-K
  • 8
  • 6
2 Solutions
 
josgoodCommented:
The other project should contain a ConnectToClient.lib, or a library of another name that includes ConnectToClient.

Add that library to the list of libraries included in the project.  If you need instructions on how to do that, please say what version of Visual Studio you're using.
0
 
F-J-KAuthor Commented:
The other project has ConnectToClient.h in the Header Files folder & ConnectToClient.cpp in Source Files folder - i did not put ConnectToClient in any library, nor i made it standard.

If you can give the instructions, i will appreciate it. I'm using Visual Studio 2008
0
 
josgoodCommented:
I guess I need to clarify...

1)  Are you including ConnectToClient.cpp in your project?
2)  If not, what does the other project create -- an .exe? a dll? a lib?
3)  Does ConnectToClient define two constructors -- one taking no arguments and the other taking two char const *?
0
Introducing Cloud Class® training courses

Tech changes fast. You can learn faster. That’s why we’re bringing professional training courses to Experts Exchange. With a subscription, you can access all the Cloud Class® courses to expand your education, prep for certifications, and get top-notch instructions.

 
F-J-KAuthor Commented:
1. no
2. .exe
3. yes
0
 
josgoodCommented:
If the other project created a .lib, then we could use that .lib and statically link it in.  However, it is creating an exe, so that's out.

I see two choices:
1)  Use CreateProcess (for example) to spawn another process that runs ConnectToClient.exe, passing the necessary command line arguments.  This assumes that ConnectToClient accepts command line arguments.
2)  Include ConnectToClient.cpp in your project, along with any headers and cpp files that it needs in order to build.

If you pick the second, then you'll have to include any inclusion paths and linkage paths the ConnectToClient project uses.  This isn't difficult, just a bit of a pain.

I suggest the second approach, unless it starts to balloon in effort -- needing to include all sorts of other cpp files and headers and the like.
0
 
F-J-KAuthor Commented:
1. Yes including it in the header such as #include "C:\Users\Admin\Desktop\X-Shab\X-Shab\ConnectToClient.h", but not including the file the .h & .cpp into my remoteSide project.
0
 
F-J-KAuthor Commented:
no sorry, ConnectToClient.cpp does not have main(). It does not produce ConnectToClient.exe
0
 
josgoodCommented:
If you open the other project, open the solution window, right-click the solution, click properties, and look in the application tab, you'll see "Output type".  That should be Windows application, console application, or class library.

If it is class library, then the project emits a .lib that we can use.
0
 
F-J-KAuthor Commented:
can you tell me how to make my headers as standard in VS 2008, not VC++.
Thanks
0
 
josgoodCommented:
To define a folder containing headers for a project,
1)  Right-click the project in solution explorer
2)  Select properties
3)  Select Configuration Properties | C/C++ | General
4)  The top line in the right-hand pane is "Additional Include Directories" and contains all additional folders in which VS 2008 will look for headers.  If you click on "Additional Include Directories", a 3-dot (ellipsis) button will appear.  Click that button and a popup window will open that lets you add directories.
0
 
F-J-KAuthor Commented:
Ok, i did it. I went to this folder ""C:\Users\Admin\Desktop\X-Shab\X-Shab" which contains all .h & its .cpp
such as ConnectToClient.h, ConnectToClient.cpp, MainMenus.h, MainMenus.cpp,etc. When i get into the folder, the file browser does not show any of file inside the folder X-Shab. Thus, this path "C:\Users\Admin\Desktop\X-Shab\X-Shab" does not help when its added into is "Additional Include Directories". Anyhow, i added it there & change mt include format from #include "ConnectToClient.h" to #include <ConnectToClient.h>. I get this error  fatal error C1083: Cannot open include file: 'ConnectToClient.h': No such file or directory

0
 
josgoodCommented:
>>the file browser does not show any of file inside the folder X-Shab.  Thus this path...does not help
The path C:\Users\Admin\Desktop\X-Shab makes me think there are multiple users for this PC, and that X-Shab is another user who is keeping these files on his desktop.  (I'm not sure of myself here, but at least this theory fits the observed facts).  If I'm right, then you'll need to ask X-Shab for a copy of these files and then place them in a folder that is accessible to you.

Then you should be able to update the include path to point to the new folder rather than X-Shab's folder.

I hope this helps.  It's time for me to go sleep.  I'll be happy to help some more tomorrow.

If my guess on the X-Shab path is wrong, please let me know.

Joe
0
 
F-J-KAuthor Commented:
This helped. I will check out & i hope it works. Thanks
0
 
F-J-KAuthor Commented:
Thank you
0
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

Join & Write a Comment

Featured Post

Cloud Class® Course: C++ 11 Fundamentals

This course will introduce you to C++ 11 and teach you about syntax fundamentals.

  • 8
  • 6
Tackle projects and never again get stuck behind a technical roadblock.
Join Now