Welcome, Guest. Please login or register. Did you miss your activation email?

Author Topic: How to build JSFML  (Read 41249 times)

0 Members and 1 Guest are viewing this topic.

Hiura

  • SFML Team
  • Hero Member
  • *****
  • Posts: 4321
    • View Profile
    • Email
How to build JSFML
« Reply #15 on: February 02, 2012, 07:43:10 pm »
Quote from: "pdinklag"
Well yeah, sort it out and file a pull request or something.

Things are probably way easier if I just give you access to the repo.
I'll go for a pull request so you have one nice commit and not a bunch of try and mistake commits. :wink:

Quote from: "pdinklag"
One little request: I noticed you called it "macosx_universal", I believe because Mac OS X always runs on one and the same architecture and not on 32bit or 64bit. I'd say just leave the "_universal" part.
The OS is running either in 32bits or 64bits (with Snow Leopard you can choose which one you want at boot time) but these binaries have both architectures (they are two files in one) in order to work on both architectures. So keeping the _universal postfix would prevent any confusion. However, if you think is too ugly I can remove it, of course.

Quote from: "pdinklag"
BTW, did you try auto-extraction again? It would be cool if that worked. I can explain how to test it properly if you haven't worked it out yet.
There is one problem left to solve really. On Mac OS X, any JSFML will have to be started using
Code: [Select]
-Djava.library.path=~/.jsfml/macosx -XstartOnFirstThread
However, this cannot be done from within Java because they are JVM flags.
Not yet, will test it tomorrow. I let you know if I need help with this. thanks.
SFML / OS X developer

pdinklag

  • Sr. Member
  • ****
  • Posts: 330
  • JSFML Developer
    • View Profile
    • JSFML Website
How to build JSFML
« Reply #16 on: February 02, 2012, 07:53:10 pm »
Just leave the _universal in there then. :)
I don't know about Mac OS X details.

I added you as a collaborator btw, so once we got that pull request sorted you can work on it directly.
JSFML - The Java binding to SFML.

Hiura

  • SFML Team
  • Hero Member
  • *****
  • Posts: 4321
    • View Profile
    • Email
How to build JSFML
« Reply #17 on: February 03, 2012, 03:04:29 pm »
Ok, I've made some progress! It works without -Djava.library.path (in fact, I didn't succeed to make it work with it but that's another story).  :)

I had to edit SFML binaries so they can be loaded from anywhere. That was no fun!

Anyway, there's only two thing I have to do before everything is clean.
Do you know how to add a post action in the ant script so I can run a shell command on the produced object (in this case, libjsfml.jnilib) ?

The second thing is about <signjar /> stuff. I couldn't make it work (if I give no password the compilation fails with "[signjar] jarsigner: you must enter key password"; and if I give a password it complains with "[signjar] jarsigner error: java.lang.RuntimeException: keystore load: /Users/marcoantognini/.keystore (No such file or directory)") so I commented it out.
How can I disable it only if no password was given by the user ?

I'm not familiar with this ant thing.
SFML / OS X developer

pdinklag

  • Sr. Member
  • ****
  • Posts: 330
  • JSFML Developer
    • View Profile
    • JSFML Website
How to build JSFML
« Reply #18 on: February 03, 2012, 03:25:56 pm »
Ant is just an awesome build tool in the Java world. :) I prefer it over Maven, which might be better for larger projects, I don't know.

Anyway, the build file is basically nothing but a makefile in a readable XML format. It consists of several targets which hold actions (called "tasks") that are processed sequentially (unless otherwise specified, but that doesn't matter now).

Quote from: "Hiura"
Do you know how to add a post action in the ant script so I can run a shell command on the produced object (in this case, libjsfml.jnilib) ?

You would do that using the "exec" task: http://ant.apache.org/manual/Tasks/exec.html
Code: [Select]

<exec executable="command">
  <arg value="argument1"/>
  <arg value="argument2"/>
  <arg value="argument3"/>
</exec>


Inside those arguments, you can best get the path to libjsfml.jnilib using:
Code: [Select]

${cpp.out}/${arch}/lib${jsfml.bin}.jnilib

That can simply be entered into an arg="" attribute.

Quote from: "Hiura"
The second thing is about <signjar /> stuff. I couldn't make it work (if I give no password the compilation fails with "[signjar] jarsigner: you must enter key password"; and if I give a password it complains with "[signjar] jarsigner error: java.lang.RuntimeException: keystore load: /Users/marcoantognini/.keystore (No such file or directory)") so I commented it out.
How can I disable it only if no password was given by the user ?

Ignore that stuff.

Signing a jar has nothing to do with Ant, but is a Java thing. For now, it's not relevant, but it will be once the features to run RenderWindows in browser applets are in it. If you run an applet, it will not work unless the jar is "signed". The signing happens against a certificate that the user needs to accept when loading the applet. To do that, you need a key store and a password.

You could create your own key store now and create such a certificate, but it doesn't really matter if it fails to sign. This only means that you cannot put it in a browser applet. :)

I will probably make the signing a separate target because it will be needed for actual releases and applet tests only.
JSFML - The Java binding to SFML.

Hiura

  • SFML Team
  • Hero Member
  • *****
  • Posts: 4321
    • View Profile
    • Email
How to build JSFML
« Reply #19 on: February 04, 2012, 10:43:16 am »
Wow, thanks for all the details! I'll finish the job during next week; probably offline so the shiny pull request will be ready one week later! ;-)
SFML / OS X developer

Jove

  • Full Member
  • ***
  • Posts: 114
    • View Profile
    • http://www.jestofevekites.com/
How to build JSFML
« Reply #20 on: February 24, 2012, 04:32:49 pm »
Hi.

I managed to build JSFML and when running the "Short Example" I receive this error. I'm a bit stuck now.

Code: [Select]
Exception in thread "main" java.lang.UnsatisfiedLinkError: Could not find native library in the classpath: windows_x64/libsndfile-1.dll
at org.jsfml.SFMLNativeObject.<clinit>(Unknown Source)
at ShortExample.main(ShortExample.java:15)


Any hints on what I might have done wrong?
{much better code}

pdinklag

  • Sr. Member
  • ****
  • Posts: 330
  • JSFML Developer
    • View Profile
    • JSFML Website
How to build JSFML
« Reply #21 on: February 26, 2012, 08:42:55 am »
That error message means that the dll is not available for JSFML to load.
You built SFML yourself, right? You need to make sure that the SFML dll files (and its dependencies, like libsndfile-1.dll, which is included in SFML) are in the classpath of your Java application.

In your case, since you are running on Windows 64-bit, your classpath must somewhere contain the directory windows_x64 with all the DLLs in it.

Anyway, to build JSFML, all this should not be necessary, neither is it recommended, because if you build a newer version of SFML and try to use it with JSFML, there might be incompatibilities. That's why the latest supported SFML dlls are pre-built by me and uploaded to the git repository.

All you should be needing to do to build JSFML is this (command-line using ant):
Code: [Select]

ant win64
ant jar
cd examples
ant jar


The first will build the C++ sources into a jsfml.dll file. The "JAR" targets will ask you for a password, simply enter anything you want. I will change the build targets soon so that is not necessary.

In the "out" directory of your JSFML clone, there should be a jsfml.jar (containing all the DLLs) which you can use for your project, and the examples jar file.
JSFML - The Java binding to SFML.

Jove

  • Full Member
  • ***
  • Posts: 114
    • View Profile
    • http://www.jestofevekites.com/
How to build JSFML
« Reply #22 on: February 26, 2012, 09:30:50 am »
Looks like I did everything correctly, except....

My out\bin\windows_x64 directory is completely empty, so I did the ant win64 step again and the build fails with :

Code: [Select]
D:\Program Files\Java\JSFML\build.xml:220: The directory D:\Program Files (x86)\Microsoft Visual Studio 10.0\VC\bin\amd64 does not exist

Sure enough it doesn't exist and most likely because I'm using VS2010 Express :(

I did however install the compilers when installing the Microsoft SDK, so they are present in a different location (C:\Program Files (x86) Microsoft Visual Studio 9.0\VC\bin\amd64). Is there any way to use them to build the 64 version?
{much better code}

pdinklag

  • Sr. Member
  • ****
  • Posts: 330
  • JSFML Developer
    • View Profile
    • JSFML Website
How to build JSFML
« Reply #23 on: February 26, 2012, 10:23:16 am »
Sounds more like MS Visual Studio 2008 Express?
Anyway, this is good to know. There is this file called "windows-find-vs.bat". I use this to find the MS Visual Studio installation from the registry, however, I only know the registry keys for MSVC++ 2010 Express. :)

If you change the batch to:
Code: [Select]

@echo off
echo "C:\Program Files (x86) Microsoft Visual Studio 9.0\"

Then it should work.

You can help me by checking your registry and see what there is under the key
Code: [Select]
HKEY_CURRENT_USER\Software\Microsoft\VCExpress\
Is there a node called "9.0_Config" with a value called "ShellFolder"? If so, I can extend that batch file to detect it automatically next time. :)
JSFML - The Java binding to SFML.

Jove

  • Full Member
  • ***
  • Posts: 114
    • View Profile
    • http://www.jestofevekites.com/
How to build JSFML
« Reply #24 on: February 26, 2012, 02:43:01 pm »
Things have improved!  Changes to the .bat worked and now I get no compile errors in Eclipse, so that's fixed (thanks!).

However, when I run the ShortExample the 800x600 window appears with only solid white visible, not responding at all.

There is a warning that "Build path specifies execution environment JavaSE-1.6. There are no JREs installed in the workspace that are strictly compatible with this environment."


To answer your registry question; I have only a '10.0_Config' node with no ShellFolder value.
{much better code}

pdinklag

  • Sr. Member
  • ****
  • Posts: 330
  • JSFML Developer
    • View Profile
    • JSFML Website
How to build JSFML
« Reply #25 on: February 27, 2012, 04:30:54 am »
That's probably because "cute_image.jpg" etc does not exist. ;)
It's only example code for the website at some point, it's not really supposed to work.

Try to run org.jsfml.examples.tutorials.BasicTutorial instead, that should give you a basic red screen.
JSFML - The Java binding to SFML.

Jove

  • Full Member
  • ***
  • Posts: 114
    • View Profile
    • http://www.jestofevekites.com/
How to build JSFML
« Reply #26 on: February 27, 2012, 10:40:28 pm »
"cute_image.jpg" did exist, along with all the other files required.  :wink:

However, the BasicTutorial did indeed run correctly with a juicy red screen and no other issues.

Looks ok so far.
{much better code}

pdinklag

  • Sr. Member
  • ****
  • Posts: 330
  • JSFML Developer
    • View Profile
    • JSFML Website
Re: How to build JSFML
« Reply #27 on: March 26, 2012, 05:48:25 pm »
Added Mac OS X build information from the readme file.
Thanks go to Hiura. :)
JSFML - The Java binding to SFML.

pengcheng

  • Newbie
  • *
  • Posts: 2
    • View Profile
Re: How to build JSFML
« Reply #28 on: August 24, 2012, 07:55:46 am »

Windows
To build on Windows (targets win32 and win64), you will require the Windows SDK (latest possible) as well as the Microsoft Visual C++ compiler. Note that the compiler can be installed along with the Windows SDK, so you don't necessarily need the Microsoft Visual Studio.

The path of the Windows SDK and the MS Visual C++ compiler is retrieved automatically using the provided batch scripts. Do not hesitate to report any problems with these scripts, but if you do let me know which Windows and WinSDK / MSVC++ you have installed.


Hello. I am running:
    Vista Home Basic;
    Windows SDK with VC++ compiler installed;
    No VC++ installed;
    Visual C# 2008 Expression installed;

Dir list:
C:\Program Files\Microsoft SDKs\Windows\v6.0
    Bin
    Include
    Lib
    VC
        Bin
        INCLUDE
        LIB
C:\Program Files\Microsoft Visual Studio 9.0
    Common7
    VC
    VC#

To build win32 successfully, I have to use:
   <target name="my_win32" description="Build the C++ sources for Windows 32 bit.">
      
      <property name="path.vs" value="C:/Program Files/Microsoft SDKs/Windows/v6.0" />
      <property name="path.winsdk" value="C:/Program Files/Microsoft SDKs/Windows/v6.0" />
      
      <property name="cl" value="C:/Program Files/Microsoft SDKs/Windows/v6.0/VC/Bin/cl.exe" />
      <property name="link" value="C:/Program Files/Microsoft SDKs/Windows/v6.0/VC/Bin/link.exe" />
      <property name="cwd" value="C:/Program Files/Microsoft Visual Studio 9.0/Common7/IDE" />
      
      <property name="vs.lib" value="C:/Program Files/Microsoft SDKs/Windows/v6.0/VC/lib" />
      <property name="winsdk.lib" value="C:/Program Files/Microsoft SDKs/Windows/v6.0/Lib" />
      
      <property name="arch" value="windows_x86" />
      
      <ant target="windows.build" />
   </target>


However, when running ShortExample:
Exception in thread "main" java.lang.UnsatisfiedLinkError: C:\Users\pengcheng\.jsfml\windows_x86\sfml-system-2.dll: Can't find dependent libraries
   at java.lang.ClassLoader$NativeLibrary.load(Native Method)
   at java.lang.ClassLoader.loadLibrary0(ClassLoader.java:1778)
   at java.lang.ClassLoader.loadLibrary(ClassLoader.java:1674)
   at java.lang.Runtime.load0(Runtime.java:770)
   at java.lang.System.load(System.java:1003)
   at org.jsfml.SFMLNative.loadNativeLibraries(Unknown Source)
   at org.jsfml.SFMLNativeObject.<clinit>(Unknown Source)
   at ShortExample.main(ShortExample.java:22)

Using MingW "objdump -x sfml-system-2.dll", this dll imports 3 dlls:
    KERNEL32.dll
    MSVCR100.dll
    MSVCP100.dll
The last 2 of which don't exist under "C:\Windows\System32", where there does exist "msvcp60.dll, msvcp71.dll, msvcr71.dll".

pdinklag

  • Sr. Member
  • ****
  • Posts: 330
  • JSFML Developer
    • View Profile
    • JSFML Website
Re: How to build JSFML
« Reply #29 on: August 24, 2012, 01:20:26 pm »
Quote from: pengcheng
Using MingW "objdump -x sfml-system-2.dll", this dll imports 3 dlls:
    KERNEL32.dll
    MSVCR100.dll
    MSVCP100.dll
This happens because I compiled and linked the SFML binaries using the MS Visual C++ compiler included in WinSDK 7 (Express 2010), you say that you have WinSDK 6 installed (which includes Express 2008).

I would recommend upgrading to WinSDK 7 (it supports Windows XP SP3, Vista and Windows 7) and build JSFML using the VC++ Express 2010 compiler.

Installing the Microsoft Visual C++ 2010 Redistributable Package might do the trick for you as well, but I'm not sure if it's a good idea to mix VC++ 2008 components (your jsfml.dll) with VC++ 2010 components (the SFML binaries).
JSFML - The Java binding to SFML.

 

anything