vsg-dev / vsgXchange

Utility library for converting data+materials to/from VulkanSceneGraph
MIT License
70 stars 41 forks source link

Linker errors when trying to link with curl #191

Closed ComradeMashkov closed 5 months ago

ComradeMashkov commented 5 months ago

When trying to link with curl using Visual Studio 17 2022 generator I get following errors: image

I tried using CURL_STATICLIB directive but it didn't help at all. I would be so grateful if somebody can help me to fix this nasty error! Btw, maybe I'm doing something wrong?

UPD: I also tried linking to wldap32 crypt32 Ws2_32 but it didn't help. UPD2: I explicitly added curl lib to target via vsgXchange CMakeLists.txt: image Now everything get built but when running this example I get this: image

I put .dlls into my folder and everything works fine (I guess?) but I feel I'm missing something.

robertosfield commented 5 months ago

What source for libcurl are you using?

ComradeMashkov commented 5 months ago

What source for libcurl are you using?

I use curl installed via vcpkg. The path for curl binaries and headers are in my PATH variable and CMake see libcurl while configuration process, but it crashes while building if I don't explicitly link libcurl to target in the CMake file.

So it certainly does compile but I feel that I shouldn't necessarily link libcurl. It's hard for me to say what have gone wrong and I suspect that my vsg also work the wrong way (some shaders and lights are missing, map zooming is laggy).

robertosfield commented 5 months ago

If CMake finds the libcurl package on configuration it should work out of the box without needing any further changes. When you say it crashes while building what crashes?

I mostly use Linux for dev work and have only recently started using Windows 11 and vcpkg. I haven't yet had issues with libcurl but I'll check what version is being used. Performance is perfect on par with what I see on Windows.

Perhaps a git update on your vcpkg reoo might be helpful.

As for missing shaders and lights, without information about what exactly you are attempting to do and what results you are getting there is nothing we can do to help address these issues.

robertosfield commented 5 months ago

In case this helps, I've booted up my Windows 11 machine and these the packages and versions I've installed from vcpkg to work with the VSG. I did a git update of my local vcpkg repo yesterday and upgraded the packages to the latest then rebuilt the VSG projects. As I test I just ran vsgviewer.exe models/openstreetmap.vsgt and it works fine for me, no lags or issues with lighting.

 .\vcpkg.exe list
assimp:x64-windows                                5.4.0               The Open Asset import library
brotli:x64-windows                                1.1.0#1             a generic-purpose lossless compression algorithm...
bzip2:x64-windows                                 1.0.8#5             bzip2 is a freely available, patent free, high-q...
bzip2[tool]:x64-windows                                               Builds bzip2 executable
curl:x64-windows                                  8.7.1#3             A library for transferring data with URLs
curl[non-http]:x64-windows                                            Enables protocols beyond HTTP/HTTPS/HTTP2
curl[schannel]:x64-windows                                            SSL support (Secure Channel)
curl[ssl]:x64-windows                                                 Default SSL backend
curl[sspi]:x64-windows                                                SSPI support
draco:x64-windows                                 1.5.7               A library for compressing and decompressing 3D g...
freetype:x64-windows                              2.13.2#1            A library to render fonts.
freetype[brotli]:x64-windows                                          Support decompression of WOFF2 streams
freetype[bzip2]:x64-windows                                           Support bzip2 compressed fonts.
freetype[png]:x64-windows                                             Support PNG compressed OpenType embedded bitmaps.
freetype[zlib]:x64-windows                                            Use zlib instead of internal library for DEFLATE
glslang:x64-windows                               14.2.0              Khronos-reference front end for GLSL/ESSL, parti...
imath:x64-windows                                 3.1.11              Imath is a C++ and Python library of 2D and 3D v...
jhasse-poly2tri:x64-windows                       2023-12-27          Sweep-line algorithm for constrained Delaunay tr...
kubazip:x64-windows                               0.2.6               A portable, simple zip library written in C
libdeflate:x64-windows                            1.20                libdeflate is a library for fast, whole-buffer D...
libdeflate[compression]:x64-windows                                   Support compression
libdeflate[decompression]:x64-windows                                 Support decompression
libdeflate[gzip]:x64-windows                                          Support the gzip format
libdeflate[zlib]:x64-windows                                          Support the zlib format
libpng:x64-windows                                1.6.43#1            libpng is a library implementing an interface fo...
minizip:x64-windows                               1.3.1               Minizip zip file manipulation library
openexr:x64-windows                               3.2.3#1             OpenEXR is a high dynamic-range (HDR) image file...
physx:x64-windows                                 5.3.0               The NVIDIA PhysX SDK is a scalable multi-platfor...
polyclipping:x64-windows                          6.4.2#12            The Clipper library performs clipping and offset...
pugixml:x64-windows                               1.14                Light-weight, simple and fast XML parser for C++...
rapidjson:x64-windows                             2023-07-17#1        A fast JSON parser/generator for C++ with both S...
stb:x64-windows                                   2023-04-11#1        public domain header-only libraries
utfcpp:x64-windows                                4.0.5               UTF-8 with C++ in a Portable Way
vcpkg-cmake-config:x64-windows                    2022-02-06#1
vcpkg-cmake-get-vars:x64-windows                  2023-12-31
vcpkg-cmake:x64-windows                           2024-04-18
zlib:x64-windows                                  1.3.1               A compression library
ComradeMashkov commented 5 months ago

Thanks a lot for your reply! I'll try this out and comment back with the information.

ComradeMashkov commented 5 months ago

Ok I installed all your packages in vcpkg and it seems to me that our packages are similar, here is the list:

vcpkg list ```bash .\vcpkg.exe list assimp:x64-windows 5.4.0 The Open Asset import library brotli:x64-windows 1.1.0#1 a generic-purpose lossless compression algorithm... bzip2:x64-windows 1.0.8#5 bzip2 is a freely available, patent free, high-q... bzip2[tool]:x64-windows Builds bzip2 executable curl:x64-windows 8.7.1#3 A library for transferring data with URLs curl[non-http]:x64-windows Enables protocols beyond HTTP/HTTPS/HTTP2 curl[schannel]:x64-windows SSL support (Secure Channel) curl[ssl]:x64-windows Default SSL backend curl[sspi]:x64-windows SSPI support draco:x64-windows 1.5.7 A library for compressing and decompressing 3D g... freetype:x64-windows 2.13.2#1 A library to render fonts. freetype[brotli]:x64-windows Support decompression of WOFF2 streams freetype[bzip2]:x64-windows Support bzip2 compressed fonts. freetype[png]:x64-windows Support PNG compressed OpenType embedded bitmaps. freetype[zlib]:x64-windows Use zlib instead of internal library for DEFLATE glslang:x64-windows 14.2.0 Khronos-reference front end for GLSL/ESSL, parti... imath:x64-windows 3.1.11 Imath is a C++ and Python library of 2D and 3D v... jhasse-poly2tri:x64-windows 2023-12-27 Sweep-line algorithm for constrained Delaunay tr... kubazip:x64-windows 0.2.6 A portable, simple zip library written in C libdeflate:x64-windows 1.20 libdeflate is a library for fast, whole-buffer D... libdeflate[compression]:x64-windows Support compression libdeflate[decompression]:x64-windows Support decompression libdeflate[gzip]:x64-windows Support the gzip format libdeflate[zlib]:x64-windows Support the zlib format libpng:x64-windows 1.6.43#1 libpng is a library implementing an interface fo... minizip:x64-windows 1.3.1 Minizip zip file manipulation library openexr:x64-windows 3.2.3#1 OpenEXR is a high dynamic-range (HDR) image file... physx:x64-windows 5.3.0 The NVIDIA PhysX SDK is a scalable multi-platfor... polyclipping:x64-windows 6.4.2#12 The Clipper library performs clipping and offset... pugixml:x64-windows 1.14 Light-weight, simple and fast XML parser for C++... rapidjson:x64-windows 2023-07-17#1 A fast JSON parser/generator for C++ with both S... stb:x64-windows 2023-04-11#1 public domain header-only libraries utfcpp:x64-windows 4.0.5 UTF-8 with C++ in a Portable Way vcpkg-cmake-config:x64-windows 2022-02-06#1 vcpkg-cmake-get-vars:x64-windows 2023-12-31 vcpkg-cmake:x64-windows 2024-04-18 zlib:x64-windows 1.3.1 A compression library ```

I tried one more time to build VSG and vsgXchange. VSG is built with no erros (there were no problems with VSG building btw), but vsgXchange gives me the same error :(

I will give commands instruction that I used to build vsgXchange. I hope it will help us to investigate what is going wrong.

  1. cmake .. (it is built with VS 17 2022 generator, I also tried explicitly define generator but it didn't help)
  2. The output for the command above is the following:
cmake .. output
Z:\dev\vsgXchange\build>cmake ..
-- Building for: Visual Studio 17 2022
-- Selecting Windows SDK version 10.0.22621.0 to target Windows 10.0.19045.
-- The CXX compiler identification is MSVC 19.37.32822.0
-- The C compiler identification is MSVC 19.37.32822.0
-- Detecting CXX compiler ABI info
-- Detecting CXX compiler ABI info - done
-- Check for working CXX compiler: C:/Program Files/Microsoft Visual Studio/2022/Community/VC/Tools/MSVC/14.37.32822/bin/Hostx64/x64/cl.exe - skipped
-- Detecting CXX compile features
-- Detecting CXX compile features - done
-- Detecting C compiler ABI info
-- Detecting C compiler ABI info - done
-- Check for working C compiler: C:/Program Files/Microsoft Visual Studio/2022/Community/VC/Tools/MSVC/14.37.32822/bin/Hostx64/x64/cl.exe - skipped
-- Detecting C compile features
-- Detecting C compile features - done
-- Found Vulkan: C:/VulkanSDK/1.3.283.0/Lib/vulkan-1.lib (found suitable version "1.3.283", minimum required is "1.1.70.0") found components: glslc glslangValidator
-- Performing Test CMAKE_HAVE_LIBC_PTHREAD
-- Performing Test CMAKE_HAVE_LIBC_PTHREAD - Failed
-- Looking for pthread_create in pthreads
-- Looking for pthread_create in pthreads - not found
-- Looking for pthread_create in pthread
-- Looking for pthread_create in pthread - not found
-- Found Threads: TRUE
-- Reading 'vsg_...' macros from C:/vcpkg/installed/x64-windows/lib/cmake/vsg/vsgMacros.cmake - look there for documentation
-- Found Freetype: C:/vcpkg/installed/x64-windows/lib/freetype.lib (found version "2.13.2")
-- Found CURL: C:/vcpkg/installed/x64-windows/share/curl/CURLConfig.cmake (found version "8.7.0-DEV")
-- The following OPTIONAL packages have been found:

 * vsg (required version >= 1.1.3)
 * Freetype
 * CURL
 * Threads

-- The following REQUIRED packages have been found:

 * Vulkan (required version >= 1.1.70.0)

-- Configuring done (11.8s)
-- Generating done (0.0s)
-- Build files have been written to: Z:/dev/vsgXchange/build

  1. cmake --build . -j 19
  2. The output for the command above:
cmake --build output ```bash Z:\dev\vsgXchange\build>cmake --build . -j 19 Версия MSBuild 17.7.2+d6990bcfa для .NET Framework 1>Checking Build System Building Custom Rule Z:/dev/vsgXchange/src/CMakeLists.txt Version.cpp all.cpp cpp.cpp stbi.cpp Z:\dev\vsgXchange\src\stbi\stb_image_write.h(776,13): warning C4996: 'sprintf': This function or variable may be unsafe . Consider using sprintf_s instead. To disable deprecation, use _CRT_SECURE_NO_WARNINGS. See online help for details. [ Z:\dev\vsgXchange\build\src\vsgXchange.vcxproj] dds.cpp images.cpp freetype.cpp assimp.cpp SceneConverter.cpp ktx.cpp GDAL_fallback.cpp curl.cpp openexr.cpp Создание кода... checkheader.c createdfd.c interpretdfd.c printdfd.c queries.c vk2dfd.c filestream.c hashlist.c memstream.c swap.c texture.c texture1.c texture2.c vkloader.c zstddeclib.c Создание кода... vsgXchange.vcxproj -> Z:\dev\vsgXchange\build\lib\Debug\vsgXchanged.lib Building Custom Rule Z:/dev/vsgXchange/applications/vsgconv/CMakeLists.txt vsgconv.cpp vsgXchanged.lib(curl.obj) : error LNK2019: ссылка на неразрешенный внешний символ __imp_curl_global_init в функции "pub lic: __cdecl vsgXchange::curl::Implementation::Implementation(void)" (??0Implementation@curl@vsgXchange@@QEAA@XZ). [Z:\ dev\vsgXchange\build\applications\vsgconv\vsgconv.vcxproj] vsgXchanged.lib(curl.obj) : error LNK2019: ссылка на неразрешенный внешний символ __imp_curl_global_cleanup в функции " public: virtual __cdecl vsgXchange::curl::Implementation::~Implementation(void)" (??1Implementation@curl@vsgXchange@@UE AA@XZ). [Z:\dev\vsgXchange\build\applications\vsgconv\vsgconv.vcxproj] vsgXchanged.lib(curl.obj) : error LNK2019: ссылка на неразрешенный внешний символ __imp_curl_easy_strerror в функции "p ublic: class vsg::ref_ptr __cdecl vsgXchange::curl::Implementation::read(class vsg::Path const &,cla ss vsg::ref_ptr)const " (?read@Implementation@curl@vsgXchange@@QEBA?AV?$ref_ptr@VObject@vsg@ @@vsg@@AEBVPath@5@V?$ref_ptr@$$CBVOptions@vsg@@@5@@Z). [Z:\dev\vsgXchange\build\applications\vsgconv\vsgconv.vcxproj] vsgXchanged.lib(curl.obj) : error LNK2019: ссылка на неразрешенный внешний символ __imp_curl_easy_init в функции "publi c: class vsg::ref_ptr __cdecl vsgXchange::curl::Implementation::read(class vsg::Path const &,class v sg::ref_ptr)const " (?read@Implementation@curl@vsgXchange@@QEBA?AV?$ref_ptr@VObject@vsg@@@vs g@@AEBVPath@5@V?$ref_ptr@$$CBVOptions@vsg@@@5@@Z). [Z:\dev\vsgXchange\build\applications\vsgconv\vsgconv.vcxproj] vsgXchanged.lib(curl.obj) : error LNK2019: ссылка на неразрешенный внешний символ __imp_curl_easy_setopt в функции "pub lic: class vsg::ref_ptr __cdecl vsgXchange::curl::Implementation::read(class vsg::Path const &,class vsg::ref_ptr)const " (?read@Implementation@curl@vsgXchange@@QEBA?AV?$ref_ptr@VObject@vsg@@@ vsg@@AEBVPath@5@V?$ref_ptr@$$CBVOptions@vsg@@@5@@Z). [Z:\dev\vsgXchange\build\applications\vsgconv\vsgconv.vcxproj] vsgXchanged.lib(curl.obj) : error LNK2019: ссылка на неразрешенный внешний символ __imp_curl_easy_perform в функции "pu blic: class vsg::ref_ptr __cdecl vsgXchange::curl::Implementation::read(class vsg::Path const &,clas s vsg::ref_ptr)const " (?read@Implementation@curl@vsgXchange@@QEBA?AV?$ref_ptr@VObject@vsg@@ @vsg@@AEBVPath@5@V?$ref_ptr@$$CBVOptions@vsg@@@5@@Z). [Z:\dev\vsgXchange\build\applications\vsgconv\vsgconv.vcxproj] vsgXchanged.lib(curl.obj) : error LNK2019: ссылка на неразрешенный внешний символ __imp_curl_easy_cleanup в функции "pu blic: class vsg::ref_ptr __cdecl vsgXchange::curl::Implementation::read(class vsg::Path const &,clas s vsg::ref_ptr)const " (?read@Implementation@curl@vsgXchange@@QEBA?AV?$ref_ptr@VObject@vsg@@ @vsg@@AEBVPath@5@V?$ref_ptr@$$CBVOptions@vsg@@@5@@Z). [Z:\dev\vsgXchange\build\applications\vsgconv\vsgconv.vcxproj] Z:\dev\vsgXchange\build\bin\Debug\vsgconvd.exe : fatal error LNK1120: неразрешенных внешних элементов: 7 [Z:\dev\vsgXch ange\build\applications\vsgconv\vsgconv.vcxproj] ```

P.S. Sorry for cyrillic letters in my MSVC output, for now I can't change it.

So it crashes on the building stage connected with class, implementing libcurl features. Of course I can explicitly define linking to libcurl in CMakeLists.txt, but I feel it is not a solution.

robertosfield commented 5 months ago

I don't recall anyone else hitting upon this issue, and can't think of anything you can try to resolve it.

FYI, while I have 3 decades of working with unix of various flavours I'm a newbie under Windows so will have to defer to Windows users to help you out. Asking a question on the VulkanSceneGraph forum might help reach a wider audience and better chance of getting the help you need.

robertosfield commented 5 months ago

@ComradeMashkov could you try #192 which is now merged with vsgXchange master. as @AnyOldName3 has added support for setting up libcurl using cmake config.

ComradeMashkov commented 5 months ago

@ComradeMashkov could you try #192 which is now merged with vsgXchange master. as @AnyOldName3 has added support for setting up libcurl using cmake config.

Hey, thanks for your reply and brand new commit. I tried to build again with these changes and it helped! Thanks @robertosfield for you being in touch and thanks @AnyOldName3 for this PR. I hope it will help other users to deal with this problem. It seems to me that we can close the issue.