Oovaide Analysis and Build Help

Oovaide can analyze projects, and can also build projects. The setup for analysis is simpler than the setup for building projects since only compile type parsing is performed, and the building of library and run-time components does not need to be specified.

  1. Oovaide Analysis and Build Help
    1. Oovaide Analysis
    2. C++ Analysis
      1. Choosing External C++ Packages
      2. Oovaide C++ Settings
      3. Solving C++ Analysis / Compile Problems
        1. LibCLang missing
        2. Analyzing projects (such as OovAide) that use CLang libraries
        3. Missing Standard Library Includes
        4. Builtin identifiers
        5. CLang headers
    3. Java Analysis
      1. Android Analysis
      2. Solving Java Analysis Problems
    4. OovAide Build
      1. OovAide Build C++
      2. OovAide Build Java
    5. Advanced Build Variables
    6. Inkscape Example on Windows


Oovaide Analysis

One goal of Oovaide is to be able to analyze a project by only providing a simple setup for analysis. This allows analyzing projects where nothing is known about the source code.

When a new project is created the following can be defined.

After a project is created, these directories can be viewed using the Analysis/Project Settings menu item. The source root directory can be changed if the directory does not exist.

Oovaide scans the directories of the project under the source root directory (excluding exluded directories) to find source files that need to be analyzed. The extensions of the files in the directories are used to determine which source file parser to use. Oovaide can analyze and build a single directory tree that contains both C++ and Java files. In fact, Oovaide itself can be built this way.

C++ Analysis

There are typically three types of files used to analyze or build a project.

Oovaide scans all non-excluded directories in the project, and adds include directory paths to the compiler command line for any directories in the project that contain header files. If there are files with duplicate names, it is possible to add a -I switch to include the needed directory first and it will be used before the project include paths. It is possible to do this component or directory specific by using the build settings dialog, or editing the oovaide.txt file itself.

OovAide uses the CLang parser for analysis. This means that problems with include paths can be solved by searching the web for typical CLang installation problems

Oovaide by default uses one set of compiler settings for all directories. This means that a superset of all packages should normally be specified in the common build arguments. For example, if gtk is not needed for some directories, adding it for all directories should not cause a problem for directories that do not require gtk. It may make analysis slower, but should not fail. This can be changed for complex projects.

Each header and source file is analyzed independently. This means that each file should be able to include all definitions needed. Search the web for "self-sufficient headers", or "self-contained headers", for more information. On many projects, a fairly small include change can be made to the source to be able to analyze much of the source.

Not all compiler errors need to be fixed to generate useful diagrams. Oovaide will still generate references to undefined objects as long as the compiler has parsed beyond the initial errors. If the files do not include all needed definitions (they expect the source that includes them to include other files first), then the error limit may need to be increased so that more of the file can be parsed. The other alternative is to fix the header files so that they include the needed definitions.

In Linux, the CLang compiler is not shipped with Oovaide, but must be present on the system.

Choosing External C++ Packages

Packages are collections of include and library files that are distributed for use by many programs. Some examples are GTK, Qt, etc. Oovaide provides an "External Project Packages" button on the C++ Settings screen that allows selecting packages.

Packages are different on Windows and Linux. On Linux, the pkg-config tool is used by the Oovaide package dialogs so that packages can be selected and used in each project.

On Windows, there is a file called bin/oovaide-allpkgs-win.txt, that defines a few common packages. This file can be easily read to see how packages are defined, and it is possible to modify and add more packages. You can always file a bug to get another package added.

On Windows, Oovaide attempts to find directories using wildcards in the package directory definitions. If there are multiple versions, then the directory can be specified manually.

If the "Include Directory" setting is a wildcard, then the directories are scanned for include files, and paths are saved. To prevent this scan, directories can be specified (separated with semicolons) or a single period can be used to specify that only the current directory relative to the root should be used as the path.

Oovaide C++ Settings

The CLang compiler arguments for Analysis are set up in the Analysis/Settings dialog in the C++ Settings tab. Many arguments are passed directly to the compiler, so for example, "-I/dir" will use "/dir" as an include path to search. There are a few special arguments that Oovaide uses as described below.

The argument order is important if there are files with the same names in different directories.

Flag Name Description
-EP External Packages This flag should be added using the "External Project Packages" button. This specifies the name of the package to use for the OovBuilder.
-ER External Recursive Directories This flag allows specifying a root directory to search for includes and libraries. It also allows specifying exclude directories. An example is "/rootdir/!/test/!/examples/", so that any filepath that matches test or examples will be excluded.
-lnk Link Flag The value following this flag is sent to the linker. Some examples are "-lnk-L/libdir", or "-lnk../dir/objfile.o".

Solving C++ Analysis / Compile Problems

One of the most difficult problems can be solving include path problems. The include directories for files in the project do not have to be set since OovAide sets these automatically. OovAide generally requires that the include file names are unique, or the wrong one could be used. Include paths can be set per component to resolve these issues. The simplest way is to use the Build Settings dialog. Another way is to edit the oovaide.txt project file.

See the Inkscape Example below for more problem solving information.

LibCLang missing

OovAide requires the C interface to the CLang library. On Windows, the CLang library is supplied with OovAide.

On Linux, the library is not supplied. If the library does not exist, an error like the following will occur. "error while loading shared libraries: libclang-3.6.so.1: cannot open shared object file". A package manager will allow adding the CLang package that is required. In Debian systems such as Ubuntu, the Synaptic Package Manager can be used to find the package by searching for "clang interface", and it may be named something like libclang1-3.6.

Analyzing projects (such as OovAide) that use CLang libraries

If an error displays "fatal error: clang-c/Index.h: No such file or directory", then something like libclang-3.6-dev is needed. OovAide should work with many versions of the libclang library.

Missing Standard Library Includes

On Linux, OovAide attempts to define some standard include paths for analysis using -isystem when a project is created. If these are not correct, it may be required to set them manually after the project as been created.

If an error appears such as "error: 'stdio.h' file not found" or for 'limits.h' or 'stddef.h', this means that CLang is not finding the include files in some standard locations. It is possible to find the locations that CLang is looking by using the -v switch in the Analysis/Settings menu on the C++ Settings tab in the Common Build Arguments edit box. On Debian, the package that includes the files is libclang-common-x.x-dev, which is included by using libclang-x.x-dev. Sometimes using the build-essentials may help.

It is possible to find the intersection of files that packages supply, and where clang is searching using the following. Using "echo '#include ' | clang -xc -v -", showed that clang was searching for /usr/lib/llvm-3.6/bin/../lib/clang/3.6.2/include. Remember that the paths during analysis and build are different since the path to oovCppParser is different than the path to clang. Using "dpkg --search stddef.h", showed that libclang-common-3.6-dev supplied the file /usr/lib/llvm-3.6/lib/clang/3.6.2/include/stddef.h. The "-xc -v -" switches can also be used in the OovAide analysis settings.

Builtin identifiers

If an error "undeclared identifier __builtin__ia32_bsri" displays, this means that the clang headers are not found or the libclang.dll version is does not match and is not searching the paths the same. For example, CLang versions 3.6 and 3.7 are in different locations at least on Windows. In Windows, depends.exe will show the locations. On Linux, the ldd program can be used to show dependencies for oovCppParser.

CLang headers

The CLang headers should not be analyzed or else the "Never use <adxintrin.h> directly" error will display.

Java Analysis

The oovJavaParser.jar tool that is distributed with OovAide is used to parse and analyze the java source files. A single java file is analyzed at a time.

The Analysis/Settings menu selection will display a tab named "Java Settings". This tab allows setting the class path and JDK path.

The class path is initialized from the CLASSPATH environment variable, but altering it in the settings will not change the CLASSPATH environment variable. The class path must contain all jars that are needed for your project. The CLASSPATH environment variable does not need to include tools.jar since it is added from the JDK path as described below.

The JDK path is initialized from the JAVA_HOME environment variable, but altering it in the settings will not change the JAVA_HOME environment variable. In Linux, if JAVA_HOME is missing, then "/usr/lib/jvm/default-java" is used as default. The JDK path must be set to the JAVA SDK. An example is: "C:\Program Files\Java\jdk1.8.0_51". This path is used to find the tools.jar file in the lib directory.

The Extra Analyze Arguments can be used to set switches, or to add java files that will be added to the analysis.

Android Analysis

In Android with Windows, the class paths may contain something similar to the following: The Extra Analyze Arguments may contain something similar to the following:

Solving Java Analysis Problems

If an error displays "java.lang.NoClassDefFoundError: com/sun/source/tree/Tree", this means that the JDK tools path must be set. The package that is required in Ubuntu is something like openjdk-7-jdk and can be found in the Synaptic Package Manager. Once the package is installed, the Properties/Install Files tab shows the installation location of tools.jar at something like /usr/lib/jvm/openjdk-i386/lib/tools.jar, so the JDK path must be set to /usr/lib/jvm/openjdk-i386 in the Analysis/Settings menu on the Java Settings tab.

OovAide Build

If analysis has completed successfully, then building applications with multiple libraries and executables is fairly easy.

The Build Settings dialog under the Build menu allows selecting a directory and specifying what type of component to build from the directory. For example, if a single executable will be built from the whole directory tree, then select the component/directory, and define it as a Program/Executable (for C++) or as a Java Executable Jar (for Java).

The following directory structure shows how components can be created. See the user guide for more information.

Some of the rules are:

OovAide Build C++

Use the Build/Build Settings menu to specify component types. The Extra Build Arguments on this screen are specific to each component.

OovAide Build Java

Any component specified as a Java Executable Jar must have a Manifest.txt file in the component's source directory.

The classpath must include all jars that are required for the build. The Java Library Jar can be used to build a jar that is not a stand-alone executable. At the moment, Oovaide does not determine jar dependency build order, so if this is a problem, multiple projects may have to be created to work around this for now.

The package names must match the directory structure. For each jar that is created, the package names in the java files must match the directories under the specified component's directory.

The Extra Build Arguments can be used to specify switches or to add jar, java or class files.

Advanced Build Variables

On the Analysis Settings dialog, there is an Advanced button that allows setting build variables. All of the settings used for the build are defined using build variables, so the  Advanced button allows changing the build variables with much more flexibility than the other screens.

Build Variables are used to define compiler and linker flags, tool paths, and other environment variables. Each variable can have some settings, and in some circumstances will be modified to append more settings. For example, the base setting of the project for C++ arguments may include some directory using a "-I/path" flag. Then for a particular component/directory, an additional "-I/otherPath" may be appended to the base settings of the project. Another example is that an external package may be different on Linux or Windows.

The build settings that are used are only the settings where the filter matches the current build being performed. For example, a C++ build variable with no filter will match all C++ files. A variable with a filter where the configuration is Debug, will only be used when the compile being performed is for debug mode.

The build settings are run in a particular order. In many cases the order may not matter, but an example of where they may matter is when there are duplicate header files, and one must be searched first. The shortest rules are run before longer rules.

Inkscape Example on Windows

This example shows how to analyze a project where little is known about the project. This example was run on Windows, but some items will be similar on Linux.

For this example, we will attempt to analyze the Inkscape program. The Inkscape program requires gtkmm and boost, so they need to be added as external packages. Since gtkmm includes mingw, there is no reason to additionally add a separate mingw package.

I don't know which version of gtkmm is needed, so I just downloaded the Tarnyko gtkmm-3.4.0_mingw-4.6.2 version. Use Oovaide to add gtkmm as an external package.

At first, there was a compile error about a missing config.h. I never ran the configure command, so I cheated and copied config.h.in to config.h in the Inkscape source code.

The following problem is displayed during analysis, and resolved by adding an include of "gtkmm-3.0/gtkmm.h" to the Inkscape source in src/extension/param/parameter.h. The real problem is that Inkscape does not define all classes before they are referenced in header files.

	C:/Dave/Mine/software/external-projects/inkscape-0.91/inkscape-0.91/src/
	  extension/param/parameter.h:42:8: error: use of undeclared identifier 'Glib'
	
Similar to the first problem, more includes need to be added, so add the following includes to the parameter.h file before the gtkmm include. #include "xml/node.h", #include "extension/extension.h".
	C:/Dave/Mine/software/external-projects/inkscape-0.91/inkscape-0.91/src/
	  extension/param\string.h:17:28: error: expected class name
	C:/Dave/Mine/software/external-projects/inkscape-0.91/inkscape-0.91/src/
	  extension/param\string.h:27:86: error: use of undeclared identifier 'Parameter'
	
Inkscape defines float.h which conflicts with the external mingw library float.h. This problem can be eliminated by selecting "Analysis/Project Settings", and adding "inkscape-0.91/src/extension/param/" to Exclude Sub-Directories.
	C:/Dave/Mine/software/external-projects/inkscape-0.91/inkscape-0.91/src/
	extension/param\float.h:32:23: error: unknown type name 'gchar'
	
The CLang compiler requires intrinsics from its own header file, and cannot use the one from mingw. The CLang compiler searches some paths which can be seen by adding the -v switch to the compiler options. The first files that CLang is searching for are shipped in the CLang package under the LLVM/lib directory. These must be found before the mingw directories. The best option is NOT to add the mingw directories to a project, since CLang will normally find them. Another option may be to use "-Iclang/3.6.0/include" before the other external package ref arguments ("-EP").
	/gtkmm340_mingw462/lib/gcc/mingw32/4.6.2/include\ia32intrin.h:41:10:
	error: use of undeclared identifier '__builtin_ia32_bsrsi'
	
Inscape requires the Boehm garbage collector. This can be added by defining a new external package, or by using -I with the "include" directory specified. The sigc++ library can be added in the same manner with the "sigc++" directory specified. These packages are probably not needed to get a pretty good analysis of Inkscape.
	C:/Dave/Mine/software/external-projects/inkscape-0.91/inkscape-0.91/src/
	  gc-core.h:25:11: fatal error: 'gc.h' file not found
	
To summarize, by modifying two source files, and creating a simple Oovaide project, it was fairly easy to perform analysis on the Inkscape project.