Narase
Narase

Reputation: 490

Unable to compile libcurl with CMake, unresolved symbols

Im trying to compile libcurl on Win10 with my project in CMake. Currently this is (the libcurl part of) my setup:

link_directories("C:/Program Files/OpenSSL-Win64-1_1_1/lib")
link_directories("C:/Program Files/OpenSSL-Win64-1_1_1")
list(APPEND CMAKE_PREFIX_PATH ${CMAKE_CURRENT_SOURCE_DIR}/out/build/x64-Debug/libssh2-1.10.0/src)
add_subdirectory(curl-7.80.0)

When doing so I get these errors:

Creating library C:/PATH/build/curl-7.80.0/lib/Debug/libcurl-d_imp.lib and object C:/PATH/build/curl-7.80.0/lib/Debug/libcurl-d_imp.exp

libssh2.obj : error LNK2019: unresolved external symbol libssh2_init referenced in function Curl_ssh_init [C:\PATH\curl-7.80.0\build\lib\libcurl.vcxproj]

libssh2.obj : error LNK2019: unresolved external symbol libssh2_exit referenced in function Curl_ssh_cleanup [C:\PATH\curl-7.80.0\build\lib\libcurl.vcxproj]

libssh2.obj : error LNK2019: unresolved external symbol libssh2_session_init_ex referenced in function ssh_force_kno wnhost_key_type [C:\PATH\curl-7.80.0\build\lib\libcurl.vcxproj]

libssh2.obj : error LNK2019: unresolved external symbol libssh2_session_abstract referenced in function sftp_perform [C:\PATH\curl-7.80.0\build\lib\libcurl.vcxproj]

OpenSSL was installed via this installer: https://slproweb.com/products/Win32OpenSSL.html

I dont really know much about CMake, typically enough to build my own projects, but this is a bit over my head. I gladly appreciate every help you can give me.

Edit 1: actual link command as given by CMake:

Link:

C:\Program Files (x86)\Microsoft Visual Studio\2019\Professional\VC\Tools\MSVC\14.29.30133\bin\HostX64\x64\link.exe /ERRORREPORT:QUEUE /OUT:"C:\PATH\bin\64bit_\Debug\libcurl-d.dll" /INCREMENTAL /ILK:"libcurl.dir
Debug\libcurl-d.ilk" /NOLOGO /LIBPATH:"C:/Program Files/OpenSSL-Win64-1_1_1/lib" /LIBPATH:"C:/Program Files/OpenSS L-Win64-1_1_1/lib/Debug" /LIBPATH:"C:/Program Files/OpenSSL-Win64-1_1_1" /LIBPATH:"C:/Program Files/OpenSSL-Win64- 1_1_1/Debug" /LIBPATH:"C:/PATH/out/build/x64-Debug/libssh2-1.10.0/src" /LIBPATH:"C:/PATH/out/build/x64-Debug/libssh2-1.10.0/src/Debug" /LIBPATH:"C:/PATH/out/build/x64-Debug/libssh2 -1.10.0" /LIBPATH:"C:/PATH/out/build/x64-Debug/libssh2-1.10.0/Debug" wldap32.lib winmm.lib ws2_32. lib "......\out\build\x64-Debug\libssh2-1.10.0\src\libssh2.lib" advapi32.lib crypt32.lib kernel32.lib user32.lib gdi32.lib winspool.lib shell32.lib ole32.lib oleaut32.lib uuid.lib comdlg32.lib advapi32.lib /MANIFEST /MANIFESTU AC:"level='asInvoker' uiAccess='false'" /manifest:embed /DEBUG /PDB:"C:/PATH/bin/64bit_/Debug/libc url-d.pdb" /SUBSYSTEM:CONSOLE /TLBID:1 /DYNAMICBASE /NXCOMPAT /IMPLIB:"C:/PATH/build/curl-7.80.0/l ib/Debug/libcurl-d_imp.lib" /MACHINE:X64 /machine:x64 /DLL libcurl.dir\Debug\libcurl.res

Edit 2: dumpbin for libssh2_exit

00C 00000050 SECT4 notype () External | libssh2_exit

01B 00000008 SECT5 notype Static | $unwind$libssh2_exit

01C 0000000C SECT6 notype Static | $pdata$libssh2_exit

Upvotes: 0

Views: 881

Answers (1)

Narase
Narase

Reputation: 490

So to answer this:

libcurl wasnt trying to build with OpenSSl, I neede to use a flag -DCMAKE_USE_OPENSSL to get libcurl to use it. Further my installer installed two different libs, OpenSSL and OpenSSL-1_1_1. The second one brought an error, the first one was a success

Upvotes: 0

Related Questions