how to design an IDE for GCC using Java? - gcc

I have already created a text editor using Netbeans in Java and I want to know to link the text editor with the GCC compiler in Linux Platform.

Try the Runtime 'exec' method to execute the program you want (gcc) with the parameters you want (the file names to compile). From there you get a process object that you can use to read the output streams from the executed program.

Related

Run cpp file without compiling

How to directly run a c++ file present in read-only storage like CD-drive without making executable files using g++? There must be some arguments for that to work.
The process of a C/C++ program when you make one till you run it:
You write the program's source code.
The compiler comes in here and compiles the source code to object files.
Note: Remember that the program cannot be executed at this stage. It's only an object file. You'd know this if you have worked on bigger size programs, but if you haven't here is how it works. Remember using those header files in your programs? These header files just tell the compiler that there are some things that are not defined in your program. They are somewhere else. So your compile compiles the program to the object file leaving out things that have a prototype (which is in the header files).
This is a very important point. Here a program called 'linker' comes into play. What linker does is to take all the object files created by compiler and combines them into one. Say for example your compiler created a single object file. Now, you're using math library or anything from standard library. The compiler-linker package (often called only compiler) comes with object files for these standard library definitions. So, linker takes your object file and combines it with other object files from the package and then converts it to an executable file. This is the file that you can run. Nothing else is runnable directly.
To run source code the process is explained already, we have to use the g++. Now
What I understand from your question is that you want to know if a program can be run once it's compiled and linked properly (hence an executable has been generated). Answer to that would be yes.
Alternatively, may sound strange, there is an interpreter I know called Cling that can be of use to bypass the compilation of C++ program.
After all C++ is generally seen as a compiled language. However, any programming language can be implemented as a compiler or as an interpreter and Cling happens to be an interactive C++ interpreter based on LLVM and Clang.
Take a thorough look at this

AOSP lldbclient.py missing?

I'm building AOSP from source and have created a small C++ program that prints some messages to logcat when started. Now I wanted to debug the program according to https://source.android.com/devices/tech/debug/gdb
In the reference you're encouraged to use lldb in favor of gdb and there is also a short section on using vs code as debugger.
However, I cannot find the mentioned script lldbclient anywhere in my source nor in Android Code Search, only gdbclient.py seems to be present.
Q1: Where can I find lldbclient script?
When running the gdbclient.py script the option --setup-forwarding vscode seems to be ignored and gdb is always started.
Q2: If there isn't a lldbclient script, what options do I have to pass to gdbclient.py to enable debugging with lldb and vs code?
What did I do so far?
gdbclient.py -r /data/mysample_bin --setup-forwarding vscode
Starts my native program with attached gdb and allows me to step through my program.
Though I do not know how to code python, I was able to track down a call sequence in the script to method generate_setup_script, which is called with parameter debugger=gdb. Therefore no lldb configuration for vs code is created. Passing --no-gdb or --lldb to the script doesn't change this behavior.
Q1: You can find lldbclient.py script in the repository https://android.googlesource.com/platform/development, branch android-s-beta-2 (or another android-s branch).
Q2: Android also provides some tutorial debugging with Vscode: https://source.android.com/devices/tech/debug/gdb#vscode.

Ada static compilation

I have compiled a simple Ada application which uses the Win32Ada library.
I'm compiling the application on Windows using:
gnatmake C:\GNAT\2020\bin\src\main.adb -I"C:\GNAT\2020\lib\win32ada" -largs -lwin32ada.
The application works as expected on the compilation machine and when executing main.exe a MessageBox is executed.
However, when attempting to execute the application on another Windows system which doesn't have the Ada libraries installed, I received an error:
Does Ada support static compilation?
Can I compile the application so main.exe can execute on any Windows host without needing to bundle DLL's?
I couldn't find an answer in the gnatmake --help (but I'm also new to Ada).
The default linking mode is static on Windows. So, normally, you don't need to add any option. If you need to force it, use the -bargs -static gnatmake binder option or add
package Binder is
for Default_Switches ("ada") use ("-static");
end Binder;
to your .gpr project file.
Does Ada support static compilation?
Yes, it's the default mode.
Can I compile the application so main.exe can execute on any Windows host without needing to bundle DLL's?
You should be able to, but I haven't used the win32ada library much; I would be surprised if you couldn't do something like Deplhi where the executable interfaces with the Win32 API "directly", albeit with the abstraction of the VCL.
I think the item you want to flag is in the Linker, not Binder. (Though you might need both.) The best place to check for the nitty-gritty of arguments for GNAT is the documentation, simply because there's a huge number of arguments which are essentially non-intuitive in their naming or usage.
--unchecked-shared-lib-imports might be of interest; checking out the win32ada project file (especially any scenario variables) might give you the ability to switch it to a static library. In the worst case, if you add For library_kind use "static"; to the Win32Ada library, you should be able to build it statically yourself.

How to run GhostScript on AS400 server

We have PDF files on the AS/400 and we need to convert them to PCL for printing . So for this we found Ghostscript for converting PDF file to PCL format , so we're looking for a way to run Ghostscript commands on the AS/400.
Have you please any idea how to do it , if no I am looking for another "free" method to do what we need.
Any help will be appreciated
Ghostscript doesn't accept PCL as input, you need Ghostpdl for that, and more specifically the pcl6 executable.
You can't 'run Ghostscript commands' you can run the executable with the PCL file as an input and suitable command line switches.
In order to do this you will need to compile Ghostscript for your target environment (AS/400 apparently). Ghostscript is written in standard C so you will need a C compiler, the build process is convoluted and requires running a number of executables in order to generate some platform specific files.
Your first task is going to be porting Ghostscript and its build process onto your target platform. I'm not aware of anyone having done this for AS/400 but we'd be interested to hear how you get on.

Need to port Fortran code using the DFWIN module to gcc/gfortran, where do I start?

UPDATE After some digging I found this to be a part of some workaround that passed a file handle from C++ to Fortran using a stub for OPENPIPE. OPENPIPE simply returns an externally declared file handle, doing absolutely nothing with a pipe. OPENHOLDFILENAME actually creates a file, but I'm still confused about what DFWIN has to do with this. Was it required to provide a function declaration for OPENPIPE? If so, they why was it also declared as EXTERNAL in the Fortran code?
I was given the task of compiling legacy Fortran on the GCC toolchain. I've already successfully compiled a few of the source files, but have hit a snag regarding the DFWIN module which links up to some Win32 API functions. It apparently uses some Win32 pipe functions, and I need to replace this with a modern equivalent that works with gfortran (the old compiler was Compaq Visual Fortran).
First, I see the DFWIN module included, as well as some external functions:
USE DFWIN
EXTERNAL OPENPIPE
EXTERNAL OPENHOLDFILENAME
Here is an example of how OPENPIPE is used:
OPEN(UNIT=INN,FILE=
1 '\\.\pipe\input.txt',
1 FORM='FORMATTED',STATUS='old',readonly,
1 USEROPEN=OPENPIPE)
What module can I use to replace these calls on modern Windows/Linux systems using gcc/gfortran?
EDIT: Our priority is to get this running on Windows, but in the future we want to deploy on Linux as well.

Resources