As was foretold, we've added advertisements to the forums! If you have questions, or if you encounter any bugs, please visit this thread: https://forums.penny-arcade.com/discussion/240191/forum-advertisement-faq-and-reports-thread/
Options

Windows, Unix and C++

quovadis13quovadis13 Registered User regular
OK. So I have this very nice C++ code written and it works wonderfully on a Windows based system. However, the thing is I will need this code to ultimately work on a UNIX system. I have zero experience with Unix (since I have only used Windows) so I need to know what to do to get it working off of Windows.


Sorry if that didnt make too much sense. I am computer literate, just not SUPER computer literate.

quovadis13 on

Posts

  • Options
    stigweardstigweard Registered User regular
    edited February 2008
    We need more details about the application. Does it use mfc, or any other windows centric code in it?

    stigweard on
  • Options
    quovadis13quovadis13 Registered User regular
    edited February 2008
    stigweard wrote: »
    We need more details about the application. Does it use mfc, or any other windows centric code in it?



    As far as I can tell it doesnt have any windows centric code. Its a simple program that basically creates a text file that will be read into the unix system. I had to work on the windows system because I would not be guaranteed any extended amount of time on the Unix systems here at work.

    quovadis13 on
  • Options
    JaninJanin Registered User regular
    edited February 2008
    Download Ubuntu, install it in a virtual machine, install build-essential and see what happens when you compile.

    If the code is simple you'll just have to write a makefile, otherwise you might have to set up a build system like Scons. If there's any GUI code, you'll want to port it to GTK+ or Qt. It's hard to give more advice about how to proceed without knowing if there were any problems compiling it.

    Janin on
    [SIGPIC][/SIGPIC]
  • Options
    stigweardstigweard Registered User regular
    edited February 2008
    Janin's way is likely best. It doesn't mess with your regular desktop and you can get a free vmware player and ubuntu image for it from the vmware website.

    stigweard on
  • Options
    quovadis13quovadis13 Registered User regular
    edited February 2008
    Whats the easiest way to write a makefile? Up to this point I have done all my programming using Visual Studio. Could I still use this or am I going to have to seek other utilities?



    As for my code, its a fairly simple code. No fancy UI or anything, just basic array manipulation and some small file I/O. I see no reason why it shouldnt work on any other platform. Right now I have an .exe file that does what I want it to do on windows and I just want to get it to a form that will work on a unix system.

    Thanks for your help so far though.

    quovadis13 on
  • Options
    JaninJanin Registered User regular
    edited February 2008
    quovadis13 wrote: »
    Whats the easiest way to write a makefile? Up to this point I have done all my programming using Visual Studio. Could I still use this or am I going to have to seek other utilities?



    As for my code, its a fairly simple code. No fancy UI or anything, just basic array manipulation and some small file I/O. I see no reason why it shouldnt work on any other platform. Right now I have an .exe file that does what I want it to do on windows and I just want to get it to a form that will work on a unix system.

    Thanks for your help so far though.

    A makefile is a text-based file for compiling projects, and is the most popular compilation system in UNIX. If your project is simple, you can just hand-write it yourself. In fact, if your project is *very* small (say, less than 3 .cpp files) you can just use g++ directly as:
    # For debugging
    g++ -o <myprogram> *.cpp -Wall -Wextra -ansi -pedantic -g3
    
    #For production
    g++ -o <myprogram> *.cpp -Wall -Wextra -ansi -pedantic -O2
    

    Here's a nice tutorial on how to make a small Makefile. I prefer to name mine "Makefile" (capital M), so I can just type "make" instead of "make -f <makefile here>".

    Once you have a virtual machine configured, try building a few hello-world apps that just print to the terminal or something to get the hang of G++.

    Janin on
    [SIGPIC][/SIGPIC]
  • Options
    El GuacoEl Guaco Registered User regular
    edited February 2008
    Janin's advice is sound. When I was working on my CS degree, the University required all my work to compile in UNIX. This means you actually have to compile your code on a UNIX/LINUX box, and it doesn't take anything more fancy than using make and the GNU c/c++ compiler. Make is easy to learn, so that shouldn't be a problem.

    If you're using VS to manage your code, make sure you aren't setting up your projects to be run under Windows, or VS will add a bunch of extensions and extra files that will bork the UNIX version. Just make it a vanilla project.

    El Guaco on
Sign In or Register to comment.