Menu

Win32 / Linux

2003-02-04
2012-09-26
  • Nobody/Anonymous

    I wrote a Win32 programe in Dev-C++, which uses sockets and some file i/o functions (fprintf, fopen, ...). Is it possible to compile it for Linux ?
    I didn' t use windows specific functions like CreateThread or something like that... All functions I've used are existing in Linux (fprintf, socket, ...).
    Does Dev-C++ for Linux compile it, or what do I have to do to get it working ?

     
    • upcase

      upcase - 2003-02-04

      If it really is a plain standard C sourceI guess it would be best to modify the makefile and compile it using this makefile. Only tried Dev-cpp for linux once and... well... it's buggy like hell, crashes all the time and should not be used. Try anjuta or KDevelop for some nice IDE's in Linux.

       
    • upcase

      upcase - 2003-02-04

      DON'T hit refresh!!!!! Leads to double-posts!

       
    • Anonymous

      Anonymous - 2003-02-04

      The Winsock API is based on BSD sockets but there are some important differences.

      I have posted an article on cross platform socket programming here:
      http://maxdownloads.com/forum/showthreaded.php?Cat=&Board=cpp_art&Number=10002500&page=0&view=collapsed&sb=5&o=31&fpart=1

       
    • Nobody/Anonymous

      Will a simple hello world app that is made for windows work on linux, with a straight compile (new makefile, everything)

       
      • Nobody/Anonymous

        Yes, if you compile the source on a Linux machine (using GCC for example) and so generate a Linux binary executable.

        But sure you can have the same source code for both.

        Thats it, lets the flames start now.

         
      • Anonymous

        Anonymous - 2003-02-05

        C and C++ are inherently portable languages, and using GCC compilers is a good way of ensuring portability since any implementation dependent features are mostly the same accross platforms. Differences may occur accross different processors, (endian-ness, integer sizes etc.) but x86 Linux and Win32 GCC compilers are virtually identical.

        An important aspect to writing portable code is using standard libraries (ANSI/ISO). Make sure you know which libraries/headers/functions are standard. ANSI/ISO does not specify library names, but in GCC the C runtime library is in libstdc.a, and the C++ library is in libstdc++.a. ANSI C and C++ do however specify standard header files containg declarations for the standard library. These standard headers are listed here: http://www.cplusplus.com/doc/ansi/hfiles.html. Note all of you conio.h is not among them!!!

        If you need to use a function not contained in one of these libraries you will need to ensure that there exists an equivalent or identical function on any platforms you may port your code to. Conditional compilation is a good way of ensuring cross platform code compatibility without maintaining two separate sources. In this case the useful macros are __LINUX__ and __WIN32__. There are other macros that define compiler version, processor etc. To see all predefined macros in an implementation, in the bin directory, create an empty file called foo.h and run;

        cpp -dM foo.h

        The dummy file is needed because cpp (the preprocessor) expects one. On Windows you can omit it and just type ctrl-Z after invoking cpp -dM, but I am not sure if this works on all platforms.

         

Log in to post a comment.

Want the latest updates on software, tech news, and AI?
Get latest updates about software, tech news, and AI from SourceForge directly in your inbox once a month.