I am trying to use the amalgamated version of jsoncpp(the latest version), but it is producing unresolved external symbol link errors. The code I am using is
#include <json/json.h>
int main(){
Json::Value root;
return 0;
}
and it is giving me the error
1>main.obj : error LNK2019: unresolved external symbol "public: __thiscall Json::Value::~Value(void)" (??1Value#Json##QAE#XZ) referenced in function _main
1>main.obj : error LNK2019: unresolved external symbol "public: __thiscall Json::Value::Value(enum Json::ValueType)" (??0Value#Json##QAE#W4ValueType#1##Z) referenced in function _main
Probably 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.
I got this when trying to link x86 version of JsonCpp in my x64 build. I did not notice that Vcpkg behaves as if VCPKG_DEFAULT_TRIPLET=x86-windows was defined, unless it's told otherwise.
I saw the following entry in the build log when that was happening
C:\Tools\vcpkg\installed\x86-windows\debug\lib\jsoncpp.lib : warning LNK4272: library machine type 'x86' conflicts with target machine type 'x64' [C:\projects\qpid-proton\BLD\cpp\qpid-proton-cpp.vcxproj]
Related
I am trying to set up a connection to a MySQL database. The code compiles fine, but when linking I always get errors. I've tried both dynamic and static linking but nothing works. Some of the errors:
Severity Code Description Project File Line Suppression State
Error LNK2019 unresolved external symbol "__declspec(dllimport) public: __thiscall mysqlx::abi2::r0::Error::Error(char const *)" (__imp_??0Error#r0#abi2#mysqlx##QAE#PBD#Z) referenced in function "protected: void __thiscall mysqlx::abi2::r0::Value::check_type(enum mysqlx::abi2::r0::Value::Type)const " (?check_type#Value#r0#abi2#mysqlx##IBEXW4Type#1234##Z) DatabaseTest
Severity Code Description Project File Line Suppression State
Error LNK2019 unresolved external symbol "__declspec(dllimport) public: __thiscall mysqlx::abi2::r0::DbDoc::~DbDoc(void)" (__imp_??1DbDoc#r0#abi2#mysqlx##QAE#XZ) referenced in function "public: __thiscall mysqlx::abi2::r0::Value::~Value(void)" (??1Value#r0#abi2#mysqlx##QAE#XZ) DatabaseTest
Severity Code Description Project File Line Suppression State
Error LNK2019 unresolved external symbol "__declspec(dllimport) public: __thiscall mysqlx::abi2::r0::DbDoc::DbDoc(void)" (__imp_??0DbDoc#r0#abi2#mysqlx##QAE#XZ) referenced in function "public: __thiscall mysqlx::abi2::r0::Value::Value(void)" (??0Value#r0#abi2#mysqlx##QAE#XZ) DatabaseTest
#include <iostream>
#include "mysqlx/xdevapi.h"
int main()
{
//short test, program doesn't compile, the headers aren't included here because they are more than 1000 lines long. You can get them at the MySQL homepage
return 0;
}
I use the newest version of the connector. You can download the project here if you want to check the settings. Does anybody have an idea?
First, find where is your mysqlx directory is located, using following command:
sudo find / -name mysqlx
In Debian system, it is usually located in /usr/include/mysql-cppconn-8/ .
For compiling, use folllowing command:
g++ -std=c++11 -I /usr/include/mysql-cppconn-8/ -lmysqlcppconn8 filename.cpp
I'm trying to run a program with GLFW in C++. I'm using visual studios 2019 on a windows 10 computer. I put the .h's and the .lib's in the proper folders and linked to them in the project settings. I'm running a minimal GLFW program I got off the internet. When I run it I get the following error:
1>------ Build started: Project: Riemannian, Configuration: Debug Win32 ------
1>Main.cpp
1>Main.obj : error LNK2019: unresolved external symbol __imp__glClear#4 referenced in function _main
1>Main.obj : error LNK2019: unresolved external symbol _glfwInit referenced in function _main
1>Main.obj : error LNK2019: unresolved external symbol _glfwTerminate referenced in function _main
1>Main.obj : error LNK2019: unresolved external symbol _glfwCreateWindow referenced in function _main
1>Main.obj : error LNK2019: unresolved external symbol _glfwWindowShouldClose referenced in function _main
1>Main.obj : error LNK2019: unresolved external symbol _glfwPollEvents referenced in function _main
1>Main.obj : error LNK2019: unresolved external symbol _glfwMakeContextCurrent referenced in function _main
1>Main.obj : error LNK2019: unresolved external symbol _glfwSwapBuffers referenced in function _main
1>C:\Users\Aaron\source\repos\Riemannian\Debug\Riemannian.exe : fatal error LNK1120: 8 unresolved externals
1>Done building project "Riemannian.vcxproj" -- FAILED.
========== Build: 0 succeeded, 1 failed, 0 up-to-date, 0 skipped ==========
I tried adding glfw3.dll to system32, but that didn't change anything. (side note, GLFW came with a file glfw3dll.lib. Is that just a .lib file that serves the same purpose as glfw3.dll?) Next I tried linking to opengl32.lib in my project settings. This got rid of the first error, the one with the __imp__ prefix. After that there were only 7 unresolved external symbols. My project type is "Application (.exe)" if that's relevant. I'm out of ideas and tired of googling, does anyone know what to do?
On a broader note, I have wasted so many hours trying to get libraries to work in Python, Java, and C++. I am incredibly frustrated and I wish someone could just explain to me how libraries work once and for all so that next time I have a problem I won't be completely lost.
If all this setup is too complicated, you can also just take the Glitter project as a base. It takes care of all the boilerplate and just lets you get on with writing OpenGL. As a bonus, it is based on the cross-platform CMake build tool so your project should be easy to port to other operating systems.
I am having a hard time linking cURL to my project on vs12 ...
I opted for the .msi solution that I picked here:
http://www.confusedbycode.com/curl/
and tried to link that to my project...
However I am still getting some errors after doing what I thought was right:
1>main.obj : error LNK2019: unresolved external symbol _curl_easy_init referenced in function _main
1>main.obj : error LNK2019: unresolved external symbol _curl_easy_setopt referenced in function _main
1>main.obj : error LNK2019: unresolved external symbol _curl_easy_perform referenced in function _main
1>main.obj : error LNK2019: unresolved external symbol _curl_easy_cleanup referenced in function _main
My configuration in my project vs12 is the following:
I included the include folder and the the lib folder in the vc++ directories
I added CURL_STATICLIB to the Preprocessor definition in C/C++ section as well as adding the proper include folder
I added the lib folder to the Linker sectio as well as libcurl.lib
Eventually I just included "curl.h" to the relevant .cpp file...
Is there something that I am missing?
Thank you a lot
I built libcurl and added it to project (specified include directory, library directory and library to use: libcurl.lib/libcurl_imp.lib - I both tried to compile and link static and dynamic library). In both cases (static/dynamic) I faced following:
1>tmp.obj : error LNK2019: unresolved external symbol _curl_easy_cleanup referenced in function "void __cdecl perform(char *)" (?perform##YAXPAD#Z)
1>tmp.obj : error LNK2019: unresolved external symbol _curl_easy_perform referenced in function "void __cdecl perform(char *)" (?perform##YAXPAD#Z)
1>tmp.obj : error LNK2019: unresolved external symbol _curl_easy_setopt referenced in function "void __cdecl perform(char *)" (?perform##YAXPAD#Z)
1>tmp.obj : error LNK2019: unresolved external symbol _curl_easy_init referenced in function "void __cdecl perform(char *)" (?perform##YAXPAD#Z)
1>C:\Users\Public\Documents\Project\curl-7.35.0\Debug\tmp.exe : fatal error LNK1120: 4 unresolved externals
All solutions I found was different variations of "add libcurl.lib".
Now just to clarify my configuration:
dynamic: include directory specified, library directory specified, libcurl_imp.lib specified as additional dependency, libcurl.dll copied to the directory where executable files should be generated.
static: include directory specified, library directory specified, libcurl.lib specified as additional dependency.
using vs2005
Well, it's silly but I was trying to use x64 library in x32 project.
I've tried to build M2Crypto (github) for win-amd64-py3.3:
python setup.py build --compiler msvc
And I've got an linker's unresolved external symbol errors (full log):
C:\Program Files (x86)\Microsoft Visual Studio 9.0\VC\BIN\amd64\link.exe /DLL /nologo /INCREMENTAL:NO /LIBPATH:D:\Programy\Python33\libs /LIBPATH:D:\Programy\Python33\PCbuild\amd64 /LIBPATH:c:\pkg\lib ssleay32.lib libeay32.lib /EXPORT:PyInit___m2crypto build\temp.win-amd64-3.3\Release\SWIG/_m2crypto_wrap.obj /OUT:build\lib.win-amd64-3.3\M2Crypto\__m2crypto.pyd /IMPLIB:build\temp.win-amd64-3.3\Release\SWIG\__m2crypto.lib /MANIFESTFILE:build\temp.win-amd64-3.3\Release\SWIG\__m2crypto.pyd.manifest
_m2crypto_wrap.obj : warning LNK4197: export 'PyInit___m2crypto' specified multiple times; using first specification
Creating library build\temp.win-amd64-3.3\Release\SWIG\__m2crypto.lib and object build\temp.win-amd64-3.3\Release\SWIG\__m2crypto.exp
_m2crypto_wrap.obj : error LNK2019: unresolved external symbol PyString_AsStringAndSize referenced in function m2_PyString_AsStringAndSizeInt
_m2crypto_wrap.obj : error LNK2019: unresolved external symbol PyString_FromStringAndSize referenced in function bn_to_mpi
_m2crypto_wrap.obj : error LNK2019: unresolved external symbol PyInt_AS_LONG referenced in function asn1_integer_set
_m2crypto_wrap.obj : error LNK2019: unresolved external symbol PyBuffer_New referenced in function ec_key_get_public_der
_m2crypto_wrap.obj : error LNK2019: unresolved external symbol PyFile_AsFile referenced in function _wrap_err_print_errors_fp
_m2crypto_wrap.obj : error LNK2019: unresolved external symbol PyFile_Check referenced in function _wrap_err_print_errors_fp
_m2crypto_wrap.obj : error LNK2019: unresolved external symbol PyInstance_New referenced in function ssl_verify_callback
build\lib.win-amd64-3.3\M2Crypto\__m2crypto.pyd : fatal error LNK1120: 7 unresolved externals
What's going on? I'm using Win64 OpenSSL v1.0.1e. Do I need older libraries?
from the full log it looks like one first problem is that the compiler can't find the python c header files. Then the linker can't find the python library. Perhaps the options to cl.exe are not good (shouldn't it be /ID:\... instead of -ID:\...?) or you don't have the python header files installed.