Adding icon to gcc executable and opening in terminal - c

I made a program to connect to a device via Bluetooth and send the data to the web using pure C in gcc. I won't be able to implement any GUI portion in the code right now but I need to deploy it to test users for testing. I want to have the executable with an icon so that a user can click on the executable and the program starts in the terminal. How do I add an icon to the executable and start the program in the terminal?
Sorry I failed to mention before that its in Ubuntu Linux

This document explains how to add your program to the programs menu: http://standards.freedesktop.org/menu-spec/latest/.

If this is a Windows executable you're making, what you need to do is to use a resource compiler to make an object file that includes the resources you want (an icon in this case) which you can then link into your program as normal. The resource compiler I've used when building programs on Windows with gcc was called windres.
I found it to be very finicky when dealing with directories with spaces in the name. Beware!

Related

How to turn a Linux application in C/C++ into a Desktop Environment for a Linux distro?

Is it possible to write an program in C/C++ and then turn that into a Linux Desktop Environment?
I want to take an program, and then be able to boot into my Linux distro and just see that.
Say I have a Linux program which is a window containing "Hello World" on a white background.
How can I make that program into a Linux Desktop Environment for a distro, where you boot and just see: Hello World, on a white background.
Any ideas? Let me know if that made no sense.
Edit: I am not talking about cross-compiling.
You don't want to be modifying rc files. Use your distro's existing mechanism for controlling lightdm/gdm/other and starting X. You want to create a new X session type by writing an Xsession file, so that your DE shows up as another DE alongside KDE and GNOME. Put your script in /usr/share/xsessions (and see the existing examples there).
You either want to
create a boot loader, or
you want to replace the 'shell'.
This would be governed by per-user or global xinit and Xsession files.
Your requirement: Run your own GUI application automatically, after system starts up. Am I right?
Here is what I have done with such requirement (I succefully made it working under Slackware):
Allow auto-login after system boot
Make a customizable Window Manager to be default WM lauchedby startx (I use FVWM)
Configure WM to launch your application after it starts up, and disable unneeded shortcut keys
Edit user's startup script (such as .bashrc or .bash_profile) to startx
Now, you can reboot to see whether it works.

GBA programming with Visual HAM in C

I am interested in programming for the Game Boy Advance using the Visual HAM IDE in C. However, every time I build a project I get a message stating:
'make.exe' is not recognized as an internal or external command,
operable program or batch file.
I downloaded GnuWin32 and make. Then, inside the ham visual editor I clicked advanced, options and set the directory of the MAKE_MODE (I guess some kind of environment variable) to the directory where the make program is.
Any suggestions on how to get this to work?
I had the same problem. Reinstall the hole vham package to the desired destination from the get-go. You can find it here: www.jharbour.com/gba/ham-280-full-win32.zip
You can't move the folders around. Even if you change the PATH variables this problem will persist.
Find where on your system the make program is in. Probably in cygwin's /usr/bin. Add that path to your system dos path.
Windows with cygwin is a screwed up hybrid system. You probably have three paths going on at once. You have the cygwin one. If you open a cygwin shell and type make I bet it finds the make program. Then if you open a dos shell ( in accessories/command prompts ) I bet it won't find the make program.
You will need to add it. Every version of windows does this differently but it is generally under right click on my computer/properties/advanced/environment variables. You will need to add it there.
And finnally there is the path known to your ide (probably). I don't know HAM, but it looks like you already did whatever they told you.
When you are done you should be able to invoke "make" from the windows/dos command prompt.

How to detect Console or Windows Application?

I am trying to write a icon changing program like resource hacker. I am able to change icons of windows programs but not console programs and I think thats quite obvious. So I want to write a code in my program that will check if the argument exe file is a console program or windows program before it tries to change the icons.
So how do I check if an exe file is a console program or windows program. I am writing program in C using visual studio.
The Subsystem value inside the Portable Executable header of the file will give you the info:
WINDOWS_CUI 3 Runs in the Windows character subsystem (a console app)

VB.NET Application which can compile and run C programs

These days I'm working on a VB.NET application which can be used to edit, compile and run C programs. Can someone tell me how I can call a cl.exe process from within my VB program and also that how do I run the program in the console widow itself.
Presently I have only the editor ready. With that one can type in a program and save it with a ".c" extension. Now there are 2 buttons on my form - "Compile" and "Run". When the user clicks on the "Compile" button, the program should be passed to the cl.exe process and the errors should be displayed in another textbox or the DOS(black screen itself). And when the user clicks on the "Run" button, the ".exe" file which just got created should get executed.
Is there any way to attach some files along with my program so that the people who do not have "C" installed in their computers can also edit, compile and run C programs using my application?
You can use the System.Diagnostics.Process class to do this.
You can launch any executable using the Start method. You an pass arguments, etc, just like you would from the command line.
Added
You can redirect the output of the program using the Process.StartInfo.RedirectStandardOutput property.
There are similar methods for redirecting errors, input, etc.
To capture the output of the compiler or the compiled and linked program, use the System.Diagnostics.Process.StandardOutput property to retrieve a System.IO.StreamReader instance.

Eclipse cross-compile... how can I do that?

I am developing on a Windows machine using Eclipse in C code.
All the files are physically located on a Linux server.
I am using Eclipse only for editing and code browsing.
When I want to compile, I open a terminal and telnet to the Linux server from which I call a file that sets up few variables and eventually invoke a "make" command.
The server is pretty busy.. I would then like to be able to compile locally [and then just ftp these executable files back to the Linux machine so that I can execute them.. unless Eclipse can do that on its own :) ].... any idea how can that be done? I am not well versed in Eclipse or OS usage.... so if you could answer and explain what I should do.. I would really appreciate...
I changed the Build Command under Project Properties menu by just calling the script file on the server I usually invoke to compile... That looked fairly simple.. well... that was too good to be true... and of course.. it didn't work! I am getting this error if I use the default "make" (Cannot run program "make": Launching failed).... while getting (Cannot run program "T:\compile": Launching failed) if I try to invoke my script file that I use to compile...
thanks,
You should take a look at running a crosstool-ng setup on your windows box inside cygwin. And then have eclipse use that compiler. This will allow you to develop for your target Linux platform easily.
Here's some slides
It sounds like you're developing for a desktop/server platform, so you'll have to make sure you set up your crosstool-ng with the same versions of standard libs as your server has (libc, libstdc++, etc). You also want to make sure your crosstool-ng has the same version of gcc as the target as well.
If you don't want to mess with getting all that setup, you could always install Linux as a virtual machine on your windows box and work inside there.

Resources