Howdy, Stranger!

It looks like you're new here. If you want to get involved, click one of these buttons!

Categories

how to compile unix based c or c++ code on windows

kariem2kkariem2k Member Posts: 8
hello
i am writing a simple net program code on linux and i want to compile it on windows system but the windows c++ compilers (like gcc,borlandc++,visualc++) don't include some of linux header files like netdb.h and socket.h etc please tell me a solution for this problem.
thanks

Comments

  • stoberstober Member Posts: 9,765 ✭✭✭
    : hello
    : i am writing a simple net program code on linux and i want to compile it on windows system but the windows c++ compilers (like gcc,borlandc++,visualc++) don't include some of linux header files like netdb.h and socket.h etc please tell me a solution for this problem.
    : thanks
    :

    The programs I've seen have conditional compile statements such as

    #if defined(_UNIX)
    #include
    #elif defined(_WINDOWS)
    #include
    #endif


  • DB1DB1 Member Posts: 1,142
    : : hello
    : : i am writing a simple net program code on linux and i want to compile it on windows system but the windows c++ compilers (like gcc,borlandc++,visualc++) don't include some of linux header files like netdb.h and socket.h etc please tell me a solution for this problem.
    : : thanks
    : :
    :
    : The programs I've seen have conditional compile statements such as
    :
    : #if defined(_UNIX)
    : #include
    : #elif defined(_WINDOWS)
    : #include
    : #endif
    :
    :
    :

    [hr]
    I have built many Unix C programs easily on windows with few (if any) changes by using RedHat's Cygwin g++ compiler. It includes all the standard Unix headers and libs (cygwin's versions).

    [hr]
  • kariem2kkariem2k Member Posts: 8
    : : : hello
    : : : i am writing a simple net program code on linux and i want to compile it on windows system but the windows c++ compilers (like gcc,borlandc++,visualc++) don't include some of linux header files like netdb.h and socket.h etc please tell me a solution for this problem.
    : : : thanks
    : : :
    : :
    : : The programs I've seen have conditional compile statements such as
    : :
    : : #if defined(_UNIX)
    : : #include
    : : #elif defined(_WINDOWS)
    : : #include
    : : #endif
    : :
    : :
    : :
    :
    : [hr]
    : I have built many Unix C programs easily on windows with few (if any) changes by using RedHat's Cygwin g++ compiler. It includes all the standard Unix headers and libs (cygwin's versions).
    :
    : [hr]
    :
    Thanks for you help
    but please what packages should i selectcto download from the cygwin setup program
    that match my needs (only programming on it)
    thanks

  • DB1DB1 Member Posts: 1,142
    : : : : hello
    : : : : i am writing a simple net program code on linux and i want to compile it on windows system but the windows c++ compilers (like gcc,borlandc++,visualc++) don't include some of linux header files like netdb.h and socket.h etc please tell me a solution for this problem.
    : : : : thanks
    : : : :
    : : :
    : : : The programs I've seen have conditional compile statements such as
    : : :
    : : : #if defined(_UNIX)
    : : : #include
    : : : #elif defined(_WINDOWS)
    : : : #include
    : : : #endif
    : : :
    : : :
    : : :
    : :
    : : [hr]
    : : I have built many Unix C programs easily on windows with few (if any) changes by using RedHat's Cygwin g++ compiler. It includes all the standard Unix headers and libs (cygwin's versions).
    : :
    : : [hr]
    : :
    : Thanks for you help
    : but please what packages should i selectcto download from the cygwin setup program
    : that match my needs (only programming on it)
    : thanks
    :
    :

    Cygwin is a linux terminal emulator that runs on Windows.
    While there is a long list of available packages you can install, for coding you basically only need to install the dev packages you need. If I remember correctly, all you really need is 'bash' (command prompt), 'gcc' and 'make'. Just choose what you need, and you can always add more at any time. Here is a list of what I have installed, although a little bit more than what is really needed, I can do anything with it that I could do on linux.

    ash ash-20020131-1.tar.bz2 0
    bash bash-2.05a-3.tar.bz2 0
    binutils binutils-20020630-2.tar.bz2 0
    cygwin cygwin-1.3.12-1.tar.bz2 0
    fileutils fileutils-4.1-1.tar.bz2 0
    gcc gcc-2.95.3-5.tar.bz2 0
    gdb gdb-20010428-3.tar.bz2 0
    grep grep-2.5-1.tar.bz2 0
    gzip gzip-1.3.3-1.tar.bz2 0
    libintl1 libintl1-0.10.40-1.tar.bz2 0
    libncurses5 libncurses5-5.2-1.tar.bz2 0
    libncurses6 libncurses6-5.2-8.tar.bz2 0
    libreadline5 libreadline5-4.2a-1.tar.bz2 0
    make make-3.79.1-7.tar.bz2 0
    ncurses ncurses-5.2-8.tar.bz2 0
    sh-utils sh-utils-2.0-2.tar.bz2 0
    tar tar-1.13.19-1.tar.bz2 0
    terminfo terminfo-5.2-3.tar.bz2 0
    texinfo texinfo-4.2-3.tar.bz2 0
    w32api w32api-1.5-1.tar.bz2 0

    I'm sure this will do the trick for you.
  • kariem2kkariem2k Member Posts: 8
    : : : : : hello
    : : : : : i am writing a simple net program code on linux and i want to compile it on windows system but the windows c++ compilers (like gcc,borlandc++,visualc++) don't include some of linux header files like netdb.h and socket.h etc please tell me a solution for this problem.
    : : : : : thanks
    : : : : :
    : : : :
    : : : : The programs I've seen have conditional compile statements such as
    : : : :
    : : : : #if defined(_UNIX)
    : : : : #include
    : : : : #elif defined(_WINDOWS)
    : : : : #include
    : : : : #endif
    : : : :
    : : : :
    : : : :
    : : :
    : : : [hr]
    : : : I have built many Unix C programs easily on windows with few (if any) changes by using RedHat's Cygwin g++ compiler. It includes all the standard Unix headers and libs (cygwin's versions).
    : : :
    : : : [hr]
    : : :
    : : Thanks for you help
    : : but please what packages should i selectcto download from the cygwin setup program
    : : that match my needs (only programming on it)
    : : thanks
    : :
    : :
    :
    : Cygwin is a linux terminal emulator that runs on Windows.
    : While there is a long list of available packages you can install, for coding you basically only need to install the dev packages you need. If I remember correctly, all you really need is 'bash' (command prompt), 'gcc' and 'make'. Just choose what you need, and you can always add more at any time. Here is a list of what I have installed, although a little bit more than what is really needed, I can do anything with it that I could do on linux.
    :
    : ash ash-20020131-1.tar.bz2 0
    : bash bash-2.05a-3.tar.bz2 0
    : binutils binutils-20020630-2.tar.bz2 0
    : cygwin cygwin-1.3.12-1.tar.bz2 0
    : fileutils fileutils-4.1-1.tar.bz2 0
    : gcc gcc-2.95.3-5.tar.bz2 0
    : gdb gdb-20010428-3.tar.bz2 0
    : grep grep-2.5-1.tar.bz2 0
    : gzip gzip-1.3.3-1.tar.bz2 0
    : libintl1 libintl1-0.10.40-1.tar.bz2 0
    : libncurses5 libncurses5-5.2-1.tar.bz2 0
    : libncurses6 libncurses6-5.2-8.tar.bz2 0
    : libreadline5 libreadline5-4.2a-1.tar.bz2 0
    : make make-3.79.1-7.tar.bz2 0
    : ncurses ncurses-5.2-8.tar.bz2 0
    : sh-utils sh-utils-2.0-2.tar.bz2 0
    : tar tar-1.13.19-1.tar.bz2 0
    : terminfo terminfo-5.2-3.tar.bz2 0
    : texinfo texinfo-4.2-3.tar.bz2 0
    : w32api w32api-1.5-1.tar.bz2 0
    :
    : I'm sure this will do the trick for you.
    :
    thanks very very much for that i downloaded cygwin and it was the thing i can't imagine it does what i need thanks again


  • DB1DB1 Member Posts: 1,142
    : : : : : : hello
    : : : : : : i am writing a simple net program code on linux and i want to compile it on windows system but the windows c++ compilers (like gcc,borlandc++,visualc++) don't include some of linux header files like netdb.h and socket.h etc please tell me a solution for this problem.
    : : : : : : thanks
    : : : : : :
    : : : : :
    : : : : : The programs I've seen have conditional compile statements such as
    : : : : :
    : : : : : #if defined(_UNIX)
    : : : : : #include
    : : : : : #elif defined(_WINDOWS)
    : : : : : #include
    : : : : : #endif
    : : : : :
    : : : : :
    : : : : :
    : : : :
    : : : : [hr]
    : : : : I have built many Unix C programs easily on windows with few (if any) changes by using RedHat's Cygwin g++ compiler. It includes all the standard Unix headers and libs (cygwin's versions).
    : : : :
    : : : : [hr]
    : : : :
    : : : Thanks for you help
    : : : but please what packages should i selectcto download from the cygwin setup program
    : : : that match my needs (only programming on it)
    : : : thanks
    : : :
    : : :
    : :
    : : Cygwin is a linux terminal emulator that runs on Windows.
    : : While there is a long list of available packages you can install, for coding you basically only need to install the dev packages you need. If I remember correctly, all you really need is 'bash' (command prompt), 'gcc' and 'make'. Just choose what you need, and you can always add more at any time. Here is a list of what I have installed, although a little bit more than what is really needed, I can do anything with it that I could do on linux.
    : :
    : : ash ash-20020131-1.tar.bz2 0
    : : bash bash-2.05a-3.tar.bz2 0
    : : binutils binutils-20020630-2.tar.bz2 0
    : : cygwin cygwin-1.3.12-1.tar.bz2 0
    : : fileutils fileutils-4.1-1.tar.bz2 0
    : : gcc gcc-2.95.3-5.tar.bz2 0
    : : gdb gdb-20010428-3.tar.bz2 0
    : : grep grep-2.5-1.tar.bz2 0
    : : gzip gzip-1.3.3-1.tar.bz2 0
    : : libintl1 libintl1-0.10.40-1.tar.bz2 0
    : : libncurses5 libncurses5-5.2-1.tar.bz2 0
    : : libncurses6 libncurses6-5.2-8.tar.bz2 0
    : : libreadline5 libreadline5-4.2a-1.tar.bz2 0
    : : make make-3.79.1-7.tar.bz2 0
    : : ncurses ncurses-5.2-8.tar.bz2 0
    : : sh-utils sh-utils-2.0-2.tar.bz2 0
    : : tar tar-1.13.19-1.tar.bz2 0
    : : terminfo terminfo-5.2-3.tar.bz2 0
    : : texinfo texinfo-4.2-3.tar.bz2 0
    : : w32api w32api-1.5-1.tar.bz2 0
    : :
    : : I'm sure this will do the trick for you.
    : :
    : thanks very very much for that i downloaded cygwin and it was the thing i can't imagine it does what i need thanks again
    :
    :
    :

    If you're saying that you can't compile a unix/linux C or C++ program with Cygwin, you have something wrong or you haven't downloaded the right packages. I can almost guarantee that you can build your program with it. In fact, when I want to write a program for linux on windows, I use only Cygwin to compile and test it. If it works there it is guaranteed to work on linux.

    Make sure you have bash, gcc, binutils, and libncurses installed. Look through the installation options in the dev category and make sure to get the libraries you need, and what ever else you might want. I have alot of C experience working with Cygwin and could help you get a win build if you want.
  • Andre YoungAndre Young USAMember Posts: 0

    ________ < http://forcoder.org /> free ebooks and video tutorials about || C Ruby Delphi PL/SQL Objective-C Visual Basic .NET PHP R Assembly Swift C++ Visual Basic Go Python Scratch Perl JavaScript MATLAB Java C# ABAP D Hack Crystal ML LabVIEW Lua F# Alice Erlang SAS Ada Fortran Logo Lisp VBScript Apex Scala Transact-SQL Julia COBOL Scheme Clojure Bash Rust Dart FoxPro Prolog Awk Kotlin || ______

Sign In or Register to comment.