Results 1 to 5 of 5
Thread: [C/C++] From CLI to GUI
Enjoy an ad free experience by logging in. Not a member yet? Register.
- Join Date
- May 2011
[C/C++] From CLI to GUI
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.
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.
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.
- Join Date
- May 2011
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.
i'm pretty sure gtk has multiplatform support, pidgin runs on windows and uses a windows GTK runtime
I can't comment on mac