msys2 / MINGW-packages

Package scripts for MinGW-w64 targets to build under MSYS2.
https://packages.msys2.org
BSD 3-Clause "New" or "Revised" License
2.25k stars 1.21k forks source link

pkgconfig hickups #6545

Closed revelator closed 2 years ago

revelator commented 4 years ago

So after a batch of decidedly odd build failures i noticed the problem seemed to stem from cmake getting irritated because some pkgconfig files was throwing wrongly formatted library strings at it. Then i decided to check those .pc files and guess what i found... the import libraries in some .pc files where in the format ws2_32 winmm etc. and not -lws2_32 -lwinmm as they should be sigh...

this doesnt affect all of them but dlib is one culprit there are others though.

revelator commented 4 years ago

well not only pkgconfig seems to have problems some cmake files seem to only take msvc into account so when cmake is looking for those libraries it gets lib.lib instead of lib.a or lib.dll.a...

openexr is one culprit it uses if (WIN32) instead of if (MSVC) checks. So the reason we dont get a ton of build failures is that cmake also looks for libraries from the pkgconfig files but when those also go bonkers with missing linker info (no -l before the library name) then things get decidedly nasty.

Alexpux commented 4 years ago

@revelator well issues with pkg-config and cmake target files need to be solved. Feel free to post packages with broken files

revelator commented 4 years ago

so far libgit2 dlib openexr openimageio thrift and arrow seems to have problems, ill post more when i have time to go through the rest of the packages.

mati865 commented 4 years ago

@revelator what is wrong with libgit2?

$ bat /mingw64/lib/pkgconfig/libgit2.pc
───────┬───────────────────────────────────────────────────────────────────────
       │ File: D:/msys64/mingw64/lib/pkgconfig/libgit2.pc
───────┼───────────────────────────────────────────────────────────────────────
   1   │ prefix="/mingw64"
   2   │ libdir="${prefix}/lib"
   3   │ includedir="${prefix}/include"
   4   │
   5   │ Name: libgit2
   6   │ Description: The git library, take 2
   7   │ Version: 0.99.0
   8   │ Libs: -L${libdir} -lgit2
   9   │ Libs.private: -lssh2 -lws2_32
  10   │ Requires.private: openssl libpcre zlib
  11   │ Cflags: -I${includedir}
───────┴───────────────────────────────────────────────────────────────────────
lazka commented 4 years ago

dlib is definitely broken:

libdir=/mingw64/lib
includedir=/mingw64/include

Name: dlib
Description: Numerical and networking C++ library
Version: 19.19.0
Libs: -L${libdir} -ldlib ws2_32 winmm comctl32 gdi32 imm32 C:/building/msys64/mingw64/lib/libgif.dll.a C:/building/msys64/mingw64/lib/libpng.dll.a C:/building/msys64/mingw64/lib/libz.dll.a C:/building/msys64/mingw64/lib/libjpeg.dll.a -lcblas -llapack C:/building/msys64/mingw64/lib/libsqlite3.dll.a C:/building/msys64/mingw64/lib/libfftw3.dll.a
Cflags: -I${includedir}  -IC:/building/msys64/mingw64/include -IC:/building/msys64/mingw64/include -IC:/building/msys64/mingw64/include
revelator commented 4 years ago

@alex one of the cmake modules in it complains it cannot parse ws2_32 and bails out, this might be a problem somewhere else though as i havent had trouble with this library before (still investigating).

dlib is indeed a mess :/

revelator commented 4 years ago

Ok got libgit2 building again, seems libssh2 had decided to put -lws2_32 in the wrong place causing a parse error. I moved it to the correct place and it worked again. Still probably a good idea to investigate what caused this.

Alexpux commented 4 years ago

@revelator dlib fix - https://github.com/msys2/MINGW-packages/commit/ddd4f4cbdb931f3d521504bb4d98da96fc327318

revelator commented 4 years ago

OpenVDB in FindCppUnit.cmake

if(WIN32) list(APPEND CMAKE_FIND_LIBRARY_SUFFIXES "_dll.lib" ) elseif(UNIX) if(CPPUNIT_USE_STATIC_LIBS) list(APPEND CMAKE_FIND_LIBRARY_SUFFIXES ".a" ) endif() endif()

should probably be

if(MSVC) list(APPEND CMAKE_FIND_LIBRARY_SUFFIXES "_dll.lib" ) elseif(UNIX OR MINGW) if(CPPUNIT_USE_STATIC_LIBS) list(APPEND CMAKE_FIND_LIBRARY_SUFFIXES ".a" ) endif() endif()

Also one located in FindJemalloc.cmake and one in FindOpenExr.cmake in OpenVDB

OpenExr in FindIlmBase.cmake has a similar problem

revelator commented 4 years ago

Also took the time to update liblas patch, got rid of the libliblas library name its now just liblas as it should be.

liblas-1.8.1.zip

you can just replace the original patch with the zipped version above.

Alexpux commented 4 years ago

@revelator see https://github.com/msys2/MINGW-packages/commit/98bfa64998ac2e7fe9b8ccef336896a6e0a892eb https://github.com/msys2/MINGW-packages/commit/9e8c05014a30605272cfe49391e86d79e49367c6

revelator commented 4 years ago

Great :)

Biswa96 commented 2 years ago

@revelator Is this issue fixed now?

revelator commented 2 years ago

yes as far as i can see all is fine, can close issue if you like.