[Last Call] Learn how to a build a cloud-first strategyRegister Now

x
?
Solved

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

Posted on 2009-02-12
14
Medium Priority
?
1,872 Views
Last Modified: 2012-05-06
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
Comment
Question by:F-J-K
  • 8
  • 6
14 Comments
 
LVL 13

Expert Comment

by:josgood
ID: 23629759
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
 
LVL 1

Author Comment

by:F-J-K
ID: 23629877
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
 
LVL 13

Expert Comment

by:josgood
ID: 23629886
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
VIDEO: THE CONCERTO CLOUD FOR HEALTHCARE

Modern healthcare requires a modern cloud. View this brief video to understand how the Concerto Cloud for Healthcare can help your organization.

 
LVL 1

Author Comment

by:F-J-K
ID: 23629935
1. no
2. .exe
3. yes
0
 
LVL 13

Expert Comment

by:josgood
ID: 23630012
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
 
LVL 1

Author Comment

by:F-J-K
ID: 23630019
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
 
LVL 1

Author Comment

by:F-J-K
ID: 23630025
no sorry, ConnectToClient.cpp does not have main(). It does not produce ConnectToClient.exe
0
 
LVL 13

Expert Comment

by:josgood
ID: 23630128
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
 
LVL 1

Author Comment

by:F-J-K
ID: 23630160
can you tell me how to make my headers as standard in VS 2008, not VC++.
Thanks
0
 
LVL 13

Accepted Solution

by:
josgood earned 2000 total points
ID: 23630179
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
 
LVL 1

Author Comment

by:F-J-K
ID: 23630245
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
 
LVL 13

Assisted Solution

by:josgood
josgood earned 2000 total points
ID: 23630275
>>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
 
LVL 1

Author Closing Comment

by:F-J-K
ID: 31546428
This helped. I will check out & i hope it works. Thanks
0
 
LVL 1

Author Comment

by:F-J-K
ID: 23630315
Thank you
0

Featured Post

Independent Software Vendors: We Want Your Opinion

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

What do responsible coders do? They don't take detrimental shortcuts. They do take reasonable security precautions, create important automation, implement sufficient logging, fix things they break, and care about users.
When you discover the power of the R programming language, you are going to wonder how you ever lived without it! Learn why the language merits a place in your programming arsenal.
With the power of JIRA, there's an unlimited number of ways you can customize it, use it and benefit from it. With that in mind, there's bound to be things that I wasn't able to cover in this course. With this summary we'll look at some places to go…
Simple Linear Regression

831 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question