Post Go back to editing

Cross compiling libiio from linux to windows

Category: Software
Product Number: libiio

Hello, 

I have a project with a cmakelist.txt that I cross compile to windows from ubuntu. This project depends on libiio and I know libiio is build also with cmake to allow cross compile. 

When I build it using x86_64-w64-mingw32 i get the message from cmake:

[build] CMake Error at extern/libiio/CMakeLists.txt:295 (message):
[build] Libusb >= 1.0.10 is required.
 
Which is understandable. I only have the libusb on my ubuntu, not for windows. But i found no documentation for this on the wiki, so here is the question:
how in my cmakelist.txt do I add the libusb windows dlls so cmake can see it and use it to build libiio?
Also i might just be missing the point and dont need them, if so can someone point me in the right direction?
Parents
  • Hello  , 


    Is there a particular reason for which you chose to cross-compile libiio?

    Instead, you can download the libiio Windows MinGW DLLs from here: github.com/.../libiio-0.25-gb6028fd-windows.zip

    Extract the archive and copy the Windows-MinGW-W64 and include folders to your project's SYSROOT location.

    Then,from your project's CMakeLists.txt , you can link your program to the libiio DLLs, by adding the following lines : 

    find_library(LIBIIO_LIBRARIES iio)
    find_path(LIBIIO_INCLUDE_DIRS iio.h)

    target_include_directories(your_target PUBLIC ${LIBIIO_INCLUDE_DIRS})
    target_link_libraries(your_target PUBLIC ${LIBIIO_LIBRARIES})

    Your add_executable call should be after the calls for find_library and find path and before the calls for target_include_directories and target_link_libraries

    Alternatively, you can leave the downloaded files where they are and tell cmake where to look for them : 

    find_library(LIBIIO_LIBRARIES iio HINTS "/path/to/Windows-MinGW-W64")
    find_path(LIBIIO_INCLUDE_DIRS iio.h HINTS "/path/to/include")

    If you choose this approach, you will also have to edit the ToolChain file used for compiling and set the following : 

    set(CMAKE_FIND_ROOT_PATH_MODE_LIBRARY BOTH)
    set(CMAKE_FIND_ROOT_PATH_MODE_INCLUDE BOTH)

    Let us know if this fixes your issue. 

    -- Cristina

  • Thank you so much for the response, I have a cross platform app that im building to communicate to my radios, your response works great for windows, looks like I'll use the precompiled libraries for each operating system, is there a precompiled library for android? This was the main reasing why I was trying to compile it by myself, but im getting thrown off a bit

  • Currently, Libiio releases do not provide android packages. 

    SInce this question was targeted at windows, you can start another thread with the Android question, and we can discuss more there. This is also to help other users who might have similar questions. 

    Thanks,

    --Cristina

Reply Children