2

I would like to use in my cygwin project Bonjour library for Windows. I have installed this library and I have dnssd.lib file but CMake doesn't find this library.

If I use this code:

  find_path(BONJOUR_PATH dns_sd.h
            PATHS "$ENV{BONJOUR_SDK_HOME}/Include")
    find_library(BONJOUR_LIBRARY
            NAMES dnssd.lib
            PATHS "$ENV{BONJOUR_SDK_HOME}/Lib/x64")
    include_directories(BONJOUR_PATH)

I am getting such error message:

CMake Error: The following variables are used in this project, but they are set to NOTFOUND. Please set them or make sure they are set and tested correctly in the CMake files: BONJOUR_LIBRARY (ADVANCED)

It happens only when I wrap above code inside if(CYGWIN) /* code */ endif() but if I wrap it inside if(WIN32) /* code */ endif() then it finds library correctly.

Why this happens?

Michał Ziobro
  • 10,759
  • 11
  • 88
  • 143
  • 1
    cygwin import library are `*.dll.a` not `*.lib` – matzeri May 24 '17 at 18:01
  • But with Bonjour SDK I have delivered *.lib, so what should I do? Couldn't I mix unix libraries with native Windows libraries? – Michał Ziobro May 24 '17 at 18:08
  • You should not mix different libraries. Or you use Unix convention or Windows one. Mixing is a recipe for mulfunction. It is specially true on 64 bit where also the data type convention are different. https://cygwin.com/cygwin-ug-net/programming.html#gcc-64 – matzeri May 24 '17 at 18:30
  • 1
    But dnssd.lib is 3rd party library so how I can use? Couldn't I use 3rd party libraries with cygwin? – Michał Ziobro May 24 '17 at 18:43
  • Cygwin has that library. Install libdns_sd-devel package. https://cygwin.com/packages/x86_64/libdns_sd-devel/libdns_sd-devel-765.30.11-1 – matzeri May 24 '17 at 19:09
  • How can I install it? – Michał Ziobro May 24 '17 at 19:38
  • I once had a similar problem when `cygwin` was using my Windows CMake version. Can you cross-check that you have the CMake Cygwin package installed (specialized CMake version for Cygwin, see e.g. [here](https://stackoverflow.com/questions/3586210/cmake-building-for-cygwin))? – Florian May 24 '17 at 20:28
  • Ok I found I can use Cygwin Setup :) I forgot that there is such option to select packages/libraries – Michał Ziobro May 25 '17 at 11:43

1 Answers1

1

While this answer may not apply to the OP's specific situation, I believe it does apply to the question. In my case I'm using cmake & Cygwin, but am trying to run a cmake project that was originally done on Linux with cmake v2.8. In my case, I'm using cmake v3.6.2, Cygwin v2.9.0-2, Windows 10.

To get cmake to find the libraries, I added this statement:

IF (CYGWIN)
  SET (CMAKE_FIND_LIBRARY_PREFIXES "")
  SET (CMAKE_FIND_LIBRARY_SUFFIXES ".lib" ".LIB" ".dll" ".DLL")
ELSE()
  SET (CMAKE_FIND_LIBRARY_PREFIXES "lib")
  SET (CMAKE_FIND_LIBRARY_SUFFIXES ".so" ".a")
ENDIF (CYGWIN)

Note that I added lib and dll in all caps, because while windows isn't case sensitive, cmake is.

Credit to Domen Vrankar for pointing out the prefix issue as well here

PfunnyGuy
  • 750
  • 9
  • 22