在windows 编译 jsvc

一、下载项目

http://commons.apache.org/proper/commons-daemon/jsvc.html

二、安装 cygwin64 

gcc-core、gcc-g++、make、gcc-objc、gcc-objc++

三、开始编译
Cannot find jni_md.h in C:\Program Files\Java\jdk1.8.0_231/Windows_NT

./configure LIBS="C:\Program Files\Java\jdk1.8.0_231\include\win32"
./configure LIBS="/cygdrive/d/Java/jdk1.8.0_231/include/win32"


checking for JDK os include directory... Cannot find jni_md.h in D:\Java\jdk1.8.0_231/Windows_NT
finally: $ ./configure --with-os-type=/include/win32
四、移动代码文件




五·、编译成功
configure
tianq@DESKTOP-GNQ5792 /cygdrive/d/project/work/commons-daemon-1.2.2-src/src/native/unix
$ ./configure --with-os-type=/include/win32
*** Current host ***
checking build system type... x86_64-pc-cygwin
checking host system type... x86_64-pc-cygwin
checking cached host system type... ok
*** C-Language compilation tools ***
checking for gcc... gcc
checking whether the C compiler works... yes
checking for C compiler default output file name... a.exe
checking for suffix of executables... .exe
checking whether we are cross compiling... no
checking for suffix of object files... o
checking whether we are using the GNU C compiler... yes
checking whether gcc accepts -g... yes
checking for gcc option to accept ISO C89... none needed
checking for ranlib... ranlib
checking for strip... strip
*** Host support ***
checking C flags dependant on host system type... ok
*** Java compilation tools ***
gcc flags added
*** Writing output files ***
configure: creating ./config.status
config.status: creating Makefile
config.status: creating Makedefs
config.status: creating native/Makefile
*** All done ***
Now you can issue "make"
make
tianq@DESKTOP-GNQ5792 /cygdrive/d/project/work/commons-daemon-1.2.2-src/src/native/unix
$ make
(cd native; make  all)
make[1]: 进入目录“/cygdrive/d/project/work/commons-daemon-1.2.2-src/src/native/unix/native”
gcc -g -O2 -DOS_CYGWIN -DDSO_DLFCN -DNO_SETSID -DCPU=\"amd64\" -Wall -Wstrict-prototypes   -I/cygdrive/d/Java/jdk1.8.0_231/include -I/cygdrive/d/Java/jdk1.8.0_231/include/win32 -c jsvc-unix.c -o jsvc-unix.o
jsvc-unix.c: 在函数‘run_controller’中:
jsvc-unix.c:1266:20: 警告:assignment to ‘_sig_func_ptr’ {或称 ‘void (*)(int)’} from incompatible pointer type ‘void (*)(int,  siginfo_t *, void *)’ {或称 ‘void (*)(int,  struct <匿名> *, void *)’} [-Wincompatible-pointer-types]
 1266 |     act.sa_handler = controller;
      |                    ^
gcc -g -O2 -DOS_CYGWIN -DDSO_DLFCN -DNO_SETSID -DCPU=\"amd64\" -Wall -Wstrict-prototypes   -I/cygdrive/d/Java/jdk1.8.0_231/include -I/cygdrive/d/Java/jdk1.8.0_231/include/win32 -c signals.c -o signals.o
signals.c: 在函数‘SetTerm’中:
signals.c:61:26: 警告:格式 ‘%ld’ expects argument of type ‘long int’, but argument 3 has type ‘DWORD’ {或称 ‘unsigned int’} [-Wformat=]
   61 |     sprintf(Name, "TERM%ld", GetCurrentProcessId());
      |                        ~~^   ~~~~~~~~~~~~~~~~~~~~~
      |                          |   |
      |                          |   DWORD {或称 unsigned int}
      |                          long int
      |                        %d
在文件作用域:
signals.c:116:12: 警告:‘lockf’ defined but not used [-Wunused-function]
  116 | static int lockf(int fildes, int function, off_t size)
      |            ^~~~~
ar cr libservice.a arguments.o debug.o dso-dlfcn.o dso-dyld.o help.o home.o java.o location.o replace.o locks.o signals.o
ranlib libservice.a
gcc   jsvc-unix.o libservice.a  -o ../jsvc
make[1]: 离开目录“/cygdrive/d/project/work/commons-daemon-1.2.2-src/src/native/unix/native”

jsvc.exe --help

$ ./jsvc.exe --help
Usage: jsvc [-options] class [args...]

Where options include:

    -help | --help | -?
        show this help page (implies -nodetach)
    -jvm 
        use a specific Java Virtual Machine. Available JVMs:
            'server'
    -client
        use a client Java Virtual Machine.
    -server
        use a server Java Virtual Machine.
    -cp | -classpath 
        set search path for service classes and resouces
    -java-home | -home 
        set the path of your JDK or JRE installation (or set
        the JAVA_HOME environment variable)
    -version
        show the current Java environment version (to check
        correctness of -home and -jvm. Implies -nodetach)
    -showversion
        show the current Java environment version (to check
        correctness of -home and -jvm) and continue execution.
    -nodetach
        don't detach from parent process and become a daemon
    -debug
        verbosely print debugging information
    -check
        only check service (implies -nodetach)
    -user 
        user used to run the daemon (defaults to current user)
    -verbose[:class|gc|jni]
        enable verbose output
    -cwd 
        set working directory to given location (defaults to /)
    -outfile
        Location for output from stdout (defaults to /dev/null)
        Use the value '2' to simulate '1>2'
    -errfile 
        Location for output from stderr (defaults to /dev/null)
        Use the value '' to simulate '2>1'
    -pidfile 
        Location for output from the file containing the pid of jsvc
        (defaults to /var/run/jsvc.pid)
    -Dname=value
        set a Java system property
    -Xoptio
        set Virtual Machine specific option
    -ea[:packagename...|:classname]
    -enableassertions[:packagename>...|:classname]
        enable assertions
    -da[:packagename...|:classname
    -disableassertions:packagename...classname
        disable assertions
    -esa | -enablesystemassertions
        enable system assertions
    -dsa | -disablesystemassertions
        disable system assertions
    -agentlib:libname[=options]
        load native agent library libname, e.g. -agentlib:hprof
    -agentpath:pathname[=options]
        load native agent library by full pathname
    -javaagent:jarpath[=options]
        load Java programming language agent, see java.lang.instrument
    -procname procname
        use the specified process name
    -wait waittime
        wait waittime seconds for the service to start
        waittime should multiple of 10 (min=10)
    -restarts maxrestarts
        maximum automatic restarts (integer)
        -1=infinite (default), 0=none, 1..(INT_MAX-1)=fixed restart count
    -stop
        stop the service using the file given in the -pidfile option
    -keepstdin
        does not redirect stdin to /dev/null
    --add-modules=modulename
        Java 9 --add-modules option. Passed as it is to JVM
    --module-path=modulepath
        Java 9 --module-path option. Passed as it is to JVM
    --upgrade-module-path=modulepath
        Java 9 --upgrade-module-path option. Passed as it is to JVM
    --add-reads=modulename
        Java 9 --add-reads option. Passed as it is to JVM
    --add-exports=modulename
        Java 9 --add-exports option. Passed as it is to JVM
    --add-opens=modulename
        Java 9 --add-opens option. Passed as it is to JVM
    --limit-modules=modulename
        Java 9 --limit-modules option. Passed as it is to JVM
    --patch-module=modulename
        Java 9 --patch-module option. Passed as it is to JVM
    --illegal-access=value
        Java 9 --illegal-access option. Passed as it is to JVM.
        Refer java help for possible values.

jsvc (Apache Commons Daemon) 1.2.2
Copyright (c) 1999-2019 Apache Software Foundation.

评论