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.
Related
How are you doing?
The error message:
nativehost.obj : error LNK2019: unresolved external symbol __imp__get_hostfxr_path#12 referenced in function "bool __cdecl `anonymous namespace'::load_hostfxr(void)" (?load_hostfxr#?A0x85d553db##YA_NXZ) [C:\Users\Ray\Desktop\Blazor\samples\core\hosting\HostWithHostFxr\src\NativeHost\NativeHost.csproj]
C:\Program Files\dotnet\packs\Microsoft.NETCore.App.Host.win-x64\3.1.6\runtimes\win-x64\native\nethost.lib : warning LNK4272: library machine type 'x64' conflicts with target machine type 'x86
I have installed DotNetCore SDK(3.1.6) and it is the latest version in my environment,
and get_hostfxr_path is a function from nethost.h
I think I need to link the nethost.lib, but I don't how to link the file in Developer Command Prompt for VS2019
Thanks
The Developer Command Prompt for VS is x86 (32-bit) tools. If you want x64 native tools, you should use the "x64 Native Tools Command Prompt". The "x86_x64 Tools Command Prompt" would also work to target x64 native.
I'm new to CMake and also new to compiling mixed source, I have received the following errors while trying to compile using CMake and Visual Studio 14.0
(Link target) ->
main.obj : error LNK2001: unresolved external symbol ethash_get_cachesize
main.obj : error LNK2001: unresolved external symbol ethash_get_datasize
The layout of my project is like this:
I have ethash_get_cachesize and ethash_get_datasize defined in internal.c in a directory ethminer/libethash/ these are C source. im sure that the CMake file that came with this set of sources is ok as the project has compiled before without issue, it has only given me LINK problems after i have added the following:
I have another directory /ethminer/dag/ with a C++ source "dag.cpp" and "dag.h" these are both C++ files. and the CMake file.
set(SOURCES
DAG.h DAG.cpp
)
include_directories(BEFORE ..)
link_directories(BEFORE ..)
the C++ source file "dag.cpp" includes #include <libethash/internal.h>
however I fear that I am missing something to tell CMake or Visual Studio to find the files it needs from the directory containing "internal.c"
any help would be much appreciated
I can't build QCharts module using Visual Studio on Windows 64bit. A link error occurs:
fatal error LNK1112: module machine type 'x64' conflicts with target machine type 'X86'
Steps:
Download from: qtcharts-opensource-src-5.7.0-rc.zip
Setting environment on prompt (qtenv2.bat and vcvarsall.bat)
execute qmake and nmake on QCharts directory
How to build with platform flag using qmake and nmake on Windows 64bit?
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)
I have a large and complicated project that is finally getting unit tests. I've built googleTest 1.6.0 locally with Visual Studio 2010, the project files built with cmake as the README specifies.
This project has many dependent libraries that are statically and dynamically linked. Many of them proprietary. All attempts to link generate 220 such errors. Here is a sampling:
msvcprtd.lib(MSVCP100D.dll) : error LNK2005: "public: void __cdecl std::_Container_base12::_Orphan_all(void)" (?_Orphan_all#_Container_base12#std##QEAAXXZ) already defined in gtest.lib(gtest-all.obj)
libcpmtd.lib(cerr.obj) : error LNK2005: "protected: char * __cdecl std::basic_streambuf >::_Gndec(void)" (?_Gndec#?$basic_streambuf#DU?$char_traits#D#std###std##IEAAPEADXZ) already defined in msvcprtd.lib(MSVCP100D.dll)
LIBCMTD.lib(setlocal.obj) : error LNK2005: _configthreadlocale already defined in MSVCRTD.lib(MSVCR100D.dll)
LINK : warning LNK4098: defaultlib 'MSVCRTD' conflicts with use of other libs; use /NODEFAULTLIB:library
LINK : warning LNK4098: defaultlib 'LIBCMTD' conflicts with use of other libs; use /NODEFAULTLIB:library
fatal error LNK1169: one or more multiply defined symbols found
I've tried the /NODEFAULTLIB flag, and I've tried to ignore just msvcprtd.lib, MSVCRTD.lib, and LIBCMTD.lib, as suggested, but then I suffer from unresolved symbols...
Both the project and googleTest are compiled with x64, /MP, /MDd, and no /clr.
I've been playing around with compiler flags, wondering if there's some sort of version mismatch. Dumpbin, to the extent with which I understand it, hasn't hinted anything I might understand. I was hoping for an er
It looks like your question is answered in Google Talk's FAQ. Make sure all your libraries use the /MD(d) setting.
You may get a number of the following linker error or warnings if you attempt to link your test project with the Google Test library when your project and the are not built using the same compiler settings.
LNK2005: symbol already defined in object
LNK4217: locally defined symbol 'symbol' imported in function 'function'
LNK4049: locally defined symbol 'symbol' imported
The Google Test project (gtest.vcproj) has the Runtime Library option set to /MT (use multi-threaded static libraries, /MTd for debug). If your project uses something else, for example /MD (use multi-threaded DLLs, /MDd for debug), you need to change the setting in the Google Test project to match your project's.
To update this setting open the project properties in the Visual Studio IDE then select the branch Configuration Properties | C/C++ | Code Generation and change the option "Runtime Library". You may also try using gtest-md.vcproj instead of gtest.vcproj.