bytedeco / javacpp-presets

The missing Java distribution of native C++ libraries
Other
2.66k stars 740 forks source link

create new preset for qpOASES #723

Closed zhengdi1992 closed 5 years ago

zhengdi1992 commented 5 years ago

i'm try to create new preset for qpOASES..all it works, and build successful but the jnixxx.dylib has not created.. refer to this https://github.com/bytedeco/javacpp/wiki/Basic-Architecture

1.Runs optional external build scripts, such as cppbuild.sh from the JavaCPP Presets (successfully, for easy, I build qpOASES locally first and only cp command in the cppbuild.sh file.) 2.Runs the Parser on the given InfoMap and the header files listed in the @Platform annotation (successfully, i got the file generated qpOASES.java) 3.Runs the Generator on the Java interfaces(maybe failed or omit by some reason?) 4.Runs the native C++ compiler (GCC, Clang, MSVC, NVCC, etc) on the JNI code(maybe failed or omit by some reason?)

where should i check ,and good ideas? thanks a lot.. this is the console by maven install --projects .,qpOASES

mvn install --projects .,qpOASES
[INFO] Scanning for projects...
[INFO] Inspecting build with total of 2 modules...
[INFO] Installing Nexus Staging features:
[INFO]   ... total of 2 executions of maven-deploy-plugin replaced with nexus-staging-maven-plugin
[INFO] ------------------------------------------------------------------------
[INFO] Reactor Build Order:
[INFO] 
[INFO] JavaCPP Presets
[INFO] JavaCPP Presets for qpOASES
[INFO] 
[INFO] ------------------------------------------------------------------------
[INFO] Building JavaCPP Presets 1.5.1-SNAPSHOT
[INFO] ------------------------------------------------------------------------
[INFO] 
[INFO] --- build-helper-maven-plugin:3.0.0:add-source (add-source) @ javacpp-presets ---
[INFO] Source directory: ~/cpptest/javacpp-presets/src/gen/java added.
[INFO] Source directory: ~/cpptest/javacpp-presets/cppbuild/macosx-x86_64/java added.
[INFO] 
[INFO] --- maven-javadoc-plugin:3.0.1:jar (attach-javadocs) @ javacpp-presets ---
[INFO] Not executing Javadoc as the project is not a Java classpath-capable package
[INFO] 
[INFO] --- maven-install-plugin:2.5.2:install (default-install) @ javacpp-presets ---
[INFO] Installing ~/cpptest/javacpp-presets/pom.xml to ~/.m2/repository/org/bytedeco/javacpp-presets/1.5.1-SNAPSHOT/javacpp-presets-1.5.1-SNAPSHOT.pom
[INFO] 
[INFO] ------------------------------------------------------------------------
[INFO] Building JavaCPP Presets for qpOASES 1.2.11
[INFO] ------------------------------------------------------------------------

[INFO] 
[INFO] --- javacpp:1.5.1-SNAPSHOT:build (javacpp-validate) @ qpOASES ---
[INFO] Detected platform "macosx-x86_64"
[INFO] Building for platform "macosx-x86_64"
[INFO] 
[INFO] --- build-helper-maven-plugin:3.0.0:add-source (add-source) @ qpOASES ---
[INFO] Source directory: ~/cpptest/javacpp-presets/qpOASES/src/gen/java added.
[INFO] Source directory: ~/cpptest/javacpp-presets/qpOASES/cppbuild/macosx-x86_64/java added.
[INFO] 
[INFO] --- maven-resources-plugin:3.1.0:resources (javacpp-parser) @ qpOASES ---
[INFO] Using 'UTF-8' encoding to copy filtered resources.
[INFO] Copying 0 resource
[INFO] 
[INFO] --- maven-compiler-plugin:3.8.0:compile (javacpp-parser) @ qpOASES ---
[INFO] Changes detected - recompiling the module!
[INFO] Compiling 1 source file to ~/cpptest/javacpp-presets/qpOASES/target/classes
[INFO] 
[INFO] --- javacpp:1.5.1-SNAPSHOT:build (javacpp-cppbuild-install) @ qpOASES ---
[INFO] Detected platform "macosx-x86_64"
[INFO] Building for platform "macosx-x86_64"
[INFO] bash ~/cpptest/javacpp-presets/qpOASES/../cppbuild.sh install qpOASES -platform=macosx-x86_64 -extension= 
Detected platform "macosx-x86_64"
Building for platform "macosx-x86_64"
Installing "qpOASES"
~/cpptest/javacpp-presets/qpOASES/cppbuild ~/cpptest/javacpp-presets
install qpOASES finish.
~/cpptest/javacpp-presets
[INFO] 
[INFO] --- javacpp:1.5.1-SNAPSHOT:parse (javacpp-parser) @ qpOASES ---
[INFO] Detected platform "macosx-x86_64"
[INFO] Building for platform "macosx-x86_64"
[INFO] Targeting ~/cpptest/javacpp-presets/qpOASES/src/gen/java/qpOASES.java
[INFO] Parsing ~/cpptest/javacpp-presets/qpOASES/cppbuild/macosx-x86_64/include/qpOASES/Bounds.hpp
[INFO] Parsing ~/cpptest/javacpp-presets/qpOASES/cppbuild/macosx-x86_64/include/qpOASES/Constants.hpp
[INFO] Parsing ~/cpptest/javacpp-presets/qpOASES/cppbuild/macosx-x86_64/include/qpOASES/ConstraintProduct.hpp
[INFO] Parsing ~/cpptest/javacpp-presets/qpOASES/cppbuild/macosx-x86_64/include/qpOASES/Constraints.hpp
[INFO] Parsing ~/cpptest/javacpp-presets/qpOASES/cppbuild/macosx-x86_64/include/qpOASES/Flipper.hpp
[INFO] Parsing ~/cpptest/javacpp-presets/qpOASES/cppbuild/macosx-x86_64/include/qpOASES/Indexlist.hpp
[INFO] Parsing ~/cpptest/javacpp-presets/qpOASES/cppbuild/macosx-x86_64/include/qpOASES/LapackBlasReplacement.hpp
[INFO] Parsing ~/cpptest/javacpp-presets/qpOASES/cppbuild/macosx-x86_64/include/qpOASES/Matrices.hpp
[INFO] Parsing ~/cpptest/javacpp-presets/qpOASES/cppbuild/macosx-x86_64/include/qpOASES/MessageHandling.hpp
[INFO] Parsing ~/cpptest/javacpp-presets/qpOASES/cppbuild/macosx-x86_64/include/qpOASES/Options.hpp
[INFO] Parsing ~/cpptest/javacpp-presets/qpOASES/cppbuild/macosx-x86_64/include/qpOASES/QProblem.hpp
[INFO] Parsing ~/cpptest/javacpp-presets/qpOASES/cppbuild/macosx-x86_64/include/qpOASES/QProblemB.hpp
[INFO] Parsing ~/cpptest/javacpp-presets/qpOASES/cppbuild/macosx-x86_64/include/qpOASES/SQProblem.hpp
[INFO] Parsing ~/cpptest/javacpp-presets/qpOASES/cppbuild/macosx-x86_64/include/qpOASES/SQProblemSchur.hpp
[INFO] Parsing ~/cpptest/javacpp-presets/qpOASES/cppbuild/macosx-x86_64/include/qpOASES/SparseSolver.hpp
[INFO] Parsing ~/cpptest/javacpp-presets/qpOASES/cppbuild/macosx-x86_64/include/qpOASES/SubjectTo.hpp
[INFO] Parsing ~/cpptest/javacpp-presets/qpOASES/cppbuild/macosx-x86_64/include/qpOASES/Types.hpp
[INFO] Parsing ~/cpptest/javacpp-presets/qpOASES/cppbuild/macosx-x86_64/include/qpOASES/UnitTesting.hpp
[INFO] Parsing ~/cpptest/javacpp-presets/qpOASES/cppbuild/macosx-x86_64/include/qpOASES/Utils.hpp
[INFO] Parsing ~/cpptest/javacpp-presets/qpOASES/cppbuild/macosx-x86_64/include/qpOASES_wrapper.h
[INFO] 
[INFO] --- maven-resources-plugin:3.1.0:resources (default-resources) @ qpOASES ---
[INFO] Using 'UTF-8' encoding to copy filtered resources.
[INFO] Copying 0 resource
[INFO] 
[INFO] --- maven-compiler-plugin:3.8.0:compile (default-compile) @ qpOASES ---
[INFO] Changes detected - recompiling the module!
[INFO] Compiling 3 source files to ~/cpptest/javacpp-presets/qpOASES/target/classes
[INFO] ~/cpptest/javacpp-presets/qpOASES/src/gen/java/qpOASES.java: ~/cpptest/javacpp-presets/qpOASES/src/gen/java/qpOASES.java使用了未经检查或不安全的操作。
[INFO] ~/cpptest/javacpp-presets/qpOASES/src/gen/java/qpOASES.java: 有关详细信息, 请使用 -Xlint:unchecked 重新编译。
[INFO] 
[INFO] --- javacpp:1.5.1-SNAPSHOT:build (javacpp-compiler) @ qpOASES ---
[INFO] Detected platform "macosx-x86_64"
[INFO] Building for platform "macosx-x86_64"
[INFO] Targeting ~/cpptest/javacpp-presets/qpOASES/target/native/org/bytedeco/qpOASES/macosx-x86_64/qpOASES.java
[INFO] Parsing ~/cpptest/javacpp-presets/qpOASES/cppbuild/macosx-x86_64/include/qpOASES/Bounds.hpp
[INFO] Parsing ~/cpptest/javacpp-presets/qpOASES/cppbuild/macosx-x86_64/include/qpOASES/Constants.hpp
[INFO] Parsing ~/cpptest/javacpp-presets/qpOASES/cppbuild/macosx-x86_64/include/qpOASES/ConstraintProduct.hpp
[INFO] Parsing ~/cpptest/javacpp-presets/qpOASES/cppbuild/macosx-x86_64/include/qpOASES/Constraints.hpp
[INFO] Parsing ~/cpptest/javacpp-presets/qpOASES/cppbuild/macosx-x86_64/include/qpOASES/Flipper.hpp
[INFO] Parsing ~/cpptest/javacpp-presets/qpOASES/cppbuild/macosx-x86_64/include/qpOASES/Indexlist.hpp
[INFO] Parsing ~/cpptest/javacpp-presets/qpOASES/cppbuild/macosx-x86_64/include/qpOASES/LapackBlasReplacement.hpp
[INFO] Parsing ~/cpptest/javacpp-presets/qpOASES/cppbuild/macosx-x86_64/include/qpOASES/Matrices.hpp
[INFO] Parsing ~/cpptest/javacpp-presets/qpOASES/cppbuild/macosx-x86_64/include/qpOASES/MessageHandling.hpp
[INFO] Parsing ~/cpptest/javacpp-presets/qpOASES/cppbuild/macosx-x86_64/include/qpOASES/Options.hpp
[INFO] Parsing ~/cpptest/javacpp-presets/qpOASES/cppbuild/macosx-x86_64/include/qpOASES/QProblem.hpp
[INFO] Parsing ~/cpptest/javacpp-presets/qpOASES/cppbuild/macosx-x86_64/include/qpOASES/QProblemB.hpp
[INFO] Parsing ~/cpptest/javacpp-presets/qpOASES/cppbuild/macosx-x86_64/include/qpOASES/SQProblem.hpp
[INFO] Parsing ~/cpptest/javacpp-presets/qpOASES/cppbuild/macosx-x86_64/include/qpOASES/SQProblemSchur.hpp
[INFO] Parsing ~/cpptest/javacpp-presets/qpOASES/cppbuild/macosx-x86_64/include/qpOASES/SparseSolver.hpp
[INFO] Parsing ~/cpptest/javacpp-presets/qpOASES/cppbuild/macosx-x86_64/include/qpOASES/SubjectTo.hpp
[INFO] Parsing ~/cpptest/javacpp-presets/qpOASES/cppbuild/macosx-x86_64/include/qpOASES/Types.hpp
[INFO] Parsing ~/cpptest/javacpp-presets/qpOASES/cppbuild/macosx-x86_64/include/qpOASES/UnitTesting.hpp
[INFO] Parsing ~/cpptest/javacpp-presets/qpOASES/cppbuild/macosx-x86_64/include/qpOASES/Utils.hpp
[INFO] Parsing ~/cpptest/javacpp-presets/qpOASES/cppbuild/macosx-x86_64/include/qpOASES_wrapper.h
[INFO] 
[INFO] --- maven-resources-plugin:3.1.0:testResources (default-testResources) @ qpOASES ---
[INFO] Using 'UTF-8' encoding to copy filtered resources.
[INFO] skip non existing resourceDirectory ~/cpptest/javacpp-presets/qpOASES/src/test/resources
[INFO] 
[INFO] --- maven-compiler-plugin:3.8.0:testCompile (default-testCompile) @ qpOASES ---
[INFO] No sources to compile
[INFO] 
[INFO] --- maven-surefire-plugin:2.12.4:test (default-test) @ qpOASES ---
[INFO] No tests to run.
[INFO] 
[INFO] --- maven-jar-plugin:3.1.0:jar (default-jar) @ qpOASES ---
[INFO] Building jar: ~/cpptest/javacpp-presets/qpOASES/target/qpOASES.jar
[INFO] 
[INFO] --- maven-javadoc-plugin:3.0.1:jar (attach-javadocs) @ qpOASES ---
    omit...
[INFO] --- maven-jar-plugin:3.1.0:jar (javacpp-macosx-x86_64) @ qpOASES ---
[INFO] Building jar: ~/cpptest/javacpp-presets/qpOASES/target/qpOASES-macosx-x86_64.jar
[INFO] 
[INFO] --- maven-install-plugin:2.5.2:install (default-install) @ qpOASES ---
[INFO] Installing ~/cpptest/javacpp-presets/qpOASES/target/qpOASES.jar to ~/.m2/repository/org/bytedeco/javacpp-presets/qpOASES/1.2.11/qpOASES-1.2.11.jar
[INFO] Installing ~/cpptest/javacpp-presets/qpOASES/pom.xml to ~/.m2/repository/org/bytedeco/javacpp-presets/qpOASES/1.2.11/qpOASES-1.2.11.pom
[INFO] Installing ~/cpptest/javacpp-presets/qpOASES/target/qpOASES-javadoc.jar to ~/.m2/repository/org/bytedeco/javacpp-presets/qpOASES/1.2.11/qpOASES-1.2.11-javadoc.jar
[INFO] Installing ~/cpptest/javacpp-presets/qpOASES/target/qpOASES-macosx-x86_64.jar to ~/.m2/repository/org/bytedeco/javacpp-presets/qpOASES/1.2.11/qpOASES-1.2.11-macosx-x86_64.jar
[INFO] ------------------------------------------------------------------------
[INFO] Reactor Summary:
[INFO] 
[INFO] JavaCPP Presets .................................... SUCCESS [  1.034 s]
[INFO] JavaCPP Presets for qpOASES ........................ SUCCESS [ 12.025 s]
[INFO] ------------------------------------------------------------------------
[INFO] BUILD SUCCESS
[INFO] ------------------------------------------------------------------------
[INFO] Total time: 14.080 s
[INFO] Finished at: 2019-05-07T10:31:39+08:00
[INFO] Final Memory: 60M/1348M
[INFO] ------------------------------------------------------------------------
zhengdi1992 commented 5 years ago

image

the only things in qpOASES-macos-x86_64.jar was that..without any jni dylib

saudet commented 5 years ago

It looks like you forgot to specify some class or package for the execution of javacpp-compiler. The default is defined here but that doesn't match your class names, so you'll need to override that: https://github.com/bytedeco/javacpp-presets/blob/master/pom.xml#L297

zhengdi1992 commented 5 years ago

thank you for your advice.. cool, it's right.. i have change the mapper class from target = "qpOASES", target = "org.bytedeco.qpOASES.presets.qpOASES", and now it was match the default path..

[INFO] clang++ -I~/cpptest/javacpp-presets/qpOASES/cppbuild/macosx-x86_64/include/ -I/Library/Java/JavaVirtualMachines/jdk1.8.0_151.jdk/Contents/Home/include -I/Library/Java/JavaVirtualMachines/jdk1.8.0_151.jdk/Contents/Home/include/darwin ~/cpptest/javacpp-presets/qpOASES/target/native/org/bytedeco/qpOASES/macosx-x86_64/jniqpOASES.cpp ~/cpptest/javacpp-presets/qpOASES/target/native/org/bytedeco/qpOASES/macosx-x86_64/jnijavacpp.cpp -march=x86-64 -m64 -O3 -Wl,-rpath,@loader_path/. -Wall -fPIC -dynamiclib -undefined dynamic_lookup -o libjniqpOASES.dylib -L~/cpptest/javacpp-presets/qpOASES/cppbuild/macosx-x86_64/lib/ -Wl,-rpath,~/cpptest/javacpp-presets/qpOASES/cppbuild/macosx-x86_64/lib/ -framework JavaVM 

and some compile type error .. just like unknown type name 'QProblem'; did you mean 'qpOASES::QProblem'?

i think it should modify the mapper class, first . i will figure it out : )

zhengdi1992 commented 5 years ago

i have build it successfully...

[INFO] --- javacpp:1.5.1-SNAPSHOT:build (javacpp-compiler) @ qpOASES ---
[INFO] Detected platform "macosx-x86_64"
[INFO] Building for platform "macosx-x86_64"
[INFO] Generating ~/cpptest/javacpp-presets/qpOASES/target/native/org/bytedeco/qpOASES/macosx-x86_64/jnijavacpp.cpp
[INFO] Generating ~/cpptest/javacpp-presets/qpOASES/target/native/org/bytedeco/qpOASES/macosx-x86_64/jniqpOASES.cpp
[INFO] Compiling ~/cpptest/javacpp-presets/qpOASES/target/native/org/bytedeco/qpOASES/macosx-x86_64/libjniqpOASES.dylib
[INFO] clang++ -I~/cpptest/javacpp-presets/qpOASES/cppbuild/macosx-x86_64/include/ -I/Library/Java/JavaVirtualMachines/jdk1.8.0_151.jdk/Contents/Home/include -I/Library/Java/JavaVirtualMachines/jdk1.8.0_151.jdk/Contents/Home/include/darwin ~/cpptest/javacpp-presets/qpOASES/target/native/org/bytedeco/qpOASES/macosx-x86_64/jniqpOASES.cpp ~/cpptest/javacpp-presets/qpOASES/target/native/org/bytedeco/qpOASES/macosx-x86_64/jnijavacpp.cpp -march=x86-64 -m64 -O3 -Wl,-rpath,@loader_path/. -Wall -fPIC -dynamiclib -undefined dynamic_lookup -o libjniqpOASES.dylib -L~/cpptest/javacpp-presets/qpOASES/cppbuild/macosx-x86_64/lib/ -Wl,-rpath,~/cpptest/javacpp-presets/qpOASES/cppbuild/macosx-x86_64/lib/ -framework JavaVM 
[INFO] Deleting ~/cpptest/javacpp-presets/qpOASES/target/native/org/bytedeco/qpOASES/macosx-x86_64/jniqpOASES.cpp
[INFO] Deleting ~/cpptest/javacpp-presets/qpOASES/target/native/org/bytedeco/qpOASES/macosx-x86_64/jnijavacpp.cpp
[INFO] 

but in runtime i simple call a native method qpOASES.QProblem_cleanup(); occur a link error

dyld: lazy symbol binding failed: Symbol not found: __Z16QProblem_cleanupv
  Referenced from: ~/cpptest/javacpp-presets/qpOASES/target/native/org/bytedeco/qpOASES/macosx-x86_64/libjniqpOASES.dylib
  Expected in: flat namespace

dyld: Symbol not found: __Z16QProblem_cleanupv
  Referenced from: ~/cpptest/javacpp-presets/qpOASES/target/native/org/bytedeco/qpOASES/macosx-x86_64/libjniqpOASES.dylib
  Expected in: flat namespace

i has check the libjniqpOASES.dylib by otool -L libjniqpOASES.dylib show like this

otool -L libjniqpOASES.dylib 
libjniqpOASES.dylib:
    libjniqpOASES.dylib (compatibility version 0.0.0, current version 0.0.0)
    /System/Library/Frameworks/JavaVM.framework/Versions/A/JavaVM (compatibility version 1.0.0, current version 1.0.0)
    /usr/lib/libc++.1.dylib (compatibility version 1.0.0, current version 400.9.4)
    /usr/lib/libSystem.B.dylib (compatibility version 1.0.0, current version 1252.200.5)

otool -L libqpOASES.dylib 
libqpOASES.dylib:
    libqpOASES.3.2.dylib (compatibility version 3.2.0, current version 0.0.0)
    /usr/lib/libc++.1.dylib (compatibility version 1.0.0, current version 400.9.4)
    /usr/lib/libSystem.B.dylib (compatibility version 1.0.0, current version 1252.200.5)

the generate jnilib has no link the dylib which installed by cppbuild.sh ? and other advice for this error?

saudet commented 5 years ago

Use @Platform(link = "qpOASES", ...) to link with it.

saudet commented 5 years ago

Please let me know if you encounter any more errors! Thanks

zhengdi1992 commented 5 years ago

all build was successful, and jnilib also link to the qpOASES.dylib, the only problem was that, when i call simple native method occur

dyld: lazy symbol binding failed: Symbol not found: __Z16QProblem_cleanupv
  Referenced from: ~/cpptest/javacpp-presets/qpOASES/target/native/org/bytedeco/qpOASES/macosx-x86_64/libjniqpOASES.dylib
  Expected in: flat namespace

i' m not sure it was the problem by cpp or not.

mapper class was that

@Properties(
    target = "org.bytedeco.qpOASES.presets.qpOASES",
    value = {
        @Platform(
            link = "qpOASES",
            includepath = "~/cpptest/javacpp-presets/qpOASES/cppbuild/macosx-x86_64/include/",
            linkpath = "~/cpptest/javacpp-presets/qpOASES/cppbuild/macosx-x86_64/lib/",
            include = {
                "qpOASES_wrapper.h"
            }
        )
    }
)
public class qpOASESConfig implements InfoMapper {

  @Override
  public void map(InfoMap infoMap) {
    infoMap
        .put(new Info(
          "QProblemBClass","OptionsClass","returnValue","QProblem","QProblemB","SQProblem","Options").skip());
  }
}

and i can also get the QProblem_cleanup method from the qpOASES_wrapper.h file

/*
 *  This file is part of qpOASES.
 *
 *  qpOASES -- An Implementation of the Online Active Set Strategy.
 *  Copyright (C) 2007-2017 by Hans Joachim Ferreau, Andreas Potschka,
 *  Christian Kirches et al. All rights reserved.
 *
 *  qpOASES is free software; you can redistribute it and/or
 *  modify it under the terms of the GNU Lesser General Public
 *  License as published by the Free Software Foundation; either
 *  version 2.1 of the License, or (at your option) any later version.
 *
 *  qpOASES is distributed in the hope that it will be useful,
 *  but WITHOUT ANY WARRANTY; without even the implied warranty of
 *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
 *  See the GNU Lesser General Public License for more details.
 *
 *  You should have received a copy of the GNU Lesser General Public
 *  License along with qpOASES; if not, write to the Free Software
 *  Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301  USA
 *
 */

/**
 *  \file interfaces/c/qpOASES_wrapper.h
 *  \author Hans Joachim Ferreau
 *  \version 3.2
 *  \date 2014-2017
 *
 *  Interface that enables to call qpOASES from plain C.
 *
 */

#ifndef QPOASES_WRAPPER_H
#define QPOASES_WRAPPER_H

#ifndef QPOASES_TYPES_HPP

    /**
     * Defined integer type for calling BLAS/LAPACK. Should usually be
     * "(unsigned) int", currently set to "(unsigned) long" for backwards
     * compatibility. This will change in a future release.
     */
    typedef long la_int_t;
    typedef unsigned long la_uint_t;

    /** Defines real_t for facilitating switching between double and float. */
    #ifdef __USE_SINGLE_PRECISION__
    typedef float real_t;
    #else
    typedef double real_t;
    #endif /* __USE_SINGLE_PRECISION__ */

    /** Defines int_t for facilitating switching between int and long int. */
    #ifdef __USE_LONG_INTEGERS__
    typedef long int_t;
    typedef unsigned long uint_t;
    #else
    typedef int int_t;
    typedef unsigned int uint_t;
    #endif /* __USE_LONG_INTEGERS__ */

    /** Defines FORTRAN integer type. Might be platform dependent! */
    #ifdef __USE_LONG_FINTS__
    typedef long fint_t;
    #else
    typedef int fint_t;
    #endif /* __USE_LONG_FINTS__ */

    /**
     * Integer type for sparse matrix row/column entries. Make this "int"
     * for 32 bit entries, and "long" for 64-bit entries on x86_64 platform.
     *
     * Most sparse codes still assume 32-bit entries here (HSL, BQPD, ...)
     */
    typedef int_t sparse_int_t;

    /* dummy definitions, not used when calling from C */
    #define QProblemBClass int_t
    #define OptionsClass int_t
    #define returnValue int_t

    /* HessianType */
    #define HST_ZERO             0
    #define HST_IDENTITY         1
    #define HST_POSDEF           2
    #define HST_POSDEF_NULLSPACE 3
    #define HST_SEMIDEF          4
    #define HST_INDEF            5
    #define HST_UNKNOWN          6

    /* SubjectToStatus */
    #define ST_LOWER            -1
    #define ST_INACTIVE          0
    #define ST_UPPER             1
    #define ST_INFEASIBLE_LOWER  2
    #define ST_INFEASIBLE_UPPER  3
    #define ST_UNDEFINED         4

    /* PrintLevel */
    #define PL_DEBUG_ITER       -2
    #define PL_TABULAR          -1
    #define PL_NONE              0
    #define PL_LOW               1
    #define PL_MEDIUM            2
    #define PL_HIGH              3

#else 

    #define QProblemBClass QProblemB
    #define OptionsClass REFER_NAMESPACE_QPOASES Options 

    /* only declare when compiling C++ library */
    static QProblem*  globalQProblemObject  = 0;
    static QProblemB* globalQProblemBObject = 0;
    static SQProblem* globalSQProblemObject = 0;
    static Options globalOptionsObject;

#endif /* QPOASES_TYPES_HPP */

/**
 *  \brief Manages all user-specified options for solving QPs.
 *
 *  This struct manages all user-specified options used for solving
 *  quadratic programs.
 *
 *  \author Hans Joachim Ferreau
 *  \version 3.2
 *  \date 2014-2017
 */
typedef struct
{
    int_t printLevel;                       /**< Print level. */

    int_t enableRamping;                    /**< Specifies whether ramping shall be enabled or not. */
    int_t enableFarBounds;                  /**< Specifies whether far bounds shall be used or not. */
    int_t enableFlippingBounds;             /**< Specifies whether flipping bounds shall be used or not. */
    int_t enableRegularisation;             /**< Specifies whether Hessian matrix shall be regularised in case semi-definiteness is detected. */
    int_t enableFullLITests;                /**< Specifies whether condition-hardened LI test shall be used or not. */
    int_t enableNZCTests;                   /**< Specifies whether nonzero curvature tests shall be used. */
    int_t enableDriftCorrection;            /**< Specifies the frequency of drift corrections (0 = off). */
    int_t enableCholeskyRefactorisation;    /**< Specifies the frequency of full refactorisation of proj. Hessian (otherwise updates). */
    int_t enableEqualities;                 /**< Specifies whether equalities shall be always treated as active constraints. */

    real_t terminationTolerance;            /**< Termination tolerance. */
    real_t boundTolerance;                  /**< Lower/upper (constraints') bound tolerance (an inequality constraint whose lower and 
                                                 upper bounds differ by less is regarded to be an equality constraint). */
    real_t boundRelaxation;                 /**< Offset for relaxing (constraints') bounds at beginning of an initial homotopy. It is also as initial value for far bounds. */
    real_t epsNum;                          /**< Numerator tolerance for ratio tests. */
    real_t epsDen;                          /**< Denominator tolerance for ratio tests. */
    real_t maxPrimalJump;                   /**< Maximum allowed jump in primal variables in nonzero curvature tests. */
    real_t maxDualJump;                     /**< Maximum allowed jump in dual variables in linear independence tests. */

    real_t initialRamping;                  /**< Start value for Ramping Strategy. */
    real_t finalRamping;                    /**< Final value for Ramping Strategy. */
    real_t initialFarBounds;                /**< Initial size of Far Bounds. */
    real_t growFarBounds;                   /**< Factor to grow Far Bounds. */
    int_t initialStatusBounds;              /**< Initial status of bounds at first iteration. */
    real_t epsFlipping;                     /**< Tolerance of squared Cholesky diagonal factor which triggers flipping bound. */
    int_t numRegularisationSteps;           /**< Maximum number of successive regularisation steps. */
    real_t epsRegularisation;               /**< Scaling factor of identity matrix used for Hessian regularisation. */
    int_t numRefinementSteps;               /**< Maximum number of iterative refinement steps. */
    real_t epsIterRef;                      /**< Early termination tolerance for iterative refinement. */
    real_t epsLITests;                      /**< Tolerance for linear independence tests. */
    real_t epsNZCTests;                     /**< Tolerance for nonzero curvature tests. */

    real_t rcondSMin;                       /**< Minimum reciprocal condition number of S before refactorization is triggered */
    int_t enableInertiaCorrection;          /**< Specifies whether the working set should be repaired when negative curvature is discovered during hotstart. */

    int_t enableDropInfeasibles;            /**< ... */
    int_t dropBoundPriority;                /**< ... */
    int_t dropEqConPriority;                /**< ... */
    int_t dropIneqConPriority;              /**< ... */
    int_t printResiduals;                   /**< If true, it will print the internal qpOASES residuals and other information per iteration */

} qpOASES_Options;

int_t qpOASES_Options_init( qpOASES_Options* const options,
                            int_t mode
                            );

int_t qpOASES_Options_copy( const qpOASES_Options* const from,
                            OptionsClass* const to
                            );

int_t qpOASES_obtainOutputs(    const QProblemBClass* const globalQpObject,
                                returnValue returnvalue,
                                real_t* const x,
                                real_t* const y,
                                real_t* const obj,
                                int_t* const status
                                );

int_t QProblem_setup(   int_t nV,
                        int_t nC,
                        int_t hessianType
                        );

int_t QProblem_init(    const real_t* const H,
                        const real_t* const g,
                        const real_t* const A,
                        const real_t* const lb,
                        const real_t* const ub,
                        const real_t* const lbA,
                        const real_t* const ubA,
                        int_t* const nWSR,
                        real_t* const cputime,
                        const qpOASES_Options* const options,
                        real_t* const x,
                        real_t* const y,
                        real_t* const obj,
                        int_t* const status
                        );

int_t QProblem_hotstart(    const real_t* const g,
                            const real_t* const lb,
                            const real_t* const ub,
                            const real_t* const lbA,
                            const real_t* const ubA,
                            int_t* const nWSR,
                            real_t* const cputime,
                            real_t* const x,
                            real_t* const y,
                            real_t* const obj,
                            int_t* const status
                            );

int_t QProblem_cleanup( );

int_t QProblemB_setup(  int_t nV,
                        int_t hessianType
                        );

int_t QProblemB_init(   const real_t* const H,
                        const real_t* const g,
                        const real_t* const lb,
                        const real_t* const ub,
                        int_t* const nWSR,
                        real_t* const cputime,
                        const qpOASES_Options* const options,
                        real_t* const x,
                        real_t* const y,
                        real_t* const obj,
                        int_t* const status
                        );

int_t QProblemB_hotstart(   const real_t* const g,
                            const real_t* const lb,
                            const real_t* const ub,
                            int_t* const nWSR,
                            real_t* const cputime,
                            real_t* const x,
                            real_t* const y,
                            real_t* const obj,
                            int_t* const status
                            );

int_t QProblemB_cleanup( );

int_t SQProblem_setup(  int_t nV,
                        int_t nC,
                        int_t hessianType
                        );

int_t SQProblem_init(   const real_t* const H,
                        const real_t* const g,
                        const real_t* const A,
                        const real_t* const lb,
                        const real_t* const ub,
                        const real_t* const lbA,
                        const real_t* const ubA,
                        int_t* const nWSR,
                        real_t* const cputime,
                        const qpOASES_Options* const options,
                        real_t* const x,
                        real_t* const y,
                        real_t* const obj,
                        int_t* const status
                        );

int_t SQProblem_hotstart(   const real_t* const H,
                            const real_t* const g,
                            const real_t* const A,
                            const real_t* const lb,
                            const real_t* const ub,
                            const real_t* const lbA,
                            const real_t* const ubA,
                            int_t* const nWSR,
                            real_t* const cputime,
                            real_t* const x,
                            real_t* const y,
                            real_t* const obj,
                            int_t* const status
                            );

int_t SQProblem_cleanup( );

#endif /* QPOASES_WRAPPER_H */

/*
 *  end of file
 */
saudet commented 5 years ago

It's possible that libqpOASES.dylib wasn't built properly to work with rpath. What does otool -L say?

zhengdi1992 commented 5 years ago
$ otool -L libqpOASES.dylib 
libqpOASES.dylib:
    libqpOASES.3.2.dylib (compatibility version 3.2.0, current version 0.0.0)
    /usr/lib/libc++.1.dylib (compatibility version 1.0.0, current version 400.9.4)
    /usr/lib/libSystem.B.dylib (compatibility version 1.0.0, current version 1252.200.5)
zhengdi1992 commented 5 years ago

rename for libqpOASES.3.2.dylib and still the same problem

cppbuild.sh

cp ~/or/qpOASES2/build/libs/libqpOASES.3.2.dylib ~/cpptest/javacpp-presets/qpOASES/cppbuild/macosx-x86_64/lib/libqpOASES.3.2.dylib

mapper.java

@Platform(
            link = "qpOASES.3.2",
             ....
        )

now otool -L

otool -L libqpOASES.3.2.dylib 
libqpOASES.3.2.dylib:
    libqpOASES.3.2.dylib (compatibility version 3.2.0, current version 0.0.0)
    /usr/lib/libc++.1.dylib (compatibility version 1.0.0, current version 400.9.4)
    /usr/lib/libSystem.B.dylib (compatibility version 1.0.0, current version 1252.200.5)
saudet commented 5 years ago

Yeah, that's not going to work. To get this working, we can run the following before the building the presets:

install_name_tool -add_rpath @loader_path/. -id @rpath/libqpOASES.3.2.dylib libqpOASES.3.2.dylib
zhengdi1992 commented 5 years ago

i'v add the rpath.. and maven rebuild it now otools says that in the dir auto generated ~/cpptest/javacpp-presets/qpOASES/target/native/org/bytedeco/qpOASES/macosx-x86_64

$ otool -L libjniqpOASES.dylib 
libjniqpOASES.dylib:
    libjniqpOASES.dylib (compatibility version 0.0.0, current version 0.0.0)
    @rpath/libqpOASES.3.2.dylib (compatibility version 3.2.0, current version 0.0.0)
    /System/Library/Frameworks/JavaVM.framework/Versions/A/JavaVM (compatibility version 1.0.0, current version 1.0.0)
    /usr/lib/libc++.1.dylib (compatibility version 1.0.0, current version 400.9.4)
    /usr/lib/libSystem.B.dylib (compatibility version 1.0.0, current version 1252.200.5)

$ otool -L libqpOASES.3.2.dylib 
libqpOASES.3.2.dylib:
    @rpath/libqpOASES.3.2.dylib (compatibility version 3.2.0, current version 0.0.0)
    /usr/lib/libc++.1.dylib (compatibility version 1.0.0, current version 400.9.4)
    /usr/lib/libSystem.B.dylib (compatibility version 1.0.0, current version 1252.200.5)

but the same error still exist :(

saudet commented 5 years ago

So it looks like the library provides no definition for the QProblem_cleanup() function. You'll need to skip any missing symbols like that:

infoMap.put(new Info("QProblem_cleanup", ...).skip())
zhengdi1992 commented 5 years ago

you got it .. the warpper .h file was extra create for define some important method for use qpOASES methods... but never compile and install to a dylib.. (i misunderstand that cpp will did this things..)

so i should do it first install a dylib which between the jni dylib and the qpOASES.dylib... or i also could user the generated java interface qpOASES.java to wrapper the same things?

zhengdi1992 commented 5 years ago

java swig can use a extra wrapper .cpp/.cxx file to generate the jni lib, but cpp Actually not?

saudet commented 5 years ago

JavaCPP can do the same, yes.

zhengdi1992 commented 5 years ago

one more question.. sometimes we only want to use part of the c++ functions dylib, so we will make a warpper file.. if i use javacpp to generate jni interface... for the configeMapper.java should i only include the only warpper file ? or recursion include all dependency file which define the struct whose userd in the warpper file ? Any good idea if possiable can use the configeMapper.java with infoMap? recursion include maybe a very huge job ...

saudet commented 5 years ago

We only need to include what's useful for the wrapper.

saudet commented 5 years ago

It's also possible to include only portions of files: https://github.com/bytedeco/javacpp/wiki/Mapping-Recipes#skipping-lines-from-header-files