Building FAQ

From OpenNMS
Jump to: navigation, search

I get an error about "conflicting types for 'unsetenv'" when compiling opennms-iplike

This is the error in more detail:

In file included from /opt/csw/postgresql/include/server/c.h:822,
                 from /opt/csw/postgresql/include/server/postgres.h:48,
                 from /home/dgregor/opennms/trunk/opennms/opennms-iplike/opennms-iplike-solaris/../src/main/native/iplike.c:47:
/opt/csw/postgresql/include/server/port.h:323: error: conflicting types for 'unsetenv'
/usr/include/stdlib.h:188: error: previous declaration of 'unsetenv' was here
/opt/csw/postgresql/include/server/port.h:323: error: conflicting types for 'unsetenv'
/usr/include/stdlib.h:188: error: previous declaration of 'unsetenv' was here

This seems to be due to the PostgreSQL configure script incorrectly determining that the OS does not have an "unsetenv" function. Add "-Dbuild.postgresql.compiler.arg=-DHAVE_UNSETENV" to your build.sh command-line and that should take care of it. E.g.:

JAVA_HOME=/usr/java ./build.sh \
    -Dbuild.postgresql.compiler.arg=-DHAVE_UNSETENV \
    -Dopennms.home=/opt/opennms \
    install assembly:directory-inline

I get an error about "'_FILE_OFFSET_BITS' redefined" when compiling opennms-iplike

This is the error:

In file included from /opt/csw/postgresql/include/server/c.h:53,
                 from /opt/csw/postgresql/include/server/postgres.h:48,
                 from /home/dgregor/opennms/trunk/opennms/opennms-iplike/opennms-iplike-solaris/../src/main/native/iplike.c:46:
/opt/csw/postgresql/include/server/pg_config.h:663:1: "_FILE_OFFSET_BITS" redefined
In file included from /usr/include/iso/ctype_iso.h:30,
                 from /usr/include/ctype.h:18,
                 from /home/dgregor/opennms/trunk/opennms/opennms-iplike/opennms-iplike-solaris/../src/main/native/iplike.c:41:
/usr/include/sys/feature_tests.h:188:1: this is the location of the previous definition

This seems to be due to the PostgreSQL configure script incorrectly determining that the OS does not set _FILE_OFFSET_BITS. Add "-Dbuild.postgresql.compiler.arg=-DUNDEF_FILE_OFFSET_BITS" to your build.sh command-line and that should take care of it. You will most likely also need to set the -DHAVE_UNSETENV compiler option mentioned above, as well. E.g.:

JAVA_HOME=/usr/java ./build.sh \
    -Dbuild.postgresql.compiler.arg="-DHAVE_UNSETENV -DUNDEF_FILE_OFFSET_BITS" \
    -Dopennms.home=/opt/opennms \
    install assembly:directory-inline

Building with a custom localRepository

If you are building with a custom local repository location, set via the maven.repo.local property, you might also want to set the property org.ops4j.pax.url.mvn.localRepository to the same directory. Otherwise you could end up with an error like:

[ERROR] Failed to execute goal org.opennms.maven.plugins:features-maven-plugin:1.0.2-SNAPSHOT:generate-features-xml (features.xml) on project all: Execution features.xml of goal org.opennms.maven.plugins:features-maven-plugin:1.0.2-SNAPSHOT:generate-features-xml failed: URL [mvn:org.opennms.container/karaf/1.13.0-SNAPSHOT/xml/features] could not be resolved. -> [Help 1]
org.apache.maven.lifecycle.LifecycleExecutionException: Failed to execute goal org.opennms.maven.plugins:features-maven-plugin:1.0.2-SNAPSHOT:generate-features-xml (features.xml) on project all: Execution features.xml of goal org.opennms.maven.plugins:features-maven-plugin:1.0.2-SNAPSHOT:generate-features-xml failed: URL [mvn:org.opennms.container/karaf/1.13.0-SNAPSHOT/xml/features] could not be resolved.
        at org.apache.maven.lifecycle.internal.MojoExecutor.execute(MojoExecutor.java:225)
        at org.apache.maven.lifecycle.internal.MojoExecutor.execute(MojoExecutor.java:153)
        at org.apache.maven.lifecycle.internal.MojoExecutor.execute(MojoExecutor.java:145)
        at org.apache.maven.lifecycle.internal.LifecycleModuleBuilder.buildProject(LifecycleModuleBuilder.java:84)
        at org.apache.maven.lifecycle.internal.LifecycleModuleBuilder.buildProject(LifecycleModuleBuilder.java:59)
        at org.apache.maven.lifecycle.internal.LifecycleStarter.singleThreadedBuild(LifecycleStarter.java:183)
        at org.apache.maven.lifecycle.internal.LifecycleStarter.execute(LifecycleStarter.java:161)
        at org.apache.maven.DefaultMaven.doExecute(DefaultMaven.java:320)
        at org.apache.maven.DefaultMaven.execute(DefaultMaven.java:156)
        at org.apache.maven.cli.MavenCli.execute(MavenCli.java:537)
        at org.apache.maven.cli.MavenCli.doMain(MavenCli.java:196)
        at org.apache.maven.cli.MavenCli.main(MavenCli.java:141)
        at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
        at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:57)
        at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
        at java.lang.reflect.Method.invoke(Method.java:606)
        at org.codehaus.plexus.classworlds.launcher.Launcher.launchEnhanced(Launcher.java:290)
        at org.codehaus.plexus.classworlds.launcher.Launcher.launch(Launcher.java:230)
        at org.codehaus.plexus.classworlds.launcher.Launcher.mainWithExitCode(Launcher.java:409)
        at org.codehaus.plexus.classworlds.launcher.Launcher.main(Launcher.java:352)
Caused by: org.apache.maven.plugin.PluginExecutionException: Execution features.xml of goal org.opennms.maven.plugins:features-maven-plugin:1.0.2-SNAPSHOT:generate-features-xml failed: URL [mvn:org.opennms.container/karaf/1.13.0-SNAPSHOT/xml/features] could not be resolved.
        at org.apache.maven.plugin.DefaultBuildPluginManager.executeMojo(DefaultBuildPluginManager.java:110)
        at org.apache.maven.lifecycle.internal.MojoExecutor.execute(MojoExecutor.java:209)
        ... 19 more
Caused by: java.lang.RuntimeException: URL [mvn:org.opennms.container/karaf/1.13.0-SNAPSHOT/xml/features] could not be resolved.
        at org.ops4j.pax.url.mvn.internal.Connection.getInputStream(Connection.java:195)
        at java.net.URL.openStream(URL.java:1037)
        at org.opennms.maven.plugins.karaf.FeaturesBuilder.addRepository(FeaturesBuilder.java:52)
        at org.opennms.maven.plugins.karaf.GenerateFeaturesXmlMojo.addRepositoriesFromConfiguration(GenerateFeaturesXmlMojo.java:195)
        at org.opennms.maven.plugins.karaf.GenerateFeaturesXmlMojo.execute(GenerateFeaturesXmlMojo.java:161)
        at org.apache.maven.plugin.DefaultBuildPluginManager.executeMojo(DefaultBuildPluginManager.java:101)
        ... 20 more

Unable to resolve dependencies for assembly ... build error

The build will fail with an error like:

[ERROR] Failed to execute goal on project org.opennms.core.xml: Could not resolve dependencies for project org.opennms.core:org.opennms.core.xml:bundle:1.12.9-SNAPSHOT: Failure to find oro:oro:jar:2.0.8 in http://maven.opennms.org/content/groups/opennms.org-release was cached in the local repository, resolution will not be reattempted until the update interval of opennms-repo has elapsed or updates are forced -> [Help 1]

Dependencies should automatically be downloaded from the OpenNMS web site. This error can be due to a temporary download timeout. Try running "./compile.pl" again and see if the build gets further.

Windows and NSIS

The build will fail with an error like:

[ERROR] Failed to execute goal org.codehaus.mojo:nsis-maven-plugin:1.0-alpha-1:make (default) on project opennms-remote-poller-windows: Unable to execute makensis: Cannot run program "C:\Progra~1\NSIS\makensis.exe" (in directory "D:\opennms.git\opennms-assemblies\remote-poller-nsis"): CreateProcess error=2, The system cannot find the file specified -> [Help 1]

You need to download NSIS version 2.46. After installing it, modify opennms-assemblies/remote-poller-nsis/pom.xml and set <makensisBin> to the path of where makensis.exe was installed.