pquiring / javaforce

JavaForce library for building powerful Apps and Services (Native Bindings for Camera, OpenGL, ffmpeg). Includes VoIP stack, PLC I/O and many apps.
http://pquiring.github.io/javaforce
GNU Lesser General Public License v3.0
55 stars 24 forks source link

Problem while building windows native #12

Closed quentin452 closed 8 months ago

quentin452 commented 8 months ago

When i use Intellij idea

PS C:\Users\iamacatfr\Desktop\github-intellidea\javaforce\native\windows> ant
Buildfile: C:\Users\iamacatfr\Desktop\github-intellidea\javaforce\native\windows\build.xml

windows:
     [exec] The command attribute is deprecated.
     [exec] Please use the executable attribute and nested arg elements.

BUILD FAILED
C:\Users\iamacatfr\Desktop\github-intellidea\javaforce\native\windows\build.xml:8: Execute failed: java.io.IOException: Cannot run program "cl" (in directory "C:\Use
rs\iamacatfr\Desktop\github-intellidea\javaforce\native\windows"): CreateProcess error=2, Le fichier spÚcifiÚ est introuvable
        at java.lang.ProcessBuilder.start(ProcessBuilder.java:1048)
        at java.lang.Runtime.exec(Runtime.java:594)
        at org.apache.tools.ant.taskdefs.launcher.Java13CommandLauncher.exec(Java13CommandLauncher.java:58)
        at org.apache.tools.ant.taskdefs.Execute.launch(Execute.java:424)
        at org.apache.tools.ant.taskdefs.Execute.execute(Execute.java:438)
        at org.apache.tools.ant.taskdefs.ExecTask.runExecute(ExecTask.java:660)
        at org.apache.tools.ant.taskdefs.ExecTask.runExec(ExecTask.java:699)
        at org.apache.tools.ant.taskdefs.ExecTask.execute(ExecTask.java:527)
        at org.apache.tools.ant.UnknownElement.execute(UnknownElement.java:299)
        at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
        at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
        at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
        at java.lang.reflect.Method.invoke(Method.java:498)
        at org.apache.tools.ant.dispatch.DispatchUtils.execute(DispatchUtils.java:99)
        at org.apache.tools.ant.Task.perform(Task.java:350)
        at org.apache.tools.ant.Target.execute(Target.java:449)
        at org.apache.tools.ant.Target.performTasks(Target.java:470)
        at org.apache.tools.ant.Project.executeSortedTargets(Project.java:1401)
        at org.apache.tools.ant.Project.executeTarget(Project.java:1374)
        at org.apache.tools.ant.helper.DefaultExecutor.executeTargets(DefaultExecutor.java:41)
        at org.apache.tools.ant.Project.executeTargets(Project.java:1264)
        at org.apache.tools.ant.Main.runBuild(Main.java:818)
        at org.apache.tools.ant.Main.startAnt(Main.java:223)
        at org.apache.tools.ant.launch.Launcher.run(Launcher.java:284)
        at org.apache.tools.ant.launch.Launcher.main(Launcher.java:101)
Caused by: java.io.IOException: CreateProcess error=2, Le fichier spÚcifiÚ est introuvable
        at java.lang.ProcessImpl.create(Native Method)
        at java.lang.ProcessImpl.<init>(ProcessImpl.java:453)
        at java.lang.ProcessImpl.start(ProcessImpl.java:139)
        at java.lang.ProcessBuilder.start(ProcessBuilder.java:1029)
        ... 24 more

When i use Visual Studio

ant command not found

quentin452 commented 8 months ago

after some adjustments like adding cl path, i had an issue again when building

Unable to open include file: 'windows.h': No such file or directory

build.xml from native/windows

<project name="native" default="windows" basedir=".">
  <description>native</description>
  <property name="home" value="../.."/>
  <property environment="env"/>
  <property name="path.to.cl" value="C:\Program Files\Microsoft Visual Studio\2022\Community\VC\Tools\MSVC\14.38.33130\bin\Hostx64\x64"/>

  <target name="windows" description="create windows native files">
    <!-- native library -->
    <exec command="${path.to.cl}/cl /I '${java.home}/include' /I '${java.home}/include/win32' /I '${env.FFMPEG_HOME}' /I '../headers' native.cpp /c /Fo: native.obj"/>
    <exec command="${path.to.cl}/cl /I '../glfw/include' glfw.c /c /Fo: glfw.obj"/>
    <exec command="${path.to.cl}/lib /nologo /out:native.lib native.obj glfw.obj"/>

    <!-- native loaders -->
    <exec command="${path.to.cl}/cl /I '${java.home}/include' /I '${java.home}/include/win32' windows.cpp native.lib user32.lib gdi32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib strmiids.lib opengl32.lib /Fe: ../win64.exe /link /subsystem:windows /entry:mainCRTStartup"/>
    <exec command="${path.to.cl}/cl /I '${java.home}/include' /I '${java.home}/include/win32' windows.cpp native.lib user32.lib gdi32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib strmiids.lib opengl32.lib /Fe: ../win64c.exe /link /subsystem:console"/>
    <exec command="${path.to.cl}/cl /I '${java.home}/include' /I '${java.home}/include/win32' /D_JF_SERVICE windows.cpp native.lib user32.lib gdi32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib strmiids.lib opengl32.lib /Fe: ../win64s.exe /link /subsystem:console"/>

    <!-- native cli loaders -->
    <exec command="${path.to.cl}/cl /I '${java.home}/include' /I '${java.home}/include/win32' /D_JF_CLI windows.cpp native.lib user32.lib gdi32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib strmiids.lib opengl32.lib /Fe: ../../bin/jfexecw.exe /link /subsystem:windows /entry:mainCRTStartup"/>
    <exec command="${path.to.cl}/cl /I '${java.home}/include' /I '${java.home}/include/win32' /D_JF_CLI windows.cpp native.lib user32.lib gdi32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib strmiids.lib opengl32.lib /Fe: ../../bin/jfexec.exe /link /subsystem:console"/>
    <exec command="${path.to.cl}/cl /I '${java.home}/include' /I '${java.home}/include/win32' /D_JF_CLI /D_JF_DEBUG windows.cpp native.lib user32.lib gdi32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib strmiids.lib opengl32.lib /Fe: ../../bin/jfexecwd.exe /link /subsystem:windows /entry:mainCRTStartup"/>
    <exec command="${path.to.cl}/cl /I '${java.home}/include' /I '${java.home}/include/win32' /D_JF_CLI /D_JF_DEBUG windows.cpp native.lib user32.lib gdi32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib strmiids.lib opengl32.lib /Fe: ../../bin/jfexecd.exe /link /subsystem:console"/>
    <exec command="${path.to.cl}/cl /I '${java.home}/include' /I '${java.home}/include/win32' /D_JF_CLI /D_JF_DEBUG /D_JF_CLI_SERVICE windows.cpp native.lib user32.lib gdi32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib strmiids.lib opengl32.lib /Fe: ../../bin/jfexecsd.exe /link /subsystem:console"/>

    <delete>
      <fileset dir="." includes="*.obj"/>
    </delete>
  </target>

  <target name="get-bin" description="download pre-built binaries">
    <sequential>
      <get src="http://javaforce.sourceforge.net/jf-bin-win64.zip" dest="${home}/jf-bin-win64.zip" usetimestamp="true"/>
      <unzip src="${home}/jf-bin-win64.zip" dest="${home}"/>
    </sequential>
  </target>

  <target name="zip-bin" description="zip pre-built binaries">
    <zip destfile="${home}/jf-bin-win64.zip">
      <fileset dir="${home}">
        <include name="bin/*.exe"/>
        <include name="native/*.exe"/>
      </fileset>
    </zip>
  </target>

</project>

build logs

Windows PowerShell
Copyright (C) Microsoft Corporation. Tous droits réservés.

Testez le nouveau système multiplateforme PowerShell https://aka.ms/pscore6

PS C:\Users\iamacatfr\Desktop\github-intellidea\javaforce\native\windows> ant windows
Buildfile: C:\Users\iamacatfr\Desktop\github-intellidea\javaforce\native\windows\build.xml

windows:
     [exec] The command attribute is deprecated.
     [exec] Please use the executable attribute and nested arg elements.
     [exec] native.cpp
     [exec] native.cpp(1): fatal error C1083: Impossible d'ouvrir le fichier include : 'windows.h' : No such file or directory
     [exec] Compilateur d'optimisation Microsoft (R) C/C++ version 19.38.33135 pour x64
     [exec] Copyright (C) Microsoft Corporation. Tous droits réservés.
     [exec]
     [exec] cl : Ligne de commande warning D9024 : type de fichier source non reconnu 'C:\Program', fichier objet pris par défaut
     [exec] cl : Ligne de commande warning D9027 : fichier source 'C:\Program' ignoré
     [exec] cl : Ligne de commande warning D9024 : type de fichier source non reconnu 'Files\Microsoft', fichier objet pris par défaut
     [exec] cl : Ligne de commande warning D9027 : fichier source 'Files\Microsoft' ignoré
     [exec] cl : Ligne de commande warning D9024 : type de fichier source non reconnu 'Visual', fichier objet pris par défaut
     [exec] cl : Ligne de commande warning D9027 : fichier source 'Visual' ignoré
     [exec] cl : Ligne de commande warning D9024 : type de fichier source non reconnu 'Studio\2022\Community\VC\Tools\MSVC\14.38.33130\bin\Hostx64\x64', fichier obje
t pris par défaut
     [exec] cl : Ligne de commande warning D9027 : fichier source 'Studio\2022\Community\VC\Tools\MSVC\14.38.33130\bin\Hostx64\x64' ignoré
     [exec] Result: 2
     [exec] The command attribute is deprecated.
     [exec] Please use the executable attribute and nested arg elements.
     [exec] glfw.c
     [exec] C:\Users\iamacatfr\Desktop\github-intellidea\javaforce\native\glfw\src\../include/GLFW/glfw3.h(103): fatal error C1083: Impossible d'ouvrir le fichier in
clude : 'stddef.h' : No such file or directory
     [exec] Compilateur d'optimisation Microsoft (R) C/C++ version 19.38.33135 pour x64
     [exec] Copyright (C) Microsoft Corporation. Tous droits réservés.
     [exec]
     [exec] cl : Ligne de commande warning D9024 : type de fichier source non reconnu 'C:\Program', fichier objet pris par défaut
     [exec] cl : Ligne de commande warning D9027 : fichier source 'C:\Program' ignoré
     [exec] cl : Ligne de commande warning D9024 : type de fichier source non reconnu 'Files\Microsoft', fichier objet pris par défaut
     [exec] cl : Ligne de commande warning D9027 : fichier source 'Files\Microsoft' ignoré
     [exec] cl : Ligne de commande warning D9024 : type de fichier source non reconnu 'Visual', fichier objet pris par défaut
     [exec] cl : Ligne de commande warning D9027 : fichier source 'Visual' ignoré
     [exec] cl : Ligne de commande warning D9024 : type de fichier source non reconnu 'Studio\2022\Community\VC\Tools\MSVC\14.38.33130\bin\Hostx64\x64', fichier obje
t pris par défaut
     [exec] cl : Ligne de commande warning D9027 : fichier source 'Studio\2022\Community\VC\Tools\MSVC\14.38.33130\bin\Hostx64\x64' ignoré
     [exec] Result: 2
     [exec] The command attribute is deprecated.
     [exec] Please use the executable attribute and nested arg elements.
     [exec] LINK : fatal error LNK1181: impossible d'ouvrir le fichier en entrée 'native.obj'
     [exec] Result: 1181
     [exec] The command attribute is deprecated.
     [exec] Please use the executable attribute and nested arg elements.
     [exec] windows.cpp
     [exec] windows.cpp(12): fatal error C1083: Impossible d'ouvrir le fichier include : 'windows.h' : No such file or directory
     [exec] Compilateur d'optimisation Microsoft (R) C/C++ version 19.38.33135 pour x64
     [exec] Copyright (C) Microsoft Corporation. Tous droits réservés.
     [exec]
     [exec] cl : Ligne de commande warning D9024 : type de fichier source non reconnu 'C:\Program', fichier objet pris par défaut
     [exec] cl : Ligne de commande warning D9024 : type de fichier source non reconnu 'Files\Microsoft', fichier objet pris par défaut
     [exec] cl : Ligne de commande warning D9024 : type de fichier source non reconnu 'Visual', fichier objet pris par défaut
     [exec] cl : Ligne de commande warning D9024 : type de fichier source non reconnu 'Studio\2022\Community\VC\Tools\MSVC\14.38.33130\bin\Hostx64\x64', fichier obje
t pris par défaut
     [exec] Result: 2
     [exec] The command attribute is deprecated.
     [exec] Please use the executable attribute and nested arg elements.
     [exec] windows.cpp
     [exec] windows.cpp(12): fatal error C1083: Impossible d'ouvrir le fichier include : 'windows.h' : No such file or directory
     [exec] Compilateur d'optimisation Microsoft (R) C/C++ version 19.38.33135 pour x64
     [exec] Copyright (C) Microsoft Corporation. Tous droits réservés.
     [exec]
     [exec] cl : Ligne de commande warning D9024 : type de fichier source non reconnu 'C:\Program', fichier objet pris par défaut
     [exec] cl : Ligne de commande warning D9024 : type de fichier source non reconnu 'Files\Microsoft', fichier objet pris par défaut
     [exec] cl : Ligne de commande warning D9024 : type de fichier source non reconnu 'Visual', fichier objet pris par défaut
     [exec] cl : Ligne de commande warning D9024 : type de fichier source non reconnu 'Studio\2022\Community\VC\Tools\MSVC\14.38.33130\bin\Hostx64\x64', fichier obje
t pris par défaut
     [exec] Result: 2
     [exec] The command attribute is deprecated.
     [exec] Please use the executable attribute and nested arg elements.
     [exec] windows.cpp
     [exec] windows.cpp(12): fatal error C1083: Impossible d'ouvrir le fichier include : 'windows.h' : No such file or directory
     [exec] Compilateur d'optimisation Microsoft (R) C/C++ version 19.38.33135 pour x64
     [exec] Copyright (C) Microsoft Corporation. Tous droits réservés.
     [exec]
     [exec] cl : Ligne de commande warning D9024 : type de fichier source non reconnu 'C:\Program', fichier objet pris par défaut
     [exec] cl : Ligne de commande warning D9024 : type de fichier source non reconnu 'Files\Microsoft', fichier objet pris par défaut
     [exec] cl : Ligne de commande warning D9024 : type de fichier source non reconnu 'Visual', fichier objet pris par défaut
     [exec] cl : Ligne de commande warning D9024 : type de fichier source non reconnu 'Studio\2022\Community\VC\Tools\MSVC\14.38.33130\bin\Hostx64\x64', fichier obje
t pris par défaut
     [exec] Result: 2
     [exec] The command attribute is deprecated.
     [exec] Please use the executable attribute and nested arg elements.
     [exec] windows.cpp
     [exec] windows.cpp(12): fatal error C1083: Impossible d'ouvrir le fichier include : 'windows.h' : No such file or directory
     [exec] Compilateur d'optimisation Microsoft (R) C/C++ version 19.38.33135 pour x64
     [exec] Copyright (C) Microsoft Corporation. Tous droits réservés.
     [exec]
     [exec] cl : Ligne de commande warning D9024 : type de fichier source non reconnu 'C:\Program', fichier objet pris par défaut
     [exec] cl : Ligne de commande warning D9024 : type de fichier source non reconnu 'Files\Microsoft', fichier objet pris par défaut
     [exec] cl : Ligne de commande warning D9024 : type de fichier source non reconnu 'Visual', fichier objet pris par défaut
     [exec] cl : Ligne de commande warning D9024 : type de fichier source non reconnu 'Studio\2022\Community\VC\Tools\MSVC\14.38.33130\bin\Hostx64\x64', fichier obje
t pris par défaut
     [exec] Result: 2
     [exec] The command attribute is deprecated.
     [exec] Please use the executable attribute and nested arg elements.
     [exec] windows.cpp
     [exec] windows.cpp(12): fatal error C1083: Impossible d'ouvrir le fichier include : 'windows.h' : No such file or directory
     [exec] Compilateur d'optimisation Microsoft (R) C/C++ version 19.38.33135 pour x64
     [exec] Copyright (C) Microsoft Corporation. Tous droits réservés.
     [exec]
     [exec] cl : Ligne de commande warning D9024 : type de fichier source non reconnu 'C:\Program', fichier objet pris par défaut
     [exec] cl : Ligne de commande warning D9024 : type de fichier source non reconnu 'Files\Microsoft', fichier objet pris par défaut
     [exec] cl : Ligne de commande warning D9024 : type de fichier source non reconnu 'Visual', fichier objet pris par défaut
     [exec] cl : Ligne de commande warning D9024 : type de fichier source non reconnu 'Studio\2022\Community\VC\Tools\MSVC\14.38.33130\bin\Hostx64\x64', fichier obje
t pris par défaut
     [exec] Result: 2
     [exec] The command attribute is deprecated.
     [exec] Please use the executable attribute and nested arg elements.
     [exec] windows.cpp
     [exec] windows.cpp(12): fatal error C1083: Impossible d'ouvrir le fichier include : 'windows.h' : No such file or directory
     [exec] Compilateur d'optimisation Microsoft (R) C/C++ version 19.38.33135 pour x64
     [exec] Copyright (C) Microsoft Corporation. Tous droits réservés.
     [exec]
     [exec] cl : Ligne de commande warning D9024 : type de fichier source non reconnu 'C:\Program', fichier objet pris par défaut
     [exec] cl : Ligne de commande warning D9024 : type de fichier source non reconnu 'Files\Microsoft', fichier objet pris par défaut
     [exec] cl : Ligne de commande warning D9024 : type de fichier source non reconnu 'Visual', fichier objet pris par défaut
     [exec] cl : Ligne de commande warning D9024 : type de fichier source non reconnu 'Studio\2022\Community\VC\Tools\MSVC\14.38.33130\bin\Hostx64\x64', fichier obje
t pris par défaut
     [exec] Result: 2
     [exec] The command attribute is deprecated.
     [exec] Please use the executable attribute and nested arg elements.
     [exec] windows.cpp
     [exec] windows.cpp(12): fatal error C1083: Impossible d'ouvrir le fichier include : 'windows.h' : No such file or directory
     [exec] Compilateur d'optimisation Microsoft (R) C/C++ version 19.38.33135 pour x64
     [exec] Copyright (C) Microsoft Corporation. Tous droits réservés.
     [exec]
     [exec] cl : Ligne de commande warning D9024 : type de fichier source non reconnu 'C:\Program', fichier objet pris par défaut
     [exec] cl : Ligne de commande warning D9024 : type de fichier source non reconnu 'Files\Microsoft', fichier objet pris par défaut
     [exec] cl : Ligne de commande warning D9024 : type de fichier source non reconnu 'Studio\2022\Community\VC\Tools\MSVC\14.38.33130\bin\Hostx64\x64', fichier obje
t pris par défaut
     [exec] Result: 2

BUILD SUCCESSFUL
Total time: 0 seconds
PS C:\Users\iamacatfr\Desktop\github-intellidea\javaforce\native\windows>
pquiring commented 8 months ago

The VisualC++ compiler requires lots of environment variables (like INCLUDE and LIB).
After you install VisualC++ Build Tools there should be items in the start menu called "Developer Command Prompt". This should setup the required variables. Then run ant from this folder (which needs Java and ant in your path as well).

I use a lot of complex scripts to setup my build environment. Look for vcvars64.bat within VC++ which you can also run to setup the environment.

Thanks,

pquiring commented 8 months ago

I'll see if I can modify the ant task to look for VC++ automatically and make this runnable from an IDE.
But for now try the "Developer Command Prompt".

pquiring commented 8 months ago

There are pre-built natives available. Run "ant get-bin" in this folder to download from sourceforge.

Thanks,

pquiring commented 8 months ago

I've updated the readme.txt file in that folder with more useful info.

pquiring commented 8 months ago

Is your issue resolved? Were you able to compile it or use the pre-built option?

pquiring commented 8 months ago

Closing issue, I've updating readme.txt to help compile (which I agree is a complex setup - nothing on Windows is designed well)