I am trying to setup Haxe with IntelliJ and my Linux box. I downloaded Linux 64bit binaries from haxe(haxe 3.1.3) site and community edition intellij. I installed Haxe plugin in intellij and then created a new Haxe Module. For sdk I picked the haxe folder I donwloaded from haxe site. I created a new configuration to compile and run but It gives me an error that It can't locate standard library. Why is that happenning?
Haxe Directory Tree
haxe-3.1.3
├── extra
└── std
├── cpp
├── cs
├── flash
├── flash8
├── haxe
├── java
├── js
├── neko
├── php
├── sys
└── tools
haxe-3.1.3 was the directory I chose for haxe toolbox in intellij. Creating a new Haxe project lets me choose Haxe 3.1.3 (meaning that toolkit is set up correctly since its recognized). External Libraries in intellij project includes Haxe dir with std (when expanding the folder to see what it contains).
In "Project structure" dialog in the SDK i see that libraries are setup correctly (haxe-3.1.3/std) and the haxe executable also(haxe-3.1.3/haxelib). Classpath contains the Library directory
When I compile it using openFl and with flash as target I get the following error
Error:compilation failed
/home/avlahop/development/Haxe/haxe-3.1.3/haxelib
Error:libneko.so: cannot open shared object file: No such file or directory
When I switch to Haxe compiler and Neko or Javascript I get the following
Information:Compilation completed with 1 error and 1 warning in 0 sec
Information:1 error
Information:1 warning
Error:compilation failed
Warning:Standard library not found
My Class
package ;
class Test3 {
public function new() {
}
public static function main(): Void{
trace("Hello from haxe and IntelliJ IDEA");
}
}
I really want to get in to it but cannot start...
Manually go into /usr/lib and look for libneko.so. Sometimes installs might throw a one at the end or something aka libneko.so.1.
Rename the file correctly. You may have to use a newer version of neko, I had to compile from the git to get it to work: https://github.com/HaxeFoundation/neko
If you don't notice anything off, make sure your environment variables are correct. Open up /etc/environment in the text editor of your choosing
export HAXE_STD_PATH=/usr/local/haxe/std:. # path to std + :.
export HAXE_HOME=/usr/whatever/haxe # path to haxe
export NEKOPATH=/usr/local/neko # path to neko
Note that if you used HAXE_LIBRARY_PATH, that's been changed to HAXE_STD_PATH in later versions of Haxe. You also need the reference to this file, open your /etc/profile with sudo and check for:
. /etc/environment
That's all I got. Hope it works out for you.
Based on #johnink anwser, this work for me in linux commandline mode :
I downloaded linux binaries from https://haxe.org/download/ and uncompress in some path like
/some/folder/haxe-tool
I added this lines to my ~/bashrc
export HAXE_STD_PATH="/some/folder/haxe-tool/std"
export HAXE_HOME="/some/folder/haxe-tool"
export PATH=$PATH":"$HAXE_HOME
And tested with this cmd:
haxe -main HelloWorld --interp
Also I converted to javascript with this cmd
haxe -js HelloWorld.js -main HelloWorld
Using this file :
class Main {
static public function main():Void {
trace("Hello World");
}
}
Following the "Hello World" example :
https://code.haxe.org/category/beginner/hello-world.html
Related
I want to run Vulkan on my android phone, and currently, I'm stuck at the point trying to make CMake find the libshaderc.
What I did is first build the shaderc:
cd <my-ndk-root>/sources/third_party/shaderc
../../../ndk-build NDK_PROJECT_PATH=. APP_BUILD_SCRIPT=Android.mk APP_STL:=c++_static APP_ABI=all NDK_TOOLCHAIN_VERSION:=clang libshaderc_combined -j16
And inside my CMakeLists.txt, I have:
get_filename_component(SHADERC_SRC
${ANDROID_NDK}/sources/third_party/shaderc
ABSOLUTE)
add_library(shaderc_lib STATIC IMPORTED)
set_target_properties(shaderc_lib PROPERTIES IMPORTED_LOCATION
${SHADERC_SRC}/libs/${ANDROID_STL}/${ANDROID_ABI}/libshaderc.a)
But the CMake can't find the shaderc_lib, and failed with error:
CMake Error: The following variables are used in this project, but they are set to NOTFOUND.
Please set them or make sure they are set and tested correctly in the CMake files:
shaderc_lib
Please note that I already checked that I have libshaderc.a under the [my-ndk-root]/sources/third_party/shaderc/libs:
.
└── c++_static
├── arm64-v8a
│ └── libshaderc.a
├── armeabi-v7a
│ └── libshaderc.a
├── x86
│ └── libshaderc.a
└── x86_64
└── libshaderc.a
5 directories, 4 files
I'm not very familiar with CMake and NDK, so if I made some stupid mistakes, please correct me. Thanks in advance!
Make sure your CMake path points to the correct place. Also, your libshaderc.a is static library and you need to link it to your shared lib, e.g. libshaderc-shared.so using below CMake configuration:
target_link_libraries( libshaderc-shared
[my-ndk-root]/sources/third_party/shaderc/libs/c++_static/${ANDROID_ABI}/libshaderc.a )
References:
Here is the guide for how to properly build shaderc https://github.com/google/shaderc.
https://developer.android.com/ndk/guides/graphics/shader-compilers
I am busy learning Vulkan as well, and the only help I can currently provide is the vulkan samples. They work on an android device which supports vulkan. I am using a nokia scirocco 8 as my test device. Have a look at the CMakeLists.txt in the samples as to how to link the shaderc static library. https://github.com/googlesamples/vulkan-basic-samples/
My build.hxml file looks like this:
-main Main
-cp src
-js bin/index.js
I use js.Browser in Main class. When I try to build it with F8, FlashDevelop gives me "You cannot access the js package while targeting cross". And I actually see that it tries to run:
Running process: bla-bla-bla -target "js"
...
cmd: cmd /c haxe build.hxml
haxe -cp src -main Main
So it removes -js parameter from hxml and then fails the build. How to fix it?
In the project properties, choose "Custom Build" as compilation target.
The reason is that the hxml target uses a custom build command (Build tab) and when the Application compilation target is selected, FD will try to compile it a second time with an incorrect configuration. This is legitimately a bug in FD - raise an issue on Github?
So I am trying to build and test out a CMake with the Android NDK on Android Studio. I can get my library to compile, but it doesn't seem to want to pull any third-party dependencies over. I've been reading through the toolchain and looking for better documentations, with no luck. Can someone tell me if I am missing?
cmake_minimum_required(VERSION 3.4.1)
set(SFML_PATH ${ANDROID_NDK}/sources/sfml)
set(SFML_LIB_PATH ${SFML_PATH}/lib/${ANDROID_NDK_ABI_NAME})
set(SFML_LIB_SYSTEM ${SFML_LIB_PATH}/libsfml-system.so)
set(SFML_LIB_AUDIO ${SFML_LIB_PATH}/libsfml-audio.so)
set(SFML_LIB_GRAPHICS ${SFML_LIB_PATH}/libsfml-graphics.so)
set(SFML_LIB_NETWORK ${SFML_LIB_PATH}/libsfml-network.so)
set(SFML_LIB_WINDOW ${SFML_LIB_PATH}/libsfml-window.so)
set(SFML_LIB_ACTIVITY ${SFML_LIB_PATH}/libsfml-activity.so)
set(SFML_LIB_MAIN ${SFML_LIB_PATH}/libsfml-main.a)
set(SFML_LIBS ${SFML_LIB_SYSTEM} ${SFML_LIB_GRAPHICS} ${SFML_LIB_AUDIO} ${SFML_LIB_WINDOW} ${SFML_LIB_ACTIVITY})
include_directories(${SFML_PATH}/include)
link_directories(${SFML_LIB_PATH})
add_library(native-lib SHARED
src/main/cpp/native-lib.cpp)
target_link_libraries(native-lib log ${SFML_LIBS})
#file(COPY ${SFML_LIBS} DESTINATION ${__android_install_path})
FOREACH(SFML_LIB ${SFML_LIB})
execute_process( COMMAND "${CMAKE_COMMAND}" -E copy_if_different "${SFML_LIB}" "${LIBRARY_OUTPUT_PATH}/${SFML_LIB}" RESULT_VARIABLE __fileCopyProcess )
MESSAGE("Lib: ${SFML_LIB}")
ENDFOREACH(SFML_LIB)
Above is my CMakeLists.txt. I have done a little hacking to get it to compile with SFML with the paths, as I have not found good documentation with CMake and Android yet.
May you add more info for:
"but it doesn't seem to want to pull any third-party dependencies over."?
this one:
https://github.com/googlesamples/android-ndk/tree/master/hello-libs
has static and shared 3rd party libs, you may try it.
For the shared dependent lib, you will need to pack them into APK, that is done inside gradle, cmake will not do it.
The above example shows that, basically they need to be copied into your app/src/main/jniLibs too so they will be packed into apk, and pushed to your android phone/tablet. At runtime they could be loaded.
I have tried to put a group of libraries into one directory, and use
link_directories(...)
then just put the lib names directly into
target_link_libraries(...)
also works. Make sure you have the right libs for the ABIs you intend to support for your app [looks like you are just building for one ABI].
The process could be little long it will depend on your android skills.
An example could be similar to this process:
Crosscompile sfml.
Create your jni bridge
Generate with cmake the project and compile
Copy your files to android studio. create java loading library code.
I guess that you have crosscompiled sfml and you know how works crosscompiling process, if I am wrong check these link below:
Tutorial:
https://github.com/SFML/SFML/wiki/Tutorial:-Building-SFML-for-Android
Source code:
https://github.com/SFML/SFML
Toolchain:
https://github.com/SFML/SFML/blob/master/cmake/toolchains/android.toolchain.cmake
Changes on your cmake:
add this file
FIND_PACKAGE(SFML required)
In cmake put your SFML build directory and cmake will fills your VARIABLES
automatically for instance this variables:
set(SFML_PATH ${ANDROID_NDK}/sources/sfml)
set(SFML_LIB_PATH ${SFML_PATH}/lib/${ANDROID_NDK_ABI_NAME})
set(SFML_LIB_SYSTEM ${SFML_LIB_PATH}/libsfml-system.so)
set(SFML_LIB_AUDIO ${SFML_LIB_PATH}/libsfml-audio.so)
set(SFML_LIB_GRAPHICS ${SFML_LIB_PATH}/libsfml-graphics.so)
set(SFML_LIB_NETWORK ${SFML_LIB_PATH}/libsfml-network.so)
set(SFML_LIB_WINDOW ${SFML_LIB_PATH}/libsfml-window.so)
set(SFML_LIB_ACTIVITY ${SFML_LIB_PATH}/libsfml-activity.so)
set(SFML_LIB_MAIN ${SFML_LIB_PATH}/libsfml-main.a)
There are two ways to make android studio native apps:
Easy way:
Create JNI bridge:
Crosscompile your cmake script and copy your lib to app/src/main/jniLibs
add library in execution time
code:
try
{
Log.v(LOG_TAG, "adding your library");
System.loadLibrary(your_library);
}
catch(UnsatisfiedLinkError e)
{
Log.e(LOG_TAG,e.getMessage());
}
More complete way (it allows to debug library)
Create your ndk module in gradle
example
android.ndk {
moduleName = "your_library"
cppFlags.add("-fexceptions")
//cppFlags.add("-std=c++11")
//cFlags.add("-fopenmp")
cppFlags.add("-I" + file("src/main/jni").absolutePath)
stl = "gnustl_shared" // Which STL library to use: gnustl or stlport
ldLibs.addAll(["android", "EGL", "GLESv2", "dl", "log", "z"])
String libsDir = curDir.absolutePath + "/src/main/jniLibs/armeabi/"
ldLibs.add(libsDir + "your_native_lib.so")
}
~/groovy
% tree
.
├── lib
│ ├── GTemplate.class
│ └── GTemplate.groovy
└── Simple.groovy
class GTemplate {
static def toHtml() {
this.newInstance().toHtml1()
}
def toHtml1() {
"test"
}
}
import lib.*
class Simple extends GTemplate {
}
Error:
% groovyc Simple.groovy
org.codehaus.groovy.control.MultipleCompilationErrorsException:
startup failed: Compilation incomplete: expected to find the class
lib.GTemplate in /home/bhaarat/groovy/lib/GTemplate.groovy, but the
file contains the classes: GTemplate 1 error
It looks like you are confusing Groovy with PHP-like techniques.
Because it's closer to Java, if a class exists within a subfolder, it needs to exist within a package of the same name. In your example, you could add this line to the top of GTemplate.groovy and recompile the file:
package lib
However, this means that the fully-qualified name for GTemplate is now actually lib.GTemplate. This may not be what you want.
Alternatively, if you want to use the files from a subfolder without using packages, you could remove the import statement from Simple.groovy, and instead compile and run the class like so:
groovyc -classpath $CLASSPATH:./lib/ Simple.groovy
groovy -classpath $CLASSPATH:./lib/ Simple
NOTE: If you don't have a CLASSPATH already set, you can simply use:
groovyc -classpath ./lib/ Simple.groovy
groovy -classpath ./lib/ Simple
Also, for windows machines, change $CLASSPATH: to %CLASSPATH%;
I strongly recommend learning about packages and understanding how they work. Look at this Wikipedia article on Java packages for a starting point.
Using bjam on ubuntu, I am building a c++ shared library and trying to use it in an executable. I have to build as shared since it wont link as static (lots of undefined references arise). Thats fine.
Two related problems:
1) Using a heirarchy of Jamfiles, my exe project (testServerHub) has a dependency on the shared library (pythonManager). Here's the Jamfile for the exe:
echo "Compiling serverHub//test" ;
# declare project name
project serverHub//testServerHub
: build-dir ../_gcc/intermediate
;
# build unit-test using these source files, dependent libraries and settings
exe testServerHub
: # Source
..\\..\\..\\common\\0_8_1\\test\\runner.cpp
successfulTest.cpp
# Dependent libraries by path and project name
../controller/pythonManager//pythonManager
/boost//unit_test_framework
: # Settings
<link>shared
;
install ..\\bin : testServerHub ;
And here's my lib Jamfile:
echo "Compiling serverHub/controller//pythonManager" ;
# declare project name
project serverHub/controller//pythonManager
: requirements
<define>URTH_SERVERHUB
: build-dir ../../_gcc/intermediate
;
# build library using these source files and settings
lib pythonManager
: ../../../../common/0_8_1/controller/pythonManager/pythonManager.cpp
../../../../common/0_8_1/controller/pythonManager/cppInterfaceBase.cpp
cppInterfaceServerHub.cpp
/boost/python//boost_python
/user-config//python
: <link>shared
;
# copy and rename
install ../../lib : pythonManager ;
If I run 'bjam pythonManager' the pythonManager shared library is built and copied to my project lib folder (by the final install command). However if I run 'bjam test', both testServerHub and pythonManager are built, but the libpythonManager.so is not copied to the project lib folder - the install command doens't run!
2) Okay, so as a temporary workaround, I build libpythonManager.so first and then build testServerHub executable. Both compile and link. At runtime, the executable complains about not being able to find libpythonManager.so. Not a great surprise since the runtime linker doesn't know about my project lib folder. How do I tell it to look in a certain directory for shared libraries? or how do I install libpythonManager.so into /usr/local/lib if the install command has no effect on dependent library builds?
Thank you very much
Si
I think that you could use <install-dependencies>on in the exe Jamfile, like in
install ..\\bin : testServerHub : <install-dependencies>on <install-type>LIB ;
This will install all the libraries (LIB) on which the exe depends.
See eg http://www.boost.org/doc/tools/build/doc/html/bbv2/tasks/installing.html as a reference.