I was trying to make libimagequant library work in java but I can't make the "dll" and can't make the "jnilib", I don't know why but it just doesn't work, if somebody could help it would be awesome.
I have already tried to make the "Makefile" but it gives me errors on errors, maybe someone already compiled a dll, I still don't understand why they don't pre build all the source.
EDIT NUM 1:
I would like to make the libimagequant library work in my java program,
I downloaded the library https://github.com/ImageOptim/libimagequant
when i tried to run make Makefile java it gave me a message that touch is not recognized, as touch is not important i removed the command from Makefile, then i run it again and now it is giving me this error:
process_begin: CreateProcess(NULL, env bash C:\Users\Me\Desktop\libimag
equant\configure, ...) failed.
make (e=2): The system cannot find the file specified.
make: Nothing to be done for `Makefile'.
javah -o org/pngquant/LiqObject.h org.pngquant.LiqObject
javac org/pngquant/PngQuant.java
javah -o org/pngquant/PngQuant.h org.pngquant.PngQuant
javah -o org/pngquant/Image.h org.pngquant.Image
javah -o org/pngquant/Result.h org.pngquant.Result
make: *** No rule to make target `config.mk', needed by `pam.o'. Stop.
Related
I am learning Opencv for android and according to a tutorial I was watching I had to set up JNI.
I have already configured java and ndk to be accesible from the command line (windows) from everywhere.
I have to execute this command in the terminal of android studio:
javah -d jni -classpath ../../build/intermediates/classes/debug bruno.volcovinsky.aprendiendoopencv.NativeClass
I know that javah is not more useful, so I use instead javac. It gives the same error. I Also tried using javac -h (that I saw in some websited)
The video where I saw this is the following: https://youtu.be/mF9fYdXfSD8?t=4m28s
Does anybody know what am I doing wrong?
So this is a little bit messy, however I have a single .cpp file that I want to be used in two different ways; as a c class called by a java class using JNI, and as a c program standalone. The reason for this is because this code moves around between machines and sometimes I want to just run and compile the c++ code directly as opposed to running java and having java run it. (The c++ code has a main method that is only ever ran in the standalone version).
So anyways I have the file (test.cpp) and the java source code that goes with it (test.java) in /home/user/dev/javajni/. However, I also want to be able to compile it as a standalone in /home/user/dev/standalone/. In the standalone directory I have a make file that only compiles the c program.
Anyways, when I make a hardlink to the file in javajni inside the standalone directory the makefile doesn't see it, or refuses to see the hardlink.
make: *** No rule to make target `test.cpp', needed by `test'. Stop.
And while in the standalone directory I use:
ln /home/user/dev/javajni/test.cpp test.cpp
But when I copy the entire file over it works fine.
What's the big deal? Isn't the original file in the original location technically just a hardlink to the inode as well? I just want to be able to alter the file in one location without having to copy and paste it back and forth.
If at all useful this is what my makefile looks like:
EX=test
all: $(EX)
.cpp.o:
g++ -c -O3 -Wall $<
clean:
rm -f $(EX) *.o *.a
test:test.cpp; g++ -Wall -o $# $^
(Fyi I did change the name of the file and the directories in this post for simplification)
From the command line, I can do this and get expected output
c:\Users\SomeUser\SomePath\sandbox> javac Sandbox.java
If I use the SConstruct in conjunction with scons, in the same location, I get
c:\Users\SomeUser\SomePath\sandbox> scons
scons: done reading SConscript files.
scons: Building targets ...
javac -d classes -sourcepath . Sandbox.java
'javac' is not recognized as an internal or external command,
operable program or batch file.
scons: *** [classes\Sandbox.class] Error 1
scons: building terminated because of errors.
This looks like the answer to #1 of our "most frequently asked" FAQs at http://scons.org/faq.html could help you out. By default, SCons doesn't import the variables like $PATH from the surrounding shell environment. You have to pull in your $PATH for properly detecting the javac executable explicitly...check the mentioned FAQ entry for a more detailed discussion about why things are as they are, and how to provide the required $PATH definitions to your build environments.
I'm trying to learn JNI but everytime I try to run the java program, it throws an exception stating that it couldn't find the *.so library in the lib path with I declared when launching - this should happen. I was under the impression that it shouldn't but then I realized that I never made a so file and in-fact I was trying load an executable (Ubuntu doesn't make clear file extensions).
Anyways, how can I compile my cpp files into .so files using code blocks. I've been looking all over and all I've found is complicated gcc commands that I don't quite understand.
Any insight on how to create shared object libs from code blocks would be a great help.
You can create the object (.o) files of your classes and then use the -shared tag to combine them into a dynamically linked library.
In my experience, Code blocks does not provide the users with the ability to do so. You will have to make use of gcc.
I solved it under Linux fedorra with a shell script compile_shared.sh
#!/bin/bash
g++ -I ./include/ -c -fPIC src/MyClass.cpp -o so/MyClass.o
g++ -shared -Wl,-soname,lib_MyClass.so -o so/lib_MyClass.so so/MyClass.o
in the root folder and adjusting the build options in Codeblocks, such that the script is executed after the built.
Codeblocks
Project -> Build options ...
Select cpp in tree view on the left
Pre/post build steps
add "xterm -T bash ./compile_shared.sh" in the Post-build steps textfield
This compiles the File ./src/MyClass.cpp to ./so/MyClass.o and in a next step to ./so/lib_MyClass.so.
I currently have a makefile as such:
SOURCES = \
src/package1/*.java \
src/package2/*.java\
src/package3/*.java\
src/package4/*.java \
src/package5/*.java \
src/package6r/*.java \
src/package7/*.java \
src/package8/*.java \
src/package9/*.java
Later on in the make file i have:
new:
make clean
make caller
caller: $(SOURCES) src/package1/file1.java src/package2/file3.java
javac src/package1/main.java
At first I kept getting an error regarding rules for each of the files that needed to be built. It was of the form:
"‘No rule to make target `xxx', needed by `yyy'.’"
I found it's description here: http://www.gnu.org/software/make/manual/html_node/Error-Messages.html and how to solve it here: http://www.chemie.fu-berlin.de/chemnet/use/info/make/make_4.html#SEC26
Now, all the .class files are appropriately being created in the bin/package{1,2,3,4,5,6,7,8,9}/file{1,2,3,4,5,6}.class location; however, when the below command runs:
javac src/package1/main.java
It gives a plethora of errors stating:
error: cannot find symbol
I've tried changing the javac command to the following with the -cp flag:
javac -cp src/package1/*;src/package2/*...
But it doesn't seem to be grabbing all the dependencies, and the command is just too long. I've been trying a lot of work arounds, but I'm not sure how to best do this with a makefile and the javac command?
I already have a ant build which works, but I specifically need this make file to work as well,
Thank you for your time!
Best Regards,