I have projects A,B in visual studio under the solution AB.
B is a static library with a simple method named "add" which is already declared with __declspec(dllexport)
and A is an application depending on B.
the build order is configured B -> A
B.lib is getting created properly but i am getting "error LNK2019: unresolved external symbol _add referenced in function _main"
I also referenced the B.lib's directory in Additional dependencies in A's Project settings page
Please let me know where i am making the mistake....
sry got the solution to my problem...
C:\Documents and Settings\absasdf\My Documents\Visual Studio 2010\Projects\AB\Debug; added to Linker>General>Additional Library Directories
and
B.lib added to Linker>Input>Additional Dependencies
Now its working fine..
Related
Hi I am trying to merge two visual studio solution files into one and I have been having a difficult time calling one project to the other.
I have Solution X which contains Project A, which is a console application to control camera.
I have another solution Y which contains Project B produces a dll for another application to display plots.
After combining these two projects under one solution I made Project A to be a static library for Project B to call functions reside in Project A.
On Project B I added Project A's reference and also added a path to the include files of Project A.
I can build Project A independently, but I cannot build Project B. Visual studio complains as follows:
Severity Code Description Project File Line Suppression State
Error LNK1120 1 unresolved externals XOP3
C:\Users\xxx\Documents\project\pvcam_project\XOP3\VC\XOP3-64.xop 1
Severity Code Description Project File Line Suppression State
Warning LNK4098 defaultlib 'LIBCMT' conflicts with use of other libs;
use /NODEFAULTLIB:library XOP3
C:\Users\xxx\Documents\project\pvcam_project\XOP3\VC\LINK 1
Severity Code Description Project File Line Suppression State
Error LNK2019 unresolved external symbol pl_pvcam_get_ver referenced in
function "void __cdecl DoWave(void * *)" (?DoWave##YAXPEAPEAX#Z) XOP3
C:\Users\xxx\Documents\project\pvcam_project\XOP3\VC\XOP3.obj 1
I followed this as an example and was able to build https://msdn.microsoft.com/en-us/library/ms235627(v=vs.90).aspx
I would like to know:
Is it a good idea to have project A as a static library for project B to access ? Should the project A be a dll ?
From Solution Y I added a project A and updated the locations of include files and etc by following (How do I merge two different Visual Studio solutions?) Is this the easiest way to merge two solutions ?
Lastly it is the most important one I am not sure how to resolve the compilation error.
Thank you very much for taking a look at my problem.
I have just installed Visual Studio 2017 and I want to use the NTL library. I have followed the steps described here (for VS2013). Compiling NTL library in Visual Studio 2013
As expected, it compiles (with several, I hope, negligible warnings).
Then, under the same solution, I am doing these consecutive steps:
(under the same solution)
Add project -> New project -> Visual C++ -> Win32 Console Appl.
Right click on the created project -> Set as StartUp Project
Right click on the created project -> Add -> Reference -> NTL
Right click on the created project -> Configuration Properties ->
C/C++ -> General -> Additional Include Directories -> (NTL includes)
Take/copy some file from folder "tests" (downloaded from the NTL
repository)
Remove everything below #include "stdafx.h"
Paste and build
Those steps should work on VS2013 & VS2015, unfortunately when I build I got 4 linker related errors (LNK2019).
They all are similar to the example below:
Error LNK2019 unresolved external symbol "void __cdecl
NTL::MatPrime_crt_helper_deleter(class NTL::MatPrime_crt_helper *)"
(?MatPrime_crt_helper_deleter#NTL##YAXPAVMatPrime_crt_helper#1##Z)
referenced in function "public: static void __cdecl
NTL::ZZ_pInfoT::MatPrime_crt_helper_deleter_policy::deleter(class
NTL::MatPrime_crt_helper *)"
(?deleter#MatPrime_crt_helper_deleter_policy#ZZ_pInfoT#NTL##SAXPAVMatPrime_crt_helper#3##Z) NTLtest <thePathToTheLib>
(ZZ_p.obj) 1
Can you advice how to proceed?
I have tried to built this example -> ZZ_pEXTest.cpp
Thank you in advance!
First, I am assuming you get the same 4 errors I do. I get the one you showed in your question, plus three more. In all cases, it involves a forward declaration of a method or function that does actually exist in the code.
However, the types in the declarations are classes and the types in the implementation are structs. The function signature is therefore not the same and the linker can't find the implementation.
So, I simply updated the the forward declarations of the parameter types to be what they should be: structs.
In lip.h, change _ntl_general_rem_one_struct to be a struct.
In ZZ_p.h, change MatPrime_crt_helper to be a struct.
I believe this is all I did.
You shouldn't really have to make changes to the code. There may be a compiler switch, or it only fails in VS. I don't know. All I know is it is written by someone a lot smarter than me, and life is too short; I've made my changes and I'm moving on.
I upgraded my Win32 project from VC6 to VC2010, and fixed a lot of codes which only work on VC6, compiling is OK, but when the project began linking, it failed with the following message
LINK : fatal error LNK1104: cannot open file 'mfc42ud.lib'
I tried to find where the MFC42ud is referred, but I cannot, it drives me mad.
Could anyone help me?
updated:
Now I downloaded the MFC42ud.lib, but there is still link error, now it becomes
atlsd.lib(atltypes.obj) : error LNK2005: "public: __thiscall CRect::CRect(void)" (??0CRect##QAE#XZ) already defined in mfc42ud.lib(MFC42uD.DLL)
atlsd.lib(atltypes.obj) : error LNK2005: "public: int __thiscall CRect::Width(void)const " (?Width#CRect##QBEHXZ) already defined in mfc42ud.lib(MFC42uD.DLL)
atlsd.lib(atltypes.obj) : error LNK2005: "public: int __thiscall CRect::Height(void)const " (?Height#CRect##QBEHXZ) already defined in mfc42ud.lib(MFC42uD.DLL)
LINK : fatal error LNK1104: cannot open file 'mfcs42ud.lib'
It seems it is not compatible if I just copy the MFC42ud.lib, so now error is multiple definition
OK, at last I resolved it. It is because there are some libs I need link, and there is some linkage information in these libs.
The reason is the Microsoft VC specified preprocessor #pragma comment(lib, "some.lib")
Actually it is really a bad solution, especially to link system provided libs, like mfc libs. Even you upgraded the project, it still wants to link the old mfc libs.
The solution is to ignore the old mfc libs.
It is Unicode Debug version of the MFC DLL for Visual Studio 6, part of optional parts during Visual Studio 6 installation.
Install it from the VS6 installation CD.
Reference: http://social.msdn.microsoft.com/Forums/en-US/vcgeneral/thread/46a26f16-a407-4628-962b-2a6899391293/
p.s. it's Google's first result, by the way.
In my case, my project was linking against another library, and that library had been built with
#pragma comment(lib, "mfc42.lib")
inside it.
Linking that library into my project instructed my project to link against mfc42.lib, even though I never had any such setting.
Tracking down and removing the offending library was not easy.
I am working on an (unmanaged) x64 Win32 C++ application in Visual Studio 2010 Pro, and keep getting a strange linking error.
This application makes use of the LoadImage() Windows API function through including windows.h. While the application compiles fine in the Release configuration (and LoadImage() does its job), I cannot get the executable linked in the Debug configuration. I keep getting this error:
Redacted.obj : error LNK2019: unresolved external symbol __imp_LoadImageW referenced in function "public: int __cdecl Redacted::Redacted::Execute(void)" (?Execute#Redacted#Redacted##QEAAHXZ)
C:\Users\redacted\Documents\Visual Studio 2010\Projects\Redacted\x64\Debug\Redacted.exe : fatal error LNK1120: 1 unresolved externals
If I switch from Unicode to non-multi-byte character set, the error message will change from LoadImageW() to LoadImageA() accordingly, but otherwise persist. As I cannot find any relevant differences in the properties for the Release and Debug configuration, I am at a loss why it will compile in one, but not the other. User32.lib is correctly set as an Additional dependency for the Linker in both configurations, and the /MACHINE:X64 flag is set in both as well.
Since the linker doesn't complain about not finding the User32.lib, I am led to believe that it tries to link a wrong version from the Platform SDK, i.e. the 32-bit one. But how can I find out which exact copy of a LIB file the linker actually tries to use?
Check the linker paths in the global configuration settings. Most probably one of those is wrong.
Beyond that, I believe there's a linker /VERBOSE flag (or something similar) which will display the information you're looking for. It's somewhere in the linker settings for the project you're building.
I am developing a subproject in a solution in MS Visual Studio 2005. The subproject is a Windows CE 6.0 service (as DLL) and it is included in the Windows CE 6.0 OS Project. In the subproject I need to use some functions from "ceosutil.lib" (svsutil.hxx is the header), but I cannot link it to my subproject. When building, I get the following type of errors: "error LNK2019: unresolved external symbol".
What is interesting, when I switch the project type to a static library, it compiles without problems. If I start a new DLL project (standalone one, not as subproject), it also works (the "ceosutil.lib" is already listed in the Additional Dependencies of the project and all configurations).
Please help!
I have found the answer to my own question. The solution is to add the name of the library ("ceosutil.lib", after a space) to Additional Libraries field in the Link tab of the subproject properties:
In MS Visual Studio 2005:
Right Mouse Click on subproject name -> Properties -> Link tab -> Additional Libraries.
default value was: $(_PROJECTROOT)\cesysgen\sdk\lib\$(_CPUINDPATH)\coredll.lib
new value: $(_PROJECTROOT)\cesysgen\sdk\lib\$(_CPUINDPATH)\coredll.lib ceosutil.lib
Update:
It is even easier to open the subproject (right mouse btn -> open) and paste the path to the library in the TARGETLIBS section. The result will be exactly the same:
TARGETLIBS= \
$(_PROJECTROOT)\cesysgen\sdk\lib\$(_CPUINDPATH)\coredll.lib \