Using eclipse to create an Autotools-based project.
Starting from the "Hello World C++ Autotools Project" in the project creation wizard.
Here are the following steps.
Add a folder to the project called include.
Add a file to the include folder called Application.h.
Add #include <Application.h> entry into the src/proj.cpp file.
Trying to compile gets me a fatal error: Application.h: No such file or directory.
What is the autotools-fu I need to add my include folder to -I search path?
The Autotools plugin sorta follows the design of the GNU autoconf toolset, and so you need to configure the source files that are used by autoconf, automake, etc.
Start with the Autotools hello world project (I named mine AutoHello)
Project->New->Source folder->Folder name: include
Add the header file Application.h to the include folder. I just generated a new simple one, but you can copy an existing one too.
Add include/Makefile to the AC_CONFIG_FILES definition in configure.ac. (Note: *.ac files can be thought of as autoconf source files)
Add include to the SUBDIRS definition in Makefile.am (Note: *.am files can be thought of as automake source files)
Add a new file include/Makefile.am which will handle the automake behavior of the include folder.
Add a definition include_HEADERS to include/Makefile.am which lists all the headers contained in the folder. For this little example we simply list Application.h
In src/Makefile.am, add a definition a_out_CPPFLAGS. Give it a value of -I$(top_srcdir)/include. This tells our make target to add include as an include search path when compiling.
Project->Reconfigure Project
And that should give you a project that will compile a target that uses header files that are located in the include folder.
Related
I have a NetBeans project that uses the GSON library. I've tried including the GSON.jar file without requiring future users to separately download it. However it doesn't seem to work. The project looks for the file from the relative path of my computer so the file isn't found on another user's computer. Is there a way to include GSON.jar and "Export to Zip" and keep the reference in the project itself? I'm lost!
Thank you
Exporting a Project to ZIP zips up the project folder only, and not anything outside of the folder, including dependencies. If you include the GSON.jar file in the project folder, then the JAR file will be included in the .ZIP file. It's a good practice anyway since NetBeans will use a relative classpath and thus if you move the project itself NetBeans won't give you an error message when loading the project.
I am new in the cmake world and I am not even sure if what I try to achieve is possible or not.
Currently, I have an eclipse project file which contains many targets (they have some files in common, some are different (I used the exclusions in Eclipse to do it)).
One of my colleague uses the CLion for that so he created a CmakeLists.txt files for that. Is it possible to use these CmakeLists.txt files to create a project in eclipse? Is it possible to have this way a multiple targets in one project file?
Is it possible to use these CmakeLists.txt files to create a project in eclipse?
Yes, use the following from your source root to generate Eclipse project files which support in-source builds.
$ cmake -G"Eclipse CDT4 - Unix Makefiles" .
If you want to do out-of-source builds, there are a few wrinkles to be aware of. Have a look at this cmake wiki page about the Eclipse CDT generator for more details.
Note that Eclipse also supports importing projects from existing makefiles, which means you can just use the "Unix Makefile" generator to generate makefiles, and import from those.
See this cmake wiki page for details on that
Is it possible to have this way a multiple targets in one project file?
Yes it is. All targets specified in your CMakeLists.txt file(s) will be included in the generated project file.
Thank you for a quick answer. I looked into what you sent me but my indexing still does not work. In my project I have following structure:
Folder main with main.c
Folder platform with three different folders: folder a with a.c file, folder b with b.c file and folder c.c file, and one platform.h file common for all those files with declaration of function "platform()". The main function calls the function "platform()" from platform.h which definition is different for each target (a, b, and c respectively defined in a.c, b.c and c.c file). When I create the eclipse project I do get the folder called "[Targets]" but the indexing does not work which means it does not show me the function from the proper target.
Is it possible to be able to switch from one target to another with the "hammer" sign?
Many thanks.
I have a project that containst source/header files that are from 3rd party. In my project I have the same filename in a different path (e.g. version.h). The scanner is resolving the includes to the wrong file and therefore fails to parse my source files properly.
That's what I have done:
I explicitly configured the project path to not be part of the source path.
Third party libraries are not on include path nor on source path (but a still a subfolder in the project).
The toolchain is "No ToolChain", as it is a NMAKE project created by CMake.
The include directories has been hand selected to exclude not wanted includes and explicitly add wanted includes.
How can I force eclipse to only resolve the files based on the configured include and source pathes?
You can try turning off Allow heuristic resolution of includes. This is a global setting in Preferences -> C/C++ -> Indexer. It can also be overridden per project in the project's settings.
I am unable to generate javadoc for linked .java files using Eclipse Mars.
This shows how my project is set up:
I am able to run the program.
The source file is in a folder named foo, to match the package declaration:
I select Project > Generate Javadoc... and check the package:
I agree to all of the default options.
I get this output in the console:
Loading source files for package foo...
Constructing Javadoc information...
javadoc: warning - No source files for package foo
javadoc: warning - No source files for package foo
javadoc: error - No public or protected classes found to document.
1 error
2 warnings
Adding javadoc comments to the source code makes no difference.
I have no trouble generating javadoc when I do not have linked source files.
How do I set up links to source files so I can generate javadoc?
When you do Project > Generate Javadoc... it launches the external program javadoc part of the JDK typically. The javadoc program does not understand/know about Eclipse linked resources, so it sees the empty folder.
How do I set up links to source files so I can generate javadoc?
Short answer is you cannot with links at the file level.
Use Links to src folder
Rather than doing a link to files within a package, make the link to the containing source folder. In your screenshot you don't have a src folder, but you could create one that is linked.
For example, I have a project called demoforso, in it I create a folder called src that is linked to D:\tmp\src and add src to classpath. When the javadoc is run on this project, it passes D:\tmp\src as the sourcepath.
Use Javadoc views in Eclipse
(i.e. Don't generate Javadoc at all, granted possibly not useful in your case, but included for completeness.)
The hovers and Javadoc view in Eclipse means that you never need to generated Javadoc for your own use.
I am new to CMake and I am trying Integrate CMake with Eclipse.
Below is the example of the file structure that I have.
PROJECT
build/linux
build/linux/Release (Should contain the release libraries and files)
build/linux/Debug (Should contain the debug version of the files)
SRC
subProject_1
.cpp (all source files) and CMakeLists.txt 1 for this folder (creating a static library)
subproject_2
.cpp (all source files) and CMakeLists.txt 2 for this folder (creating a static library)
subproject_3
.cpp (all source files) and CMakeLists.txt 3 for this folder (creating the executable)
Include
subProject_1
.h (all the header files)
subProject_2
.h (all the header files)
subProject_3
.h (all the header files)
Can you please let me know how would I be able to integrate CMake to Eclipse. I would like to do a in Source build so that I can sub version my code.
I have tried different options of placing the main CMakelist in project folder, project/build/linux folder and so on. I can get the project working but I dont get to see the source folder as well as the include folder on eclipse.
I have tried both 1st and 2nd option specified in http://www.vtk.org/Wiki/CMake:Eclipse_UNIX_Tutorial#CMake_with_Eclipse
It's usually very simple: from a clean build directory, you configure cmake using Eclipse as generator (it's easier if you use cmake-gui), and then you import the build directory into Eclipse (File, Import, General, Existing Projects into Workspace).