Eclipse Refactor Project into executable and library - c

I have an Eclipse project that is currently a monolithic one. That is, it contains all of the C source/includes and build an executable. This project is comprised of a GIT module and several submodules. I would like to refactor this Eclipse PROJECT so that it contains the executable project and projects for the submodules as static libraries.
I'm pretty sure that I can do this if I was creating this from scratch. However, I can't seem to figure out how to do this by modifying the existing project.
Any ideas on how to accomplish this?

Related

Netbeans JSF - Creating executable JAR file

I'm working at the moment on an JSF Project project. Everything is working fine. Creating .war-file, deploying it.
What I actually want is, to create a executable JAR-file for a single Class. In this Class I have a Main-method that sends an email after executing it.
I the past I have worked with Eclipse. And that was very easy.
Now I am working with Netbeans. I have red a lot of posts with the information to clean and build the project. Next to that checking the .dist folder for the JAR-files.
I have either the .dist folder, or any JAR-files in my Project folder for that correlate file.
How can I easily create that JAR-file in Netbeans?
Assuming you are using a native NetBeans project rather than Maven:
The build artefact of a project is defined by it's project type. A JSB/Web project is always build into a WAR file.
If there is one class in your project that you want to put into a JAR file, the clean solution would be to create a new "Java" project with that class (as your class clearly has no dependencies to your Web Application this should work).
For such a project NetBeans will automatically create a runnable JAR file if you configure the main method.
In your JSF project you can simply include that project as a library. If you enable "Build projects on classpath", the jar will automatically be build when you build the web application.
Another approach would be to customize the Ant script NetBeans uses internally and add a target that builds your executable JAR file from that single class.
Details on how to customize the IDE generated Ant script can be found in the manual:
https://docs.oracle.com/netbeans/nb82/netbeans/NBDAG/create_japps.htm#CHDDAHEB

Building a multi module C project (i.e. solution) with Eclipse CDT

I am moving from Netbeans to Eclipse (on Ubuntu 12.0.4). I have a C application that consists of several sub projects which are libraries (shared and static), as well as stand alone executables.
I can't figure out how to create a 'parent' project foo, which contains component projects
foobar
foofoo
barfoo
barbar
Ideally, I want all the 'component projects' to be created under the folder foo, so that I have a directory structure like this:
/path/to/foo/foobar/ (contains foobar project files)
/path/to/foo/foofoo/ (contains foofoo project files)
/path/to/foo/barfoo/ (contains barfoo project files)
/path/to/foo/barbar/ (contains barbar project files)
Does anyone know how I can achieve this structure using Eclipse as IDE (with CDT)?
Last but not the least, I intend to create my C modules using the Autotools option. Will the generated files for Autotools be automatically updated as I add new header/source to a module - or do I need to manually maintain the Autotool files?
Friend,
I think there is no the "parent" C project. You can create a normal C project in IDE and add all dependencies into sub-folders. Then tell compiler your build procedure via Makefile. I think it's easy way as you have had experience on C application.
About autotools, once you update/add/remove your project file, I think you need to modify your Makefile to reflect your change and do clean and rebuild your project.
For other C build tools, you can use buildroot if you'd like.
The best way I can think to do this in eclipse is to create a separate workspace for the project e.g. foo, and then add the sub-projects (foobar, foofoo, etc...) as projects. This is generally a better approach to take with eclipse, instead of a single monolithic workspace. I don't know what the specific dependency structure for the sub-projects looks like, but you should be able to express it simply by using eclipse project properties. This can include a rollup executable sub-project that depends on the libraries.
Unfortunately, I'm not sure if eclipse cdt will maintain autotools files. However if not, it should be relatively easy to integrate and use some of the autotools binaries such as autoscan, and autoheader into the eclipse build commands.
At first you need to a working directory, Then you should new project, Then per file or per class (according to C++ or C ) append your files, it's much safe way. another way is not clean, i have experience. don't use them.

build legacy C code in eclipse

I inherited a project written in C, running on Linux, with Cmake files written by the previous person. The previous person did not use IDE for this project, so I found it a bit hard to maintain this fairly large sized project, and I'm new to Cmake unfortunately :(.
I want to use eclipse (my OS is Linux) for this project to help me understand the project faster, and be able to build and debug it in Eclipse, so I do not have to run the build scripts manually every time. The project was in Mercurial, hence I check it out into my repository using Eclipse, then I have some options:
Open the project, and somehow make it into a C project which I can compile
Convert the code into makefile project, use Cross GCC toolchian, try to add all the pathes to 'include', then try to build (I'm on this path, but it seems Eclipse Juno needs me to find the path to include files myself, which is a lot to add manually T_T)
Create a new makefile project, import the code gradually as I go, I'm not super familiar with the code yet...
Some other ways...
Any suggestions please?
Also, in my case, which of the 3 options mentioned in http://www.vtk.org/Wiki/CMake:Eclipse_UNIX_Tutorial would be a good choice?

cmake vs gmake for qtcreator project

I am attempting to use QtCreator as an IDE for a straight C project. The reason is that I am comfortable with QtCreator and I want a visual IDE for stepping through this new project I am working on. My development box and my deployment box are different, but both of those have gmake on them. QtCreator requires cmake, which I dont mind putting on my development box, but my deployment box is not going to have cmake.
Am I OK to build my software on the Qt box, and be sure it will deploy on the deployment box?
Edit: to be clear, the existing code base already has a makefile structure going, and I'd rather not interrupt that. If I can set my project up to use those existing targets and such it would be great.
If your project is using CMake as build system, then you should have it installed on the machine you are building. You can't pregenerate Makefile's and then just run make on the other box.
Well, you actually can, but then you will probably need same compiler versions, libs/headers located in same paths and etc. So generally it's not good idea.
As for deploying already compiled binaries - it have no relation to CMake. The general rule there is that you should have same shared libraries on both machines. Linking your project statically allows deploying single fat executable/library, without any additional dependencies.

Compiling C code as static library for use in iPhone app?

Pardon me if this is a "noob" question, I'm overextending myself a bit with this.
I'm trying to compile a library written in C for use in an iPhone app I'm developing. I can't seem to figure out how to do this, and I've been searching and trying things for hours.
I've tried using an External Build System project, and selecting the folder where the makefile.in.am.mingw are.
I've tried creating a Static Library project and adding the header\source files to the project. Which looked good until I tried to compile and got 260k+ errors.
When I 'cd' to the directory with the makefiles and type 'make' I get:
No targets specified and no makefile found. Stop.
I have no idea how makefiles work, I just want to use the library!
Is there a simple way to do this? If someone could at least point me in the right direction, I would be quite appreciative.
The makefiles you have are for GNU automake (under MINGW by the look of it). Even if you get them working (automake can be tricky, but it is included in Mac OS X's development thankfully), it probably won't help you much in building an iPhone library.
I did this with an existing C library by creating a new framework target in Xcode with the right include settings, etc gleaned from looking at the makefiles. That created a .framework bundle with headers and an iPhone .a library ready to be used by an iPhone project. You could also just import the C source into the iPhone project, and have it compiled in that way which would probably be quicker.

Resources