My problem is that when I try to build my cpp project that has #include curl/curl.h in, it cannot dynamically (or statically for the matter) link the DLL curl files with the curl.h header files. I am using CMake, VCPKG, MinGW and cURL. Here is the error message
[ 50%] Linking CXX executable Decentrum.exe
CMakeFilesDecentrum.dir/objects.a(analysis.cpp.obj): In function `Z19fetch_data_from_apiRKNSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEEE':
C:/Users/PC/OneDrive/Desktop/Decentrum/analysis.cpp:19: undefined reference to `_imp__curl_easy_init'
C:/Users/PC/OneDrive/Desktop/Decentrum/analysis.cpp:21: undefined reference to `_imp__curl_easy_setopt'
C:/Users/PC/OneDrive/Desktop/Decentrum/analysis.cpp:22: undefined reference to `_imp__curl_easy_setopt'
C:/Users/PC/OneDrive/Desktop/Decentrum/analysis.cpp:23: undefined reference to `_imp__curl_easy_setopt'
C:/Users/PC/OneDrive/Desktop/Decentrum/analysis.cpp:24: undefined reference to `_imp__curl_easy_perform'
C:/Users/PC/OneDrive/Desktop/Decentrum/analysis.cpp:25: undefined reference to `_imp__curl_easy_cleanup'
collect2.exe: error: ld returned 1 exit status
CMakeFilesDecentrum.dirbuild.make:99: recipe for target 'Decentrum.exe' failed
mingw32-make[2]: *** [Decentrum.exe] Error 1
CMakeFilesMakefile2:81: recipe for target 'CMakeFiles/Decentrum.dir/all' failed
mingw32-make[1]: *** [CMakeFiles/Decentrum.dir/all] Error 2
Makefile:109: recipe for target 'all' failed
mingw32-make: *** [all] Error 2```
My CMakeLists.txt file is:
```cmake_minimum_required(VERSION 3.10)
project(Decentrum)
set(CMAKE_CXX_STANDARD 14)
list(APPEND CMAKE_MODULE_PATH "C:/Program Files/CMake/share/cmake-3.29/Modules")
include(C:/src/vcpkg/scripts/buildsystems/vcpkg.cmake)
set(CURL_LIBRARY "C:/src/vcpkg/packages/curl_x64-windows/lib/libcurl.dll.a")
set(CURL_INCLUDE_DIR "C:/src/vcpkg/packages/curl_x64-windows/include")
find_package(CURL REQUIRED)
set_target_properties(CURL::libcurl PROPERTIES
IMPORTED_LOCATION "C:/src/vcpkg/packages/curl_x64-windows/lib/libcurl.dll.a"
)
add_executable(Decentrum analysis.cpp)
target_link_libraries(Decentrum PRIVATE CURL::libcurl)
``
I looked in the `C:srcvcpkgpackagescurl_x64-windows` directory and there was only libcurl.lib, so i downloaded with the same version, libcurl.dll.a and libcurl.a
As you can tell, I am a beginner with C++ and would really appreciate any help.
I expect mingw32-make (or just running with g++ in VS code) to build my file, but instead it comes up with a linker error.
New contributor
Doge is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.