Link against failed, the lib file is exported by dumpbin of MSVC - visual-c++

I use dumpbin to convert a dll file to lib file:
get def file using dumpbin.exe /export and edit it
generate lib file using lib.exe.
The header files are available, however, when I include the header files and link against the lib file, there are linking errors:
error LNK2019: unresolved external symbol "__declspec(dllimport) public: __cdecl db::Layout::Layout(class db::Manager *)" (__imp_??0Layout#db##QEAA#PEAVManager#1##Z)
I checked the def file, some lines are like:
_ZN2db6LayoutC1EPNS_7ManagerE
_ZN2db6LayoutC1ERKS0_
_ZN2db6LayoutC1EbPNS_7ManagerE
_ZN2db6LayoutC2EPNS_7ManagerE
_ZN2db6LayoutC2ERKS0_
_ZN2db6LayoutC2EbPNS_7ManagerE
How to fix it? Did I miss some link settings in VC project? Thanks.

Related

How to make JsonCPP works in MFC c++ project

I was able to create a test WinApp using JsonCPP (https://github.com/open-source-parsers/jsoncpp) to parse a json file.
However, when I implemented similar in an MFC C++ project with C/C++ -> Precompiled Headers option set to Use Precompiled Header(/Yu) in VS2008, it fails with this error:
c:\users\user1\documents\visual studio 2008\projects\jsonutility\jsonutility\jsonTest.cpp(371) : fatal error C1010: unexpected end of file while looking for precompiled header. Did you forget to add '#include "stdafx.h"' to your source?
If I add '#include "stdafx.h"' to my JsonTest.cpp, I will get this error:
JsonTest.obj : error LNK2019: unresolved external symbol "public: class Json::Value & __thiscall Json::Value::operator[](char const *)" (??AValue#Json##QAEAAV01#PBD#Z) referenced in function "public: void __thiscall JsonTest::readConfig(char const *)" (?readConfig#JsonTest##QAEXPBD#Z)
I have tried for almost 2 days now but no success.
I had added the following in my Additional Include Directories:
C:\Users\User1\Documents\Visual Studio 2008\Projects\JsonUtility\ReadingJson\dist
C:\Program Files (x86)\Microsoft Visual Studio 9.0\VC\include
C:\usr\jsoncpp-master\include
I seems like you didn't include the JSONCPPs *.cpp file into your project (they have to be compiled and linked). If the library gets compiled to a static library, you have to tell the linker what to link.

Keep VC++ 2005 static library and your application in separate solutions

I have successfully built a static library as described in this walkthrough:
http://msdn.microsoft.com/en-us/library/ms235627%28v=vs.80%29.aspx
In the example above, both the static library and the application are located within the same solution but I prefer to keep them in separate solutions. After separation, I can compile but cannot link, here is the error:
main.obj : error LNK2019: unresolved external symbol…
Then I tried the project level setting of my application C/C++ / General / Additional include directories to where my .h file resides.
I also set .. Linker / General / Additional library directories to where my .lib file is at.
I finally set .. Linker / Input / Additional dependencies to where my .lib file is at.
Again, I could compile but not link. Here is the entire link error:
LINK : warning LNK4075: ignoring '/INCREMENTAL' due to '/OPT:ICF' specification
main.obj : error LNK2019: unresolved external symbol "public: static double __cdecl MathFuncs::MyMathFuncs::Add(double,double)" (?Add#MyMathFuncs#MathFuncs##SANNN#Z) referenced in function _main
Release\StaticLibraryApp.exe : fatal error LNK1120: 1 unresolved externals
Your project should link against the library project. In the 2nd project properties, add a library path where .lib file is stored and also include path for header path. This should resolve the issue. Also make 1st project dependent on 2nd solution.
Have a look at below article how to add libraries:
http://www.lavishsoft.com/wiki/index.php/Visual_Studio_Paths

Having problems with yaml.cpp lib in c++

I am having a hard time trying to use yaml-cpp 0.3.0 on my project
I downloaded yaml, and built it like http://code.google.com/p/yaml-cpp/ said, with VS 9 2008 WIN 64. So, i got the yaml-cpp.dll and the yaml-cpp.lib
I have a c++ project on VS 2010 express, and i am trying to link the library:
I go to project properties - c/c++ general and additional include directories that have yaml-cpp header files. Then i go to linker and add path to my lib directory, then I go to linker - input and add my .lib file, then i go to VC++ Directories and add path to my lib directory in Library directories and Reference directories
Then i try to build this simple code:
std::ifstream fin("test.yaml");
YAML::Parser parser(fin);
YAML::Node doc;
while(parser.GetNextDocument(doc)) {
//do nothing yet
}
I got several linking problems, like this:
error LNK2019: unresolved external symbol "public: __thiscall YAML::Node::Node(void)" (??0Node#YAML##QAE#XZ) referenced in function "public: __thiscall Parser::Parser(class std::basic_string<char,struct std::char_traits<char>,class std::allocator<char> >)" (??0Parser##QAE#V?$basic_string#DU?$char_traits#D#std##V?$allocator#D#2##std###Z)
error LNK2019: unresolved external symbol "public: __thiscall YAML::Parser::~Parser(void)" (??1Parser#YAML##QAE#XZ) referenced in function "public: __thiscall Parser::Parser(class std::basic_string<char,struct std::char_traits<char>,class std::allocator<char> >)" (??0Parser##QAE#V?$basic_string#DU?$char_traits#D#std##V?$allocator#D#2##std###Z)
Can anyone help me? I am banging my head against a wall here.
As you said you've got a DLL from YAML, I assume you specified -DBUILD_SHARED_LIBS=ON when you built with VS2008, so you ended up with a lib for dynamic linking (to the DLL at runtime) rather than static linking (at compile time).
If the above is correct, it may be differences between VS2008 and VS2010 that are causing a problem. For example, see this post here. To quickly see if this is the cause, in your VS2010 project properties, set the Platform Toolset to V90 and see if that helps.
Also, make sure you compiled both projects for the same CPU - i.e. both for 32-bit or both for 64-bit.

Using IrrKlang with Ogre

I'm trying to set up sound in my Ogre3D project. I have installed irrKlang 1.4.0 and added it's include and lib directories to my projects VC++ Include and Library directories, but I'm still getting a Linker error when I attempt to build. Any suggestions?
(Error 4007 error LNK2019: unresolved external symbol
"__declspec(dllimport) class irrklang::ISoundEngine * __cdecl
irrklang::createIrrKlangDevice(enum
irrklang::E_SOUND_OUTPUT_DRIVER,int,char const *,char const *)"
(_imp?createIrrKlangDevice#irrklang##YAPAVISoundEngine#1#W4E_SOUND_OUTPUT_DRIVER#1#HPBD1#Z)
referenced in function "public: __thiscall
SoundManager::SoundManager(void)" (??0SoundManager##QAE#XZ)
Okay, after looking at this for awhile it seems I was making two mistakes.
The lib directory for irrKlang is divided in two, so instead of adding (IRRKLANGDIRECTORY)\lib to my library directories, I should have been using (IRRKLANGDIRECTORY)\lib\Win32-visualStudio.
Including the lib directory wasn't sufficient, I also needed to specify the use of the irrklang library file at the top of my class (#pragma comment(lib, "irrklang.lib")).

Linker with user32.lib

I am trying to create a windows application but am getting a linker error as follows:
1>test_project.obj : error LNK2019: unresolved external symbol "int __cdecl run(void)" (?run##YAHXZ) referenced in function _WinMain#16
I assume this is because user32.lib is not linking correctly, but I have added it to linker->input->additional dependencies and added the directory containing it to library directories. Help would be appreciated.
I don't think this has anything to do with user32.lib. Most likely your program contains a forward declaration of function int run(void); which you never define yet trying to call from your WinMain(...) procedure.

Resources