Visual C fatal error LNK1120: 1 unresolved externals - c++

Don't know whats wrong, all help will be greatly appreciated.
I'm thinking I am having a problem with a file source, but am not sure.
1>------ Build started: Project: Assignment 08 ADL, Configuration: Debug Win32 ------
1>Build started 3/18/2013 8:37:38 PM.
1>InitializeBuildStatus:
1> Touching "Debug\Assignment 08 ADL.unsuccessfulbuild".
1>ClCompile:
1> Assignment 08 ADL.cpp
1> Generating Code...
1> Skipping... (no relevant changes detected)
1> student.cpp
1>ManifestResourceCompile:
1> All outputs are up-to-date.
1>Assignment 08 ADL.obj : error LNK2019: unresolved external symbol "long __cdecl decimals(class std::basic_ostream<char,struct std::char_traits<char> > &,int)" (? decimals##YAJAAV?$basic_ostream#DU?$char_traits#D#std###std##H#Z) referenced in function "void __cdecl display(class student)" (?display##YAXVstudent###Z)
1>J:\CO 127\Assignment 08 ADL\Debug\Assignment 08 ADL.exe : fatal error LNK1120: 1 unresolved externals
1>
1>Build FAILED.
1>
1>Time Elapsed 00:00:24.82

You need to look at the line above LNK1120, the LNK2019 error tells you what is wrong.
Inside of your void display(class student) function you are calling a function named decimals that is not defined anywhere in your source code or in a library.

This problem appeared to me when I added .c file instead of .cpp
so check the name of the files as well

Make sure the external variable able to access in your current file.
For Testing
easy way is declare same name local variable for testing your logic working not , later change try to access external variable.

LNK 2019 error is a linker error which generally means some object is not available to the linker. Try clean rebuilding the project and then try to execute it.

Related

How to solve 'error LNK2001: unresolved external symbol' for writing a User-defined Model (FLAC) in Visual Studio 2010 C++?

I am trying to write a User-defined Model in C++ for FLAC in Visual Studio Express 2010 C++. Initially, I am trying to run (debug and build) the built-in Strain-softening Model based on the Mohr-Coulomb criterion (Available in FLAC 8.0) by changing its name only. Once I succeed to do it, I will try to modify it as per my requirement. I am running the code in VS2010. I have already installed SDK7.1, VS2010 SP1, etc. However, I am getting the following error msg:
1>------ Build started: Project: i_ssoft, Configuration: Debug x64 ------
1> modeli_ssoft.cpp
1> Creating library C:\Program Files\Itasca\FLAC800\PluginFiles\Models\modeli_ssoft\i_ssoft\i_ssoft.lib and object C:\Program Files\Itasca\FLAC800\PluginFiles\Models\modeli_ssoft\i_ssoft\i_ssoft.exp
1>modeli_ssoft.obj : error LNK2001: unresolved external symbol "public: virtual class std::basic_string<wchar_t,struct std::char_traits<wchar_t>,class std::allocator<wchar_t> > __cdecl models::ConstitutiveModel::getPluginName(void)const " (?getPluginName#ConstitutiveModel#models##UEBA?AV?$basic_string#_WU?$char_traits#_W#std##V?$allocator#_W#2##std##XZ)
1>C:\Program Files\Itasca\FLAC800\PluginFiles\Models\modeli_ssoft\i_ssoft\\i_ssoft.dll : fatal error LNK1120: 1 unresolved externals
========== Build: 0 succeeded, 1 failed, 0 up-to-date, 0 skipped ==========
From the error code, it is clear that I need to add some libraries or I need to place the supporting libraries in the same project directory... which I have tried but still, I am getting the error.

Issues when compiling the solution file for vtk using CMake

Like I said, I'm trying to compile VTK (version 5.10.1) using CMake (2.8.12) and QT (4.7.4)
After following the instructions for installing QT using visual studios cmd line, I open up vtk's source, run CMAKE, and attempt to compile the solution file using Visual Studio Pro.
There's a few libraries that aren't compiling, but I'm hoping if someone can explain how to fix one, I can try and fix the others on my own.
When building QVTKWidgetPlugin, I keep getting the following error codes:
1>------ Build started: Project: ZERO_CHECK, Configuration: Release Win32 ------
1>Build started 8/10/2015 9:57:50 PM.
1>InitializeBuildStatus:
1> Creating "Win32\Release\ZERO_CHECK\ZERO_CHECK.unsuccessfulbuild" because "AlwaysCreate" was specified.
1>FinalizeBuildStatus:
1> Deleting file "Win32\Release\ZERO_CHECK\ZERO_CHECK.unsuccessfulbuild".
1> Touching "Win32\Release\ZERO_CHECK\ZERO_CHECK.lastbuildstate".
1>
1>Build succeeded.
1>
1>Time Elapsed 00:00:00.10
2>------ Build started: Project: QVTKWidgetPlugin, Configuration: Release Win32 ------
2>Build started 8/10/2015 9:57:51 PM.
2>InitializeBuildStatus:
2> Touching "QVTKWidgetPlugin.dir\Release\QVTKWidgetPlugin.unsuccessfulbuild".
2>CustomBuild:
2> All outputs are up-to-date.
2>ClCompile:
2> All outputs are up-to-date.
2>Link:
2> Creating library C:/vtk/bin/bin/Release/QVTKWidgetPlugin.lib and object C:/vtk/bin/bin/Release/QVTKWidgetPlugin.exp
2>Q4VTKWidgetPlugin.obj : error LNK2019: unresolved external symbol "private: static struct QString::Data QString::shared_null" (?shared_null#QString##0UData#1#A) referenced in function "public: __thiscall QString::QString(void)" (??0QString##QAE#XZ)
2>Q4VTKWidgetPlugin.obj : error LNK2019: unresolved external symbol "public: static struct QListData::Data QListData::shared_null" (?shared_null#QListData##2UData#1#A) referenced in function "public: __thiscall QList<class QDesignerCustomWidgetInterface *>::QList<class QDesignerCustomWidgetInterface *>(void)" (??0?$QList#PAVQDesignerCustomWidgetInterface####QAE#XZ)
2>moc_Q4VTKWidgetPlugin.obj : error LNK2001: unresolved external symbol "public: static struct QMetaObject const QWidget::staticMetaObject" (?staticMetaObject#QWidget##2UQMetaObject##B)
2>moc_Q4VTKWidgetPlugin.obj : error LNK2001: unresolved external symbol "public: static struct QMetaObject const QObject::staticMetaObject" (?staticMetaObject#QObject##2UQMetaObject##B)
2>C:\vtk\bin\bin\Release\QVTKWidgetPlugin.dll : fatal error LNK1120: 4 unresolved externals
2>
2>Build FAILED.
2>
2>Time Elapsed 00:00:00.14
========== Build: 1 succeeded, 1 failed, 0 up-to-date, 0 skipped ==========
I understand that its basically looking for things that aren't defined, but I'm not sure how to fix it. As far as I know this should all run 100% from QT->VTK but I'm having some issues. Thanks in advance!

CS106B Library in Visual Studio 2010

I feel like this question should have been asked already but I haven't been able to find any solutions to accomplish this. But basically I'm going through the youtube lecture videos for Stanford's CS106B course on C++ and I'd like to use their libraries in my Visual Studio 2010, but i'm a VS newbie so I'm not sure how to get the include to work. I've tried to include the path to Project|Options|Include Directories but I get the following error
1>------ Build started: Project: HelloWorld, Configuration: Debug Win32 ------
1>Build started 1/26/2015 8:28:05 PM.
1>InitializeBuildStatus:
1> Touching "Debug\HelloWorld.unsuccessfulbuild".
1>ClCompile:
1> All outputs are up-to-date.
1> All outputs are up-to-date.
1>ManifestResourceCompile:
1> All outputs are up-to-date.
1>HelloWorld.obj : error LNK2019: unresolved external symbol "int __cdecl getInteger(class std::basic_string<char,struct std::char_traits<char>,class std::allocator<char> > const &,class std::basic_string<char,struct std::char_traits<char>,class std::allocator<char> > const &)" (?getInteger##YAHABV?$basic_string#DU?$char_traits#D#std##V?$allocator#D#2##std##0#Z) referenced in function _main
1>C:\CppProjects\HelloWorld\Debug\HelloWorld.exe : fatal error LNK1120: 1 unresolved externals
1>
1>Build FAILED.
1>
1>Time Elapsed 00:00:00.88
========== Build: 0 succeeded, 1 failed, 0 up-to-date, 0 skipped ==========
Update: I downloaded the library from here: http://stanford.edu/~stepp/cppdoc/
And i'm using the Visual Studio IDE.
Any assistance would be awesome, and then I'd know how to include external libraries!

Strange link error while rebuilding in visual Studio 2012

I have a very strange problem. I have a project in VS2012 that links statically with another lib.
If I build project everything is fine.
However, if I REBUILD the project it will fail with link problems.
The lib is compiled, I do not compile it during the build.
It is no difference if I clean everything or building/rebuilding on top of previous build.
Build works, Rebuild - not!
Can anyone give me at least a clue - what different in those 2 commands? I do not even know how to start investigate the problem.
Supplemental:
To all the people that answered - You are trying to explain me the difference between the build and rebuild. Thank you, but I know it. You ignore the fact that I explained before:
I can completely clean previous results, delete OutDir, delete IntDir, delete everything produced by the compilation. still - Build work, Rebuild not.
In the explained above case - what is the difference between build and rebuild if you build the first time??
The reason I did not posted errors is that those are simply link errors telling me .lib is missing. While it is clearly not.
Here is the example:
1>C:\Program Files (x86)\Microsoft Visual Studio 11.0\VC\include\sal.h(2872): warning RC4005: '_useHeader' : redefinition
1>
1>C:\Program Files (x86)\Microsoft Visual Studio 11.0\VC\include\sal.h(2882): warning RC4005: '_on_failure' : redefinition
1>
1> Creating library D:\p4client\ProAudio\dev_main\ProAudio\XPlatform..\VisualStudioBuildProducts\WaveShell-DAE\Win32\Debug\Products\WaveShell-DAE.lib and object D:\p4client\ProAudio\dev_main\ProAudio\XPlatform..\VisualStudioBuildProducts\WaveShell-DAE\Win32\Debug\Products\WaveShell-DAE.exp
1>DefaultSwap.obj : error LNK2019: unresolved external symbol _ASI_UnregisterCustomByteSwapper#4 referenced in function _RemoveByteSwapper
1>DefaultSwap.obj : error LNK2019: unresolved external symbol _ASI_RegisterCustomByteSwapper#8 referenced in function _RegisterByteSwapper
1>PlugInLib.lib(PlugInUtils.obj) : error LNK2001: unresolved external symbol _imp_FicGestalt#8
1>PlugInLib.lib(CDSPProcess.obj) : error LNK2001: unresolved external symbol _imp_FicGestalt#8
1>PlugInLib.lib(CAdaptorPlugIn.obj) : error LNK2001: unresolved external symbol _imp_FicGestalt#8
1>CShellProcessGroup.obj : error LNK2019: unresolved external symbol _imp_FicGestalt#8 referenced in function "public: __thiscall CShellProcessGroup::CShellProcessGroup(void)" (??0CShellProcessGroup##QAE#XZ)
1>CEffectTypeRTAS.obj : error LNK2001: unresolved external symbol _imp_FicGestalt#8
1>PlugInLib.lib(CProcessGroupInterface.obj) : error LNK2001: unresolved external symbol _imp_FicGestalt#8
1>PlugInLib.lib(CProcessGroup.obj) : error LNK2001: unresolved external symbol _imp_FicGestalt#8
Maybe it will help to know that while running Build (Not rebuild) I will get the following warnings:
1>C:\Program Files (x86)\Microsoft Visual Studio 11.0\VC\include\sal.h(2872): warning RC4005: '_useHeader' : redefinition
1>
1>C:\Program Files (x86)\Microsoft Visual Studio 11.0\VC\include\sal.h(2882): warning RC4005: '_on_failure' : redefinition
1>
1> Creating library D:\p4client\ProAudio\dev_main\ProAudio\XPlatform..\VisualStudioBuildProducts\WaveShell-DAE\Win32\Debug\Products\WaveShell-DAE.lib and object D:\p4client\ProAudio\dev_main\ProAudio\XPlatform..\VisualStudioBuildProducts\WaveShell-DAE\Win32\Debug\Products\WaveShell-DAE.exp
1>PlugInLib.lib(C321ChipDSP.obj) : warning LNK4099: PDB 'vc110_ib_2.pdb' was not found with 'PlugInLib.lib(C321ChipDSP.obj)' or at 'D:\p4client\ProAudio\dev_main\ProAudio\VisualStudioBuildProducts\WaveShell-DAE\Win32\Debug\vc110_ib_2.pdb'; linking object as if no debug info
1>PlugInLib.lib(CDSP.obj) : warning LNK4099: PDB 'vc110_ib_3.pdb' was not found with 'PlugInLib.lib(CDSP.obj)' or at 'D:\p4client\ProAudio\dev_main\ProAudio\VisualStudioBuildProducts\WaveShell-DAE\Win32\Debug\vc110_ib_3.pdb'; linking object as if no debug info
1>PlugInLib.lib(CDSPUtils.obj) : warning LNK4099: PDB 'vc110_ib_4.pdb' was not found with 'PlugInLib.lib(CDSPUtils.obj)' or at 'D:\p4client\ProAudio\dev_main\ProAudio\VisualStudioBuildProducts\WaveShell-DAE\Win32\Debug\vc110_ib_4.pdb'; linking object as if no debug info
Thanks!
Build means compile and link only the source files that have changed since the last build, while Rebuild means compile and link all source files regardless of whether they changed or not.
Build is the normal thing to do and is faster. Sometimes the versions of project target components can get out of sync and rebuild is necessary to make the build successful. In practice, you never need to Clean.
'Build' will do an incremental build, basically going through each project in your solution, see if there has been a change since the last build, and if there is, build it again.
'Rebuild' will perform a clean on everything and build everything from scratch.
Edit: A more detailed answer link
If your static lib is another project in the same solution as the project that links to the lib, then you need to set a dependency between the two projects so that the build process will build the lib first and the other project second.
To do this, right-click on the Solution abd choose "Project dependencies" from the pop-up menu.
I am not sure if it is related. But you may want to check this thread (the symptom is reversed from yours though...):
VS2010 Unresolved External Symbol errors on build (but not rebuild)

error when compiling a project in VS 2010 C ++

I'm trying to compile a project that I created, a software management program, in VS 2010. In VS6 and VS2005, it compiles perfectly.
1 - visual studio 6 2 - Visual Studio 2005 3 - Visual Studio 2010
The original version has some bugs that I would like fix later, but first of all I need it to compile.
With VS 6 and VS 2005 it compiles perfectly.
I added the library #pragma comment(lib, "bufferoverflowU.lib") corresponding to each file that needs it (.cpp)
However, it did not solve anything with bufferoverflowU.lib
errors are:
1>------ Operación Volver a generar todo iniciada: proyecto: Gestion_v1, configuración: Release Win32 ------
1> StdAfx.cpp
1> WDoS.cpp
1> Helpers.cpp
1> Gestion.cpp
1> WWW.cpp
1>WWW.cpp(141): warning C4018: '<' : no coinciden signed/unsigned
1>WWW.cpp(136): warning C4101: 'dwTmp' : variable local sin referencia
1>WWW.cpp(481): warning C4244: '=' : conversion from 'DWORD' to 'char'; possible loss of data
1>WWW.cpp(482): warning C4244: '=' : conversion from 'DWORD' to 'char'; possible loss of data
1> Generando código...
1>LINK : warning LNK4108: /ALIGN specified without /DRIVER; image may not run
1>WDoS.obj : error LNK2019: unresolved external symbol ___security_cookie referenced in function "unsigned long __stdcall WDoS_HTTP(void *)" (?WDoS_HTTP##YGKPAX#Z)
1>Gstion.obj : error LNK2001: unresolved external symbol ___security_cookie
1>WWW.obj : error LNK2001: unresolved external symbol ___security_cookie
1>WDoS.obj : error LNK2019: unresolved external symbol #__security_check_cookie#4 referenced in function "unsigned long __stdcall WDoS_HTTP(void *)" (?WDoS_HTTP##YGKPAX#Z)
1>Gestion.obj : error LNK2001: unresolved external symbol #__security_check_cookie#4
1>WWW.obj : error LNK2001: unresolved external symbol #__security_check_cookie#4
1>.\Release/Gestion_v1.exe : fatal error LNK1120: 2 unresolved externals
========== Rebuild All: 0 succeeded, 1 failed, 0 skipped ==========
Any ideas?
Thanks
Your unresolved externals are a consequence of compiling with the /GS (Buffer Security Check) compiler flag, but not linking against the CRT (/NODEFAULTLIB). If /GS is not specified it defaults to being enabled. You can try to disable Buffer Security Checks by specifying /GS-.
Alternatively you can attempt to add the pieces of code you need. __security_cookie is declared in <process.h> and defined in <gs_cookie.c> as part of the CRT source that ships with Visual Studio. Since you also explicitly specified WinMain as the entry point and don't rely on the CRT to perform the required initialization you will have to call __security_init_cookie yourself. There may be more to get this to compile, but this should serve as a starting point.
Make sure your project is not set to unicode. Your library may be that is different.
Try : Project properties -> Configuration properties -> General -> Character set = not set
Ok, try this question :
error LNK2001: unresolved external symbol