I have an old project that I need to revisit. It was built in some version of Visual C++ (prolly 2005) looking at the .sln file. The sln file wont get converted to a VS 2008 solution due to some corruption (dubug point -1). I imported the folder in VS as a new project and tried compiling.
It gave compilation errors for "lang/Typedefs.h/Assertions.h" not there. Removing the declarations I had errors for Uint8/16/32/64 not declared. So I added the typedefs and other macros (TOOLS_UNUSED_PARAMETERS(x) / TOOLS_FORBID_COPY()).
That being ironed out, I got errors for Gui/FileDlg.h and Gui/FolderDlg.h(debug point - 2).
I didnt find any of those header files from any resources online or in my current VS installation and so I am assuming that code is missing and I will have to redo it.
Even these could probably have been custom implemented by the earlier programmer. The current MFC uses CFileDialog and the code uses Gui::FileDlg.
I commented out the code for the time being to see where can I get to since gui is not that big a part of the application. Later I see linker errors corresponding to RegKeyOpenEx calls and outputstream calls(dubug point -3). Winreg.h was not included but windows.h was.
sample :
Error 2 error LNK2019: unresolved external symbol __imp__MessageBoxA#16
referenced in function "public: class std::basic_ostream<char,struct
std::char_traits<char> > * __thiscall FileManager::getOutputStream(class Interface
*,class LogPoint *)" (?getOutputStream#FileManager##QAEPAV?$basic_ostream#DU?
$char_traits#D#std###std##PAVInterface##PAVLogPoint###Z) filemanager.obj
PCAPGenerator
I am not a .Net programmer so can you please suggest what would be the right course of action here ?
which debug points should i be focussing on.
RegKeyOpenEx is a Winapi function defined in Advapi32.dll. To link that into a Visual C++ project:
If your project is a static library (right-click project->Properties->Configuration Properties->Configuration Type->Static Library (.lib), go to Configuration Properties->Librarian->General->Additional Dependencies and add Advapi32.lib.
If your project is a dll (same place, says Dynamic Library (.dll) instead), you'll have the Linker section instead of Librarian. Go to its Input subsection, and add Advapi32.lib to Additional Dependencies.
For your remaining linker errors, proceed in the same way: go to the MSDN doc for the function, check which dll/lib it belongs to and have your project link it in as described above.
Related
I have tried to find an answer for this for hours, and hours, and hours. This is frickin exhausting. In visual studio I keep having these library issues with DirectX and I think I have narrowed it down to a point where it is almost, almost solvable.
The error at compiling is in the title, here are images of some of my code and the dependencies and such:
Usually Unresolved External Symbol is thrown if you are using a function defined in a header, in your case I think d3d9.h, but you haven't linked the containing implementation lib. Right click on your project name under solution explorer and than Properties->Configuration Properties->Linker->Input, now on Additional Dependencies add your lib that I suppose it will be d3d9.lib or d3dx9.lib!
Recently we did some big architectural changes (i.e. mutlithreading support) to our cloud print module. Now I have to run a PreFast check on it, but because the current edition of Visual Studio 2008 that we are using does not have integrated PreFast check support, I have to do it through Windows DDK.
I am trying to build the source with WDK, but I am getting this error.
error LNK2005: "void _cdecl operator delete(void *)" (?3#YAXPAX#Z)
already defined in libcmt.lib (delete.obj)
I believe that the linker used libcpmt.lib at a prior stage and it had the same definition for delete method. The source also has c files and cpp files mixed at different module levels. Could this be the real reason why it is using both libcmp.lib and libcpmt.lib in the first place?
Is there anyway i can fix this? I don't really need a "right" way. All i want is to build the source, so that i can run PreFast check (not really concerned about link related warnings). If it gives any PreFast warning regarding this, i can skip it for the time being.
I'm currently trying to learn WinSock coding from http://johnnie.jerrata.com/winsocktutorial/ however when I compile my listening socket, I get 9 error LNK2019: unresolved external symbol errors. They all look to be the same function names that are used in the code prefixed with an underscore after the function name it says referenced in function _WinMain#16
This also happens when I run the code example that is available for download, so I don't think I've made a mistake.
What is an unresolved external and how do I go about fixing one? I can post the code if needed but it's all visibile on that link. I'm using Visual Studios 2010, Win32 project.
Unresolved external is linker error, telling you that you didn't link symbols you are getting those unresolved externals to into the binary.
Quoting from the site you linked:
Feel free to download the entire tutorial code listing. Remember that any code presented in this tutorial should be linked with the Winsock library, usually wsock32.lib or something similarly named. Also, when using code exactly as presented in the tutorial in your own IDE (Dev-C++, Microsoft VC++, C++ Builder, etc.), choose to build a Windows project with a WinMain() to avoid errors.
One of ways to link it is:
#pragma comment(lib, "wsock32.lib")
Also, consider using Boost.Asio instead of raw WinSock.
I am getting some linking errors during the compilation of C project in Microsoft Visual Studio 2010.I am getting the following errors:
error LNK2019: unresolved external symbol _CreateRelation referenced in function _main
The CreateRelation is one of the functions in my project. Following are my questions:
I think it is some dependencies problem.How would I set those dependencies rule in the IDE?
could you please tell me, is it always possible to build a project and set the linking rule, how much it is larger, without using makefile?
[EDIT]
relation.h
void createRelation(LIST);
mainfile.c
#include relation.h
#include xyz.h
.
.
.
int main(){
LIST Relation1;
some codes //
createRelation(Relation1);
some code //
}
The function creatRelation() is defined in the realation.h.
EDIT 2
In the function containing main
There are a few ways to set the dependencies for the build process.
If the code you are referencing is in a sub-project you can simply tell VS the build-dependencies. You do that by right-clicking on the project and select project dependencies. Then you can check all projects that should be built before this project is being built.
Another nifty feature of VS2010 are Property Sheets. In older versions of VS you had to tell the compiler the include path and the lib-path for every project. Now you can create property sheets for every library you are using and then simply adding them to your project. This way you only have to create a property sheet once and can use it in many projects.
So if the code is in another project that is not a sub-project you have to set the lib-path and include-path via those property sheets. You can display the property sheets used by your project by clicking View->Additional Windows->Property Manager
If you are not referencing to any external projects. This problem is most likely caused by you not implementing a function you declared. So the compiler knows about the function-prototype and doesn't complain but the linker can't find an implementation of the symbol.
I hope that helps
-- edit --
Since you said that the implementation is in the same file as the main-function I would suspect that the signature of the declared and defined function do not match. Are you getting any warnings about implicit function declaration?
Is that a copy-paste error?
CreateRealtion(x); vs. CreateRelation(x);
This question has been brought up numerous times, but Visual Studio never ceases to challenge me.
We have an application that should be self-sufficient, i.e. not depend on any 3rd party libraries. This is why we build everything statically using the MT(d) code generation flags.
The app depends on Qt, zlib, OpenSSL and DCMTK. All of these libraries were built as static libs with MT(d). The app also uses some MFC-related code, so we also have to link against it.
MFC is included via
#include <afxwin.h>
I read somewhere that this should be the first include in every file, but I'm not sure if it is true. Anyway, the line is not included in every file, only one file includes it.
Here are the link-related errors:
Error 24 error LNK2005: "void __cdecl operator delete[](void *)" (??_V#YAXPAX#Z) already defined in LIBCMTD.lib(delete2.obj) uafxcwd.lib
Error 22 error LNK2005: "void __cdecl operator delete(void *)" (??3#YAXPAX#Z) already defined in LIBCMTD.lib(dbgdel.obj) uafxcwd.lib
Error 23 error LNK2005: "void * __cdecl operator new[](unsigned int)" (??_U#YAPAXI#Z) already defined in libcpmtd.lib(newaop.obj) uafxcwd.lib
Error 21 error LNK2005: "void * __cdecl operator new(unsigned int)" (??2#YAPAXI#Z) already defined in LIBCMTD.lib(new.obj) uafxcwd.lib
Here is the linker output.
I read many threads on many sites as well as this article from MSDN's KB. But they don't help me, as all of them keep saying that MFC libs should be linked before CRT, but I cannot find a way to alter the linking order.
Any help is greatly appreciated.
Edit 1:
Using the trick from this thread actually solves the problem, but I still want to know what's wrong here.
Edit 2:
Using Visual Studio 2008 SP1, on Windows 7 and Qt 4.6.3
The problem is clear: you are compiling CRT and MFC code together.
When you use the MFC libraries, you
must make sure that they are linked
before the CRT library is linked. You
can do this by making sure that every
file in your project includes
Msdev\Mfc\Include\Afx.h first, either
directly (#include ) or
indirectly (#include ). The
Afx.h include file forces the correct
order of the libraries, by using the directive:
#pragma comment (lib,"<libname>")
Microsoft has an article (link now gone, but check here) describing this problem and suggests 2 solutions step-by-step (the following steps are based on Visual C++ 6.0):
Solution One: Force Linker to Link Libraries in Correct Order
On the Project menu, click Settings.
In the Settings For view of the Project Settings dialog box, click to select the project configuration that is getting the link errors.
On the Link tab, click to select Input in the Category combo box.
In the Ignore libraries box, insert the library names (for example, Nafxcwd.lib;Libcmtd.lib).
Note: The linker command-line equivalent in /NOD:<library name>.
In the Object/library modules (VS2008: Properties->Configuration Properties->Linker->Input->Additional Dependencies)box, insert the library names. You must make sure that these are listed in order and as the first two libraries in the line (for example, Nafxcwd.lib Libcmtd.lib).
Solution Two: Locate and Correct the Problem Module
To view the current library link order, follow these steps:
On the Project menu, click Settings.
In the Settings For view of the Project Settings dialog box, click to select the project configuration that is getting the link errors.
On the Link tab, type /verbose:lib in the Project Options box.
Rebuild your project. The libraries will be listed in the output window during the linking process.
This was clarified to me on the MSDN Forumns:
http://social.msdn.microsoft.com/Forums/en/vcgeneral/thread/4e331cb3-e566-4ca6-b7d4-118c3bebd31a