gmp.h /mpir.h linker in visual studio 2012 professional - c++

I am trying to use gmp.h for C/C++. I am currently working on visual studio 2012 professional. I followed the instructions from the link. But still I got error messages...
1>------ Build started: Project: final, Configuration: Debug Win32 ------
1> final.cpp
1>final.obj : error LNK2019: unresolved external symbol ___gmpz_init referenced in function _wmain
1>final.obj : error LNK2019: unresolved external symbol ___gmpz_init_set_ui referenced in function _wmain
1>final.obj : error LNK2019: unresolved external symbol ___gmpz_out_str referenced in function _wmain
1>D:\New folder\final\Debug\final.exe : fatal error LNK1120: 3 unresolved externals
========== Build: 0 succeeded, 1 failed, 0 up-to-date, 0 skipped ==========
I tried all possible options but could not got the solution. Please help me out

I had the same problem and it was just that I wasn't linking the library.
You need to include the library in the Visual Studio project.
How to add additional libraries to Visual Studio project?

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.

LNK2019 error when using a library installed with vcpkg

I have installed libraries with vcpkg using the correct triplet :
C:\Users\***>vcpkg list libnoise
libnoise:x64-windows 1.0.0 A general-purpose library that generates three-d...
Then I have executed the following command :
C:\Users\***>vcpkg integrate install
Applied user-wide integration for this vcpkg root.
All MSBuild C++ projects can now #include any installed libraries.
Linking will be handled automatically.
Installing new libraries will make them instantly available.
CMake projects should use: "-DCMAKE_TOOLCHAIN_FILE=C:/Windows/vcpkg/scripts/buildsystems/vcpkg.cmake"
But in my Visual Studio 2019 project, with an x64 project, only the headers have been successfully integrated :
#include <noise/noise.h> // The header is found as well as the definition of noise::module::Perlin
int main()
{
noise::module::Perlin noise; // The implementation is not found
}
When trying to compile this, I get :
1>------ Build started: Project: Mayak, Configuration: Debug x64 ------
1>main.obj : error LNK2019: unresolved external symbol "__declspec(dllimport) public: __cdecl noise::module::Perlin::Perlin(void)" (__imp_??0Perlin#module#noise##QEAA#XZ) referenced in function main
1>NoiseVideoGenerator.obj : error LNK2001: unresolved external symbol "__declspec(dllimport) public: __cdecl noise::module::Perlin::Perlin(void)" (__imp_??0Perlin#module#noise##QEAA#XZ)
1>main.obj : error LNK2019: unresolved external symbol "__declspec(dllimport) public: virtual __cdecl noise::module::Perlin::~Perlin(void)" (__imp_??1Perlin#module#noise##UEAA#XZ) referenced in function main
1>NoiseVideoGenerator.obj : error LNK2001: unresolved external symbol "__declspec(dllimport) public: virtual __cdecl noise::module::Perlin::~Perlin(void)" (__imp_??1Perlin#module#noise##UEAA#XZ)
1>C:\Users\sylva\source\repos\Mayak\x64\Debug\Mayak.exe : fatal error LNK1120: 2 unresolved externals
1>Done building project "Mayak.vcxproj" -- FAILED.
========== Build: 0 succeeded, 1 failed, 0 up-to-date, 0 skipped ==========
On a side note, I have looked for the name of the .lib files of the noise library and tried to add them in the Linker > Input properties, it still doesn't work.
What did I do wrong ?
To enable AutoLink, select your current project and go to properties. (Alt-Enter) Make sure you edit the right configuration. Then go to Configuration Properties -> vcpkg and make sure AutoLink is enabled.
It has been fixed by the developers, on GitHub : https://github.com/microsoft/vcpkg/issues/14127

Unresolved External Symbol __imp__Py_Finalize

I literally just got Python.h to link to my Visual Studio 2017 IDE and then when I ran it, it spat this error out for me.
I use VS2017, and I am learning C++, so I have no idea why this is happening. I linked my Python.h file's directory in the project properties.
Full Build Logs:
1>------ Build started: Project: PyC++, Configuration: Release Win32 ------
1>PyC++.obj : error LNK2001: unresolved external symbol __imp__Py_Finalize
1>PyC++.obj : error LNK2001: unresolved external symbol __imp__Py_SetProgramName
1>PyC++.obj : error LNK2001: unresolved external symbol __imp__Py_InitializeEx
1>C:\Users\maste\source\repos\PyC++\Release\PyC++.exe : fatal error LNK1120: 3 unresolved externals
1>Done building project "PyC++.vcxproj" -- FAILED.
========== Build: 0 succeeded, 1 failed, 0 up-to-date, 0 skipped ==========
Try to include pythonxx.lib(such as python26.lib) in your references.
The answer is simple, like #Xiaoying Sun has stated, put the python38.lib file in your references, however, you're required to put it in your VC++ directories, this way it will work.

Unresolved external symbol _glfwInit due to 32-bit/64-bit mismatch

How do I link the library in a way that visual studio 2015 can actually see it?
Here's a few screenshot of my folders:
glfw3, glfw3/include/glfw/, glfw3/lib
I've attempted to link these folders into visual studio, under "vc++ directories => include/library directories as such: include, library
also linking the same to my project directly, under linker => input => additional dependencies
to me, that seems like everything is correct (this is how it was in the tutorial i am following, learnopengl.com)
note: I am also doing the same with the GLAD library, which that has a .c file that I put directly into my sources, along with the header files linked the same way as with GLFW.
but despite trying to run this code:
#include <glad/glad.h>
#include <GLFW/glfw3.h>
int main() {
glfwInit();
return 0;
}
it will always return this error, or similar ones:
1>------ Build started: Project: opengl_test, Configuration: Debug Win32 ------
1> main.cpp
1>main.obj : error LNK2019: unresolved external symbol _glfwInit referenced in function _main
1>C:\Users\Honza\Desktop\C++ programs\lib\glfw3\lib\glfw3.lib : warning LNK4272: library machine type 'x64' conflicts with target machine type 'X86'
1>c:\users\honza\documents\visual studio 2015\Projects\opengl_test\Debug\opengl_test.exe : fatal error LNK1120: 1 unresolved externals
========== Build: 0 succeeded, 1 failed, 0 up-to-date, 0 skipped ==========
I'm guessing there is something wrong with how I linked the libraries. I am willing to literally re-install visual studio if I have to, just please give me some possible solutions. I want to start learning opengl but all this jazz with linking libraries is leaving me frustrated and confused.
EDIT: The problem here was that I was using 64-bit GLFW binaries instead of the 32-bit ones, and compiling in 32-bit. I've fixed that, and now I get even more errors:
1>------ Build started: Project: opengl_test, Configuration: Debug Win32 ------
1>libglfw3.a(init.c.obj) : error LNK2019: unresolved external symbol ___chkstk_ms referenced in function __glfwInputError
1>libglfw3.a(init.c.obj) : error LNK2019: unresolved external symbol _vsnprintf referenced in function __glfwInputError
1>MSVCRTD.lib(vsnprintf.obj) : error LNK2001: unresolved external symbol _vsnprintf
1>libglfw3.a(context.c.obj) : error LNK2019: unresolved external symbol _sscanf referenced in function __glfwRefreshContextAttribs
1>MSVCRTD.lib(vsnprintf.obj) : error LNK2001: unresolved external symbol __vsnprintf
1>C:\Users\Honza\Documents\Visual Studio 2015\Projects\opengl_test\Debug\opengl_test.exe : fatal error LNK1120: 4 unresolved externals
========== Build: 0 succeeded, 1 failed, 0 up-to-date, 0 skipped ==========
You write that you tried to link "these folders", while in fact, you need 2 separate things in order to use a function from a static library.
Use the proper header file so compilation succeeds. From the error you quoted, compilation went well. The program knows there is an external function named _glfwInit.
Link to the specific library (.lib file). Looks like you placed a path of a folder and not the full path of the .lib file.
Under Linker => input => additional dependencies, place the full path of the gfw3.lib file.
I faced the same problem while following learnopengl.com, The issue is that you need to rebuild glfw library with cmake again,
but this time when you choose visual studio 2015 or whatever for your generator for this project, you must also choose: OPTIONAL PLATFORM FOR GENERATOR -> x64
you can make sure that every thing is OK when you build glfw inside Visual Studio and the platform that appears is x64

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!