I just started using Geany for a week. And always having to hit F9 to build and then hit F5 to run, it just sucks.
So is there any way to config Geany so that it'll build and then execute immediately (like F9 in CodeBlocks) ?
You can add your own custom commands or even adjust existing ones. Go to Build->Set Build Commands and change the compile command to something like command1 && command 2. The && should cause your POSIX shell to execute command 2 if command 1 was successful. Inside wiki there is a more verbose version of documentation what can be done on "Set Build Commands"
I know this is old but I just figured out how to do this on Ubuntu Linux.
-Click "Build" in the menu at the top
-At the bottom go to "Set Build Commands"
-Prepend the command in the "Build" section before the command in the "Execute" section.
Execute should look like g++ -Wall -o "%e" "%f" && "./%e".
Here are before and after images.
Default Build Commands
Build and Execute Combined
You should now be able to build and run your program by pressing F5 (default) once or running execute from the build dropdown menu.
i did this for windows.
donwload git bash for windows
(https://git-scm.com/download/win)
download mingw c compiler for windows
(https://sourceforge.net/projects/tdm-gcc/)
simpler way of this,is to simply use mingw bin folder of codeblocks which has the gcc for winodws binaries, to search , go to your codeblocks installed folder and search "gcc.exe" in search bar. set this bin folder as path through in enevirment variables(https://www.java.com/en/download/help/path.html)
in geany go to build->set build commands
in execute box write
\bin\bash -c "gcc %f && time ./a.exe"
Example : D:\Downloads\GitBash\bin\bash -c "gcc %f && time ./a.exe"
after this , write a source file and hit F5. Your code will compile and on successfull compile it will run
Related
I edit and test a lot of scripts using Geany.
Is there a way to make an open script executable using Geany instead of having to do it using my file manager?
I defined a build command.
Under Build
Set Build Commands
No filetype commands
Set Exe Bit chmod +x %f
I have a script written (which are basically the commands for the terminal for Ubuntu) on a file. Yes, the code starts with
#!/bin/bash
How do I run this script just by double clicking it? It can be run using the terminal but I want to make it more accessible through my desktop.
I was just trying to mimic a *.bat file on windows. A *.bat file on windows contains series of scripts operable on command prompt and executable just by double clicking on it.
Follow these steps:
Hit Alt+F2, type dconf-editor and hit ``Enter.
In dconfg-editor goto: org ➤ gnome ➤ nautilus ➤ preferences
Click on executable-text-activation and from drop down menu select:
launch: to launch scripts as programs.
OR
ask: to ask what to do via a dialog.
Close dconf-editor Thats it!
Source https://askubuntu.com/a/286651/113065
Edit -> preferences -> Behavior -> Executable Text Files = Run ...
It should run, but you can't see output.
An alternative way, mostly for developers, is to create self-contained desktop launchers. The idea is to use a launcher that includes a tag under which there is the script; the launcher executes a command that:
put the script into a temporary file
run the script which deletes itself
Of course, the script should delete itself, for this reason, it's a good practice to start the script with rm $0. Note that if the script needs to read the script itself, you will need to use rm $0 somewhere else...
You can use the following example stolen from my project:
#!/usr/bin/env xdg-open
[Desktop Entry]
Name=Launch Assistance
Comment=A simple app to setup remote assistance
Exec=ttt=/tmp/$(date +"%s%N").sh; tail -n+$(awk '/^#__SCRIPT__#/ {print NR + 1; exit 0; }' %k) %k > $ttt ; sh $ttt;
Icon=computer
Terminal=true
Type=Application
Categories=Network;Internet;Utilities;Administration;Settings;
#__SCRIPT__#
rm "$0"
# Put here the script
# note that if the script needs to read $0, you will have to edit it
You need to make it an executable file, either use chmod +x <filename> or go into the file properties and set it there.
Open nautilus
Behavior tab
Executable Text files -> Ask each time
Profit
Source. Tested on Ubuntu 20.04.
What is the windows equivalent to "./filename"
So for example I would usually compile by doing something like:
gcc -c homework1.c
gcc -o homework1 homework1.o
This would give me the executable names homework1
And for me to run the program, I would type: ( ./homework1 ) <-- ignore the parenthesis.
Usually I was write all my code in my schools Unix Shell thingy and I also compile it and run it there, but recently I think I took up all the disc space (because it says "disc quota exceeded").
Run cmd.exe
Go to where the program is example : cd C:\foder1\
Then type the program name with extension, for example : test1.exe or "test1.exe"
In windows (as in Linux) you can either run a program though a GUI interface or from a shell environment.
The GUI option is a program called Explorer, you navigate through the file system and double click executable files to run then. Executable typically have the extension '.exe' or '.bat', but there are others.
The shell environment in windows is called the 'command prompt', you can run it by going to the start menu and selecting 'run' or simply press the windows key and 'r' simultaneously. A box will popup, type 'cmd' (without the quotes) and hit enter - the command prompt should open. From there you can navigate the file system using commands like 'cd'. To run your executable type the name of the file (it should work with or without the '.exe').
A nice shortcut to open the command prompt already at a particular path, is to browse to the folder in Explorer, hold shift and then right-click the folder - the resulting context menu that pops up should have an option like 'open in command prompt'.
I am trying to compile a C file in Windows console with 'cl'.
When I first tried this, It send a message like this :
fatal error C1083 : ... 'stdio.h' : No such file or Directory.
So I searched web and found some article execute vcvars64.bat and try again.
I followed that advise and it works nice.
But whenever I reopen terminal it prints same error message what I had in very first time.
Should I execute vcvars64.bat every time, whenever I try to compile in Windows console?
PS.
My command was
cl Helloworld.c -Fehello.dll -MD -LD
You can configure a shortcut to invoke cmd.exe with a list of startup commands. Create a shortcut to cmd.exe, then edit its "Shortcut->Target" in "Command Prompt Properties" to be cmd.exe /K C:\path\to\file.cmd. Within C:\path\to\file.cmd you can put the call to invoke vcvars and any other setup you want to do every time.
Then you can invoke the shortcut instead of cmd.exe whenever you need to do command-line VS stuff.
I open a cmd console, go to where the Makefile is and run "make help", for instance. Instead of listing the available targets, make seems to just run cmd inside cmd again and again for each target. I can go back by typing "exit", "exit", "exit", etc. until I'm back to my original cmd prompt. All other targets are rendered the same way.
I configured (using Cmake GUI) CMake to use MinGW tools, indicated the correct source and build dirs. Everything regarding environment seems ok per the tests performed by CMake.
Please, help, I have no clue of what is going on. That's very odd.
Here is the "help" target from the Makefile generated by Cmake (I edited out some #echoes during investigation). In this case, make opens three cmd prompts in tandem instead of printing the information in the #echo commands.
# Help Target
help:
#echo The following are some of the valid targets for this Makefile:
#echo ... all (the default if no target is provided)
#echo ... clean
.PHONY : help
Please ask any information you want. I didn't paste the entire Makefile or CMakeCache.txt because they are quite large. If you need them, please ask.
This is my CMakeLists.txt, it is quite simple:
#
cmake_minimum_required (VERSION 2.6)
project (HELLO)
add_library (mylib MainLibClass.cpp)
add_executable(myprogram main.cpp)
target_link_libraries(myprogram mylib)