LNK2019 unresolved external symbols when compiling using libxml2 in microsoft visual studio - visual-studio

built libxml2 using cscript, added the include path in Properties->C/C++->Additional include directories and the path to libxml2_a.lib in Properties->linker->Additional dependencies.
Are there any macro definitions to add if libxml2 is linked statically to my code?

Related

Build errors while using libcurl in visual studio 2019

I am trying to get libcurl to work. I am using libcurl for the first time. I installed libcurl using vcpkg.
C:\Users\infib\vcpkg>vcpkg install curl
The following packages are already installed:
curl[core,ssl,tool,winssl]:x86-windows
Starting package 1/1: curl:x86-windows
Package curl:x86-windows is already installed
Elapsed time for package curl:x86-windows: 4.298 ms
Total elapsed time: 4.956 ms
The package curl:x86-windows provides CMake targets:
find_package(CURL CONFIG REQUIRED)
target_link_libraries(main PRIVATE CURL::libcurl)
I installed opencv64 bit and I am trying to use libcurl but I am getting many errors.
error LNK2019: unresolved external symbol __imp_curl_easy_init
error LNK2019: unresolved external symbol __imp_curl_easy_setopt
error LNK2019: unresolved external symbol __imp_curl_easy_perform
error LNK2019: unresolved external symbol __imp_curl_easy_cleanup
error LNK2019: unresolved external symbol __imp_curl_easy_getinfo
1>libcurl_a.lib : warning LNK4272: library machine type 'x86' conflicts with target machine type 'x64'
1>libcurl-d.lib : warning LNK4272: library machine type 'x86' conflicts with target machine type 'x64'
1>libcurl.lib : warning LNK4272: library machine type 'x86' conflicts with target machine type 'x64'
1>WINMM.LIB : warning LNK4272: library machine type 'x86' conflicts with target machine type 'x64'
1>wldap32.lib : warning LNK4272: library machine type 'x86' conflicts with target machine type 'x64'
1>ws2_32.lib : warning LNK4272: library machine type 'x86' conflicts with target machine type 'x64'
Could some one tell me how to over come this error. I included libcurl.lib that I found in vcpkg packages folder but still I am getting this error. I tried all the methods mentioned in stackover flow libcurl thread but still I am getting the errors.
Please let me know how to solve this.
It looks like the core of your issue is x64 vs x86. vcpkg likely is pulling in the x86 build. Honestly the solution I used was to pull the source for curl directly and use cmake. Once you have the source you need to run a script like this (in the curl directory):
mkdir build32
pushd build32
cmake -G "Visual Studio 16 2019" -A Win32 ..
popd
cmake --build build32 // this will compile it for you
mkdir build64
pushd build64
cmake -G "Visual Studio 16 2019" -A x64 ..
popd
cmake --build build64 // same as above
this will make a shared library. If you want a static lib you will need to go into the CMakeLists.txt file and update
option(BUILD_SHARED_LIBS "Build shared libraries" ON)
to
option(BUILD_SHARED_LIBS "Build shared libraries" OFF)
which will enable a static build.
you will find the necessary .lib and .dll files under the respective build
lib and type folder e.g. debug 64 would be build64\lib\Debug
hope this helps.

PCRE metro app visual studio 2013

I am trying to link pcre.lib in my metro app on visual studio 2013. I want to use the library in a .cpp file (the pcre project contains .c files).
I tried to build pcre project and use the generated lib file and the original headers. The problem is on compiling, because on each function i use from pcre library it says (the next example is for pcre_study function) :
error LNK2001: unresolved external symbol __imp_pcre_study
I want to mention that i linked the .lib file correctly and i added all the paths required. Probably the problem is when i am building the pcre project.
Can anyone help me ?

libsndfile library build error in VS 2012 Vc++ app project

I am creating Visual Studio VC++ app project on Win 7, that utilizes the libsndfile library.
The library( libsndfile-1.dll,libsndfile-1.dll) is at :
C:\SVN\US\AdditionalIncludeDir\libsndfile
and its headers(sndfile.hh,sndfile.h) at
C:\SVN\US\AdditionalIncludeDir\Include
the Visual Studio Project is at :
C:\SVN\US\Simulation\audioSim.vcxproj
I have added the library header reference as:
Project properties->C/C++->General->Additional Include Directories->
..\AdditionalIncludeDir\Include
and static lib reference as
Project properties->Linker>Additional dependencies:
libsndfile-1.lib
Project properties->Linker>Additional Library
Dir:..\AdditionalIncludeDir\libsndfile
I also have added
..\AdditionalIncludeDir\libsndfile
to path in user environment variable in Win 7.
The toplevel C++ file uses the library as:
SndfileHandle mic1(".\\filedata\\mic1.wav");
where mic1.wav is at
C:\SVN\US\Simulation\filedata
Building the project still gives me error:
error LNK2019: unresolved external symbol _sf_open referenced in
function "public: __thiscall SndfileHandle::SndfileHandle(char const
*,int,int,int,int)" (??0SndfileHandle##QAE#PBDHHHH#Z)
Why would this happen?
Thanks
sedy
I also had this problem. I had set "Additional Include Directories" (C:\Program Files (x86)\Mega-Nerd\libsndfile\include) and "Additional Library Directories" (C:\Program Files %28x86%29\Mega-Nerd\libsndfile\lib) in the project settings.
This fixed the problem:
Go to project properties -> Configuration properties -> Linker -> Input and type in the lib file name libsndfile-1.lib in the "Additional Dependencies" field.

Can't Install MSVCP100.dll

I'm using CMake to build a Qt based application of mine on Windows with Visual Studio 2010 Express. When configuring with cmake I get the following error:
System runtime library file does not exists:
'MSVC10_REDIST_DIR-NOTFOUND/x86/Microsoft.VC100.CRT/msvcp100.dll
System runtime library file does not exists:
'MSVC10_REDIST_DIR-NOTFOUND/x86/Microsoft.VC100.CRT/msvcr100.dll
Then when I try to compile, I'm getting this error (both trying in Visual Studio, and with msbuild):
MSVCRT.lib(crtexew.obj) : error LNK2019: unresolved external symbol _WinMain#16 referenced in function ___tmainCRTStartup
C:\Users\Kurtis\sandbox\UDJ-Desktop-Client\build\src\Release\UDJ.exe : fatal error LNK1120: 1 unresolved externals
I determined that Microsoft Visual C++ 2010 Express doesn't come with the redistributable that I need. So I went to Microsoft's website to download the redistributable (both for x86 and x64). However, after installing it, I'm still getting the above configure and compile errors. Does anyone know what I'm doing wrong, or how to fix my problem?
_WinMain#16 is the entry point of a Windows GUI application, so either it's missing from your source code, or you're not writing a GUI application, in which case your linker flags are incorrect.
Since you're using qt, make sure you have the QtMain Library being linked with your project. You can do this by adding it in your call to Find_Package like so:
find_package(Qt4 4.7.0 COMPONENTS QtMain QtCore QtGui QtSQL Phonon REQUIRED)

Visual Studio Boost Thread /MT Linking Issues

I am using boost's threading library and have run into linking issues in Visual Studio.
Right now, I'm compiling my VS project with /MT. The library I'm linking against is called libboost_thread-vc100-mt-1_48.lib, which seems to indicate that it, too has been compiled using /MT.
However, if I turn off all /MD related libraries in my linker settings (properties -> Linker -> Input -> Ignore Specific Default Libraries)...
msvcrt.lib
msvcrtd.lib
msvcprt.lib
msvcprtd.lib
Then I get linker errors!
libboost_thread-vc100-mt-1_48.lib(thread.obj) : error LNK2001: unresolved external symbol __imp___gmtime64
libboost_thread-vc100-mt-1_48.lib(thread.obj) : error LNK2001: unresolved external symbol __imp___beginthreadex
How could this be possible just by turning off /MD related libraries? boost::thread should only be linking against libs in /MT (Which should be LIBCMT.LIB, LIBCPMT.LIB). Did I compile boost incorrectly?
BAM! Linker defeated!
It looks like my hunch was right. I didn't compile boost correctly. To emulate /MT with a boost build, you need to link against static runtime libraries (linking to dynamic runtime libraries seems to be the default).
The command to do this (for Release build of boost::thread) was:
.\b2 --with-thread variant=release link=static threading=multi runtime-link=static
Hope this helps someone out there using boost with /MT turned on in their project!

Resources