Important: Please read the Qt Code of Conduct - https://forum.qt.io/topic/113070/qt-code-of-conduct

QtCreator from Linux to Windows 10



  • Hello, I would like to have a QtCreator code go from Linux to Windows 10. However, there are some libraries that are Linux specific that are in the code: <ifaddrs.h>, <netinet/in.h>, and <arpa/inet.h>. Is there a way to resolve this issue?



  • @Kezin99
    So Qt Creator cannot help you much in this case. It's an IDE/editor like everything else. You have to change to make things work under Windows if you have Linux-specific code.

    If you are writing your own Qt code, this does not happen, as the Qt libraries/headers abstract away the difference between platforms. Usually you don't write code which includes the headers you mention, you use Qt equivalents instead. If you cannot/do not wish to rewrite to work that way, you will have to find your own platform-specific equivalents. Or, as @Psnarf said, you could find another abstract layer like Posix and rewrite for that.



  • @Kezin99
    Qt code only uses common headers/libraries. If your own code uses Linux-specific headers, for some reason (do you really need them?), then don't include them (put them inside a suitable #if/#ifdef/#ifndef) if compiling for Windows.



  • When not including these header files, there are several compiler errors indicating that some functions are unavailable. For example, ifaddrs.h has the function getifaddrs(), which is called in the code.



  • @Kezin99
    Called in what code?? Your code? Then don't call it if it's not going to be available! If you mean somehow it's in Qt-supplied code, then that should not be trying to include things which do not exist on specific platforms. You need to explain what your issue is.



  • @JonB Yes, in my code sorry. The code that I have written was originally written in Linux and is using headers that is Linux specific. However, I am trying to port it to Windows 10, and am having difficulty because of the usage of Linux-specific libraries. The code in itself is written in C++



  • @Kezin99
    Why not use Posix functions, which should work in both Linux and Windows? For example, getaddrinfo() instead of getifaddrs(). See what data the Linux function provides and search MSDN documentation for a function that provides that data.



  • @Kezin99
    So Qt Creator cannot help you much in this case. It's an IDE/editor like everything else. You have to change to make things work under Windows if you have Linux-specific code.

    If you are writing your own Qt code, this does not happen, as the Qt libraries/headers abstract away the difference between platforms. Usually you don't write code which includes the headers you mention, you use Qt equivalents instead. If you cannot/do not wish to rewrite to work that way, you will have to find your own platform-specific equivalents. Or, as @Psnarf said, you could find another abstract layer like Posix and rewrite for that.


Log in to reply