Find the answer to your Linux question:
Results 1 to 5 of 5
Hi, My short journey in programming in a linux environment so far has all been about writing simple command line based programs; stuff that mimics linux commands for eg. Now ...
Enjoy an ad free experience by logging in. Not a member yet? Register.
  1. #1
    Just Joined!
    Join Date
    May 2011
    Posts
    2

    Smile [C/C++] From CLI to GUI


    Hi,

    My short journey in programming in a linux environment so far has all been about writing simple command line based programs; stuff that mimics linux commands for eg.

    Now i am a little curious as to how GUI work on top of CLI. This may sound illogical or confusing but bear with me. I do not understand the relationship between CLI and GUI.

    Say if i have a program that allows the user to change his/her MAC address to a randomly generated MAC. This program is coded in c and rely on command input. How do i turn this same program into GUI.

    Do I have to rewrite this program using a GUI framework? or is it as simple as linking a GUI program to the functions in my current code.

    Thanks

  2. #2
    Linux Guru Cabhan's Avatar
    Join Date
    Jan 2005
    Location
    Seattle, WA, USA
    Posts
    3,252
    You will need to rewrite your program using a GUI framework. For C, Gtk is generally the best option. For C++, you can use either Gtk or Qt.

    Now then, you can still use the same logic code to accomplish everything. You could make a shared library from your current codebase and simply use it in both the CLI and GUI versions. But yes, these will need to be separate programs.

  3. #3
    Linux Guru Lakshmipathi's Avatar
    Join Date
    Sep 2006
    Location
    3rd rock from sun - Often seen near moon
    Posts
    1,758
    I encountered similar situation when I tried to write GUI for my program. Began with GTK but later I used zenity Make Your Scripts User Friendly with Zenity | Linux Journal but i thought zenity was better suited for shell scripts kind of programs. Again shifted back to GTK, I learned GTK with a program named "isprime" from sourceforge.net and finally modified my program so that scanf/printf statements are commented out and inputs are received/send from/to GTK GUI.
    First they ignore you,Then they laugh at you,Then they fight with you,Then you win. - M.K.Gandhi
    -----
    FOSS India Award winning ext3fs Undelete tool www.giis.co.in. Online Linux Terminal http://www.webminal.org

  4. #4
    Just Joined!
    Join Date
    May 2011
    Posts
    2
    Thanks for the replies. Since I want my program to have cross platform compatibility, I think I'll have a look into the Qt framework.

    Also, is there any good articles about linking lib using the compiler. Not sure if the term sounded right. I should be using some C libraries like crypto.h for encryption, not sure how it will turn out if I throw Qt framework into the mix.

  5. #5
    Linux Guru coopstah13's Avatar
    Join Date
    Nov 2007
    Location
    NH, USA
    Posts
    3,149
    i'm pretty sure gtk has multiplatform support, pidgin runs on windows and uses a windows GTK runtime

    I can't comment on mac

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •