I have a small command line program that uses Maxim's OneWire Public Domain API and WinUSB. It builds absolutely fine on my laptop using Win7/VS2013. Now I'm trying to move it to Win8.1/VS2015 on my new desktop PC, and I can't get it to build. Here are the errors reported:
1>------ Build started: Project: readtemp5, Configuration: Debug Win32 ------
1>presshum.obj : warning LNK4217: locally defined symbol _printf imported in function _print_array
1>readtemp.obj : warning LNK4049: locally defined symbol _printf imported
1>presshum.obj : warning LNK4217: locally defined symbol _sprintf_s imported in function _ReadPressHum
1>readtemp.obj : warning LNK4049: locally defined symbol _sprintf_s imported
1>temp10.obj : warning LNK4049: locally defined symbol _sprintf_s imported
1>presshum.obj : warning LNK4217: locally defined symbol _sprintf imported in function _ReadPressHum
1>temp10.obj : warning LNK4049: locally defined symbol _sprintf imported
1>readtemp.obj : warning LNK4217: locally defined symbol _fprintf imported in function _main
1>readtemp.obj : error LNK2019: unresolved external symbol __imp____iob_func referenced in function _main
1>readtemp.obj : error LNK2019: unresolved external symbol __imp__scanf referenced in function _mainx
1>readtemp.obj : error LNK2019: unresolved external symbol __imp__sscanf referenced in function _main
1>readtemp.obj : error LNK2001: unresolved external symbol _owErrorStack
1>readtemp.obj : error LNK2001: unresolved external symbol _owErrorPointer
1>readtemp.obj : error LNK2001: unresolved external symbol _owErrorMsg
1>C:\Users\RowanB\Documents\Visual Studio 2015\Projects\readtemp5\readtemp5\Debug\readtemp5.exe : fatal error LNK1120: 6 unresolved externals
========== Build: 0 succeeded, 1 failed, 0 up-to-date, 0 skipped ==========
What does the error "locally defined symbol imported" actually mean? How do I find which line in which file is causing the problem?
What are the rules surrounding the symbol names with underscores? How do I work out what the original symbol names (i.e. the ones that I will see in source files) are?
I guess that the problem is probably that some header file or library or DLL is missing from the desktop PC, or are installed in a different place, and/or that I have not set up the project properties correctly to locate all the files needed. But how do I find out exactly what's wrong, and how to fix it?
I installed WDK on the new PC but it didn't install in the same place as on the laptop (C:\WinDDK). I can't actually find where it put it. Where are the WDK files?
Thanks - Rowan
I had similar errors when switching between 2012 and 2015 compilers withing one working directory (going back and forth between two source control commits where one was still built with 2012 and another with 2015). The fix was simply to clean the solution and rebuild. If you copied the entire folder to your new PC, it is possible that intermediate build files from 2013 cause the problem.
Related
all.
I’m compiling Ipopt-3.9.3 in Windows 10 & Visual C++ 2010 Express.
I’ve built the projects of libCoinBlas, libConHSL, libCoinLapack as well as libIpopt, and generated libCoinBlas.lib, libCoinHSL.lib, libCoinLapack.lib as well as libIpopt.lib in the correct paths but with some warnings.
While when I tried to build the projects of IpoptAmplSolver and hs071_cpp, there exists the following fatal errors.
5> Generating Code...
5> Creating library Release\IpoptAmplSolver.lib and object Release\IpoptAmplSolver.exp
5>dlarf.obj : error LNK2019: unresolved external symbol _iladlr_ referenced in function _dlarf_
5>dlarfb.obj : error LNK2001: unresolved external symbol _iladlr_
5>dlarf.obj : error LNK2019: unresolved external symbol _iladlc_ referenced in function _dlarf_
5>dlarfb.obj : error LNK2001: unresolved external symbol _iladlc_
5>dlascl.obj : error LNK2019: unresolved external symbol _disnan_ referenced in function _dlascl_
5>dpotf2.obj : error LNK2001: unresolved external symbol _disnan_
5>Release\IpoptAmplSolver.exe : fatal error LNK1120: 3 unresolved externals
========== Rebuild All: 4 succeeded, 1 failed, 0 skipped ==========
5>------ Rebuild All started: Project: hs071_cpp, Configuration: Release Win32 ------
5> hs071_main.cpp
5> hs071_nlp.cpp
5> Generating Code...
5>dlarf.obj : error LNK2019: unresolved external symbol _iladlr_ referenced in function _dlarf_
5>dlarfb.obj : error LNK2001: unresolved external symbol _iladlr_
5>dlarf.obj : error LNK2019: unresolved external symbol _iladlc_ referenced in function _dlarf_
5>dlarfb.obj : error LNK2001: unresolved external symbol _iladlc_
5>dlascl.obj : error LNK2019: unresolved external symbol _disnan_ referenced in function _dlascl_
5>dpotf2.obj : error LNK2001: unresolved external symbol _disnan_
5>LIBCMT.lib(wincrt0.obj) : error LNK2019: unresolved external symbol _WinMain#16 referenced in function ___tmainCRTStartup
5>Release\hs071_cpp.exe : fatal error LNK1120: 4 unresolved externals
========== Rebuild All: 4 succeeded, 1 failed, 0 skipped ==========
Is there anyone who can kindly tell me how should I deal with it?
Thank you very much for your attention, and I’m looking forward to your kind aid.
Finally, I've solved this problem which is due to the undefined functions. I think my case is about a released software package rather than some specific procedure code, hence, it's a little different and relative simple.
Without knowing the specifics of the libraries you are using, I recommend that you try the following to deal with this error:
The error tells you that the linker is missing code for some function calls. This probably means that a library file is not found. Make sure that the linker can find all needed lib files. Check the property pages. Under the Linker->General->Additional library directories, make sure that the directories where your lib-files are located are present and under Linker->Input->Additional dependencies, make sure that the the lib-files are listed. Also make sure that the parameters are present for the different Configurations.
If this still does not help, check if your libraries depend on other libraries. These should be mentioned in the documentation of the libraries you are using.
I've not built this, but here's what I would try from the start. From what you've said, you've compiled the .lib files that it links against and it's failing during linking.
So here are your options...
1) You've either missed a .lib file in the input list for the linker.
2) The actual .lib file doesn't contain the symbol that the linker needs (you can check this by dumping the symbols of the .lib file)
3) Your .lib file is compiled with either the wrong platform than what you're linking with or with the wrong type ie. release/debug.
4) The symbols in your lib are decorated because you're compiling as C++ instead of C, or visa-versa.
If you go through the above steps above, I'm pretty sure you'll find your problem, but you've not really given enough information to properly answer your question. Personally, I'd have a guess that you're compiling C as C++ or you've got the wrong platform type set for one of your lib files.
Thank you all very much for your patient and detailed advices that inspired me, and I finally find out that I should add some C files which define the necessary functions into my project. The detailed solution is as follows.
For example, I want to eliminate
5>dlarf.obj : error LNK2019: unresolved external symbol _iladlr_ referenced in function _dlarf_
5>dlarfb.obj : error LNK2001: unresolved external symbol _iladlr_
Step 1: Run
f2c iladlr.f
In the Visual Stuido Command Prompt and generate iladlr.c.
Step 2: Add iladlr.c to my project.
Step 3: Rebuild.
Finally, everything goes well.
I haven't ever seen the error of LNK 2019 before and now I encounter it when i try to link the code that i get from Nite.
The error is...
1>kinect.obj : error LNK2019: unresolved external symbol __imp__niteShutdownHandTracker referenced in function "public: void __thiscall nite::HandTracker::destroy(void)" (?destroy#HandTracker#nite##QAEXXZ)
1>kinect.obj : error LNK2019: unresolved external symbol __imp__niteStartHandTracking referenced in function "public: enum nite::Status __thiscall nite::HandTracker::startHandTracking(class nite::Point3f const &,short *)" (?startHandTracking#HandTracker#nite##QAE?AW4Status#2#ABVPoint3f#2#PAF#Z)
1>kinect.obj : error LNK2019: unresolved external symbol __imp__niteReadHandTrackerFrame referenced in function "public: enum nite::Status __thiscall nite::HandTracker::readFrame(class nite::HandTrackerFrameRef *)" (?readFrame#HandTracker#nite##QAE?AW4Status#2#PAVHandTrackerFrameRef#2##Z)
1>kinect.obj : error LNK2019: unresolved external symbol __imp__niteHandTrackerFrameRelease referenced in function "public: void __thiscall nite::HandTrackerFrameRef::release(void)" (?release#HandTrackerFrameRef#nite##QAEXXZ)
1>kinect.obj : error LNK2019: unresolved external symbol __imp__niteStartGestureDetection referenced in function "public: enum nite::Status __thiscall nite::HandTracker::startGestureDetection(enum nite::GestureType)" (?startGestureDetection#HandTracker#nite##QAE?AW4Status#2#W4GestureType#2##Z)
1>D:\AcerUser\Documents\Visual Studio 2013\Projects\kinect\Debug\kinect.exe : fatal error LNK1120: 11 unresolved externals
========== Build: 0 succeeded, 1 failed, 0 up-to-date, 0 skipped ==========
how to solve it?
Thanks
If you get error LNK2019 from Visual Studio Console output, you might building your project for Win32 platform on your 64bit Windows, try swiching to x64.
IF you are Using Visual Studio GO TO ->Build --> (thats where you change or create win32/x64
Configuration Manager
Are you sure your application is being linked against the corresponding libraries?
Somewhere in your OpenNI and Nite installation, there must be a folder containing .lib files. You have to specify this path in the additional library directories in your project's property page. If it still doesn't work afterwards, you should add the names of these libraries in the additional dependencies.
I have a number of DLLs building and linking against my application without issues, but this static lib is giving me troubles.
Present in it is just one class. The class is declared with __declspec(dllexport) when building the lib and __declspec(dllimport) when including the class's header in the application.
When I attempt to build the application with an instance of MyClass, I get:
error LNK2019: unresolved external symbol "__declspec(dllimport) public: virtual __thiscall MyClass::~MyClass(void)"
error LNK2019: unresolved external symbol "__declspec(dllimport) public: __thiscall MyClass::MyClass(void)"
And if I attempt to build the application with a pointer to MyClass, I get the same unresolved externals plus two additional warnings:
warning LNK4217: locally defined symbol ??0MyClass##QAE#XZ (public: __thiscall MyClass::MyClass(void)) imported in function _main
warning LNK4217: locally defined symbol ??1MyClass##UAE#XZ (public virtual __thiscall MyClass::~MyClass(void))
Searching the web for LNK4217 suggests incorrect usage of the /M[TD]d? cl.exe switch. I recreated the Visual Studio solution and dragged over the sources to make sure it was provisioned correctly. For reference, both the Lib and app have /MDd.
Using this manual, I tried to get freeglut OpenGL application to compile on my computer. This means I:
Copied files from freeglut archive to MS program files folder
Specified freeglut.lib in additional dependencies
Set explicitly the freeglut.lib path in libraries folders
But all takes no effect. The C++ header files are found right, but the libraries not - so I get these errors:
1>OpenglTest.obj : error LNK2019: unresolved external symbol __imp__glutMainLoop#0 referenced in function _wmain
1>OpenglTest.obj : error LNK2019: unresolved external symbol __imp__glutSpecialFunc#4 referenced in function _wmain
1>OpenglTest.obj : error LNK2019: unresolved external symbol "void __cdecl specialKeys(int,int,int)" (?specialKeys##YAXHHH#Z) referenced in function _wmain
1>OpenglTest.obj : error LNK2019: unresolved external symbol __imp__glutDisplayFunc#4 referenced in function _wmain
1>OpenglTest.obj : error LNK2019: unresolved external symbol __imp__glutInitDisplayMode#4 referenced in function _wmain
1>OpenglTest.obj : error LNK2019: unresolved external symbol __imp____glutInitWithExit#12 referenced in function _glutInit_ATEXIT_HACK#8
1>OpenglTest.obj : error LNK2019: unresolved external symbol __imp____glutCreateWindowWithExit#8 referenced in function _glutCreateWindow_ATEXIT_HACK#4
1>OpenglTest.obj : error LNK2019: unresolved external symbol __imp__glutSwapBuffers#0 referenced in function "void __cdecl display(void)" (?display##YAXXZ)
So my questions:
Could you guess what may be wrong? (not easy, but I cannot find this out obviously)
Is there some other manual google didn't find, but better than the one I used?
Is there some other archive I should download?
My C++ code comes from here. All functions are well found in freeglut header files. Just the libraries are missing.
This seems like a C vs C++ linkage issue. You are compiling a C source code from there as a C++ code (maybe you saved it with C++ specific extensions and the compiler assumed it is C++).
C++ will mangle function names. For example __imp__glutMainLoop#0 is most probabley a call to glutMainLoop in your source code.
The library must have been from a C code. Hence it will have a non mangled version of the function simply as glutMainLoop. That's why it can not be found.
The solution is either compile your code as C code or use extern "C".
EDIT: Some Links on how to deal with with C/C++ linkage issues (Moved from the comments).
http://www.thegeekstuff.com/2013/01/mix-c-and-cpp/
Combining C++ and C - how does #ifdef __cplusplus work?
http://www.parashift.com/c++-faq-lite/c-calls-cpp.html
I am getting the following LINK error while compiling my C++ solution:
error LNK2019: unresolved external symbol _Direct3DCreate9Ex#8
referenced in function "protected: XYX()
The symbol "Direct3DCreate9Ex' is defined in "ddraw.h" header file found in "C:\Program Files\Microsoft SDKs\Windows\v7.0\Include". And verified that the header file "ddraw.h" is present in this location. Also I have included this path in VS settings "Tools-->Options-->VC++ Directories -> Includes".
But still I am getting the link error as "error LNK2019: unresolved external symbol _Direct3DCreate9Ex#8 referenced in function "protected: XYX()" ".
Can anyone kindly help me in getting rid of this link error while compiling my C++ solution.
I am using VS 2008 on 64 bit Win7.
Thanks in advance.
Based on reference page for Direct3DCreate9Ex you need to link with D3D9.lib.