New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Pointer types don't work on the native side if allocated in java #747
Comments
It sounds like you're not using the same compiler for Mvntest and JavaCPP. We need to use the same C++ compiler for everything |
Yup. That did the trick. |
So that did the trick but now I have another problem. At the moment instead of compiling the generated cpp files and my other cpp files separately I add them to the project solution and bundle them in the same dll ( in the example that would be Mvntest), but when Loader.load() is called in the static block of the generated java classes they try to load "jni" + c.getSimpleName() , where c is the class in the global package (in this case NativeLibrary, so it tries to load jniNativeLibrary ) but that library just doesn't exist because everything is packaged into Mvntest. I tried setting the library() in the Platform annotation on the Mapper, but that doesn't get inherited in the parsed classes (Foo and StringVector) so it just tries to load jniNativeLibrary again. Is there a way to do this or does my dll have to be called jniNativeLibrary.dll?
The problem here is that the LoadLibrary method doesn't take a const char* , but a LPCWSTR instead. The method that takes |
Sure, that's what You could add a |
I already have the |
Well, I guess we can consider those as bugs that need to be fixed then |
I mean I see where the problem is, but I'm not entirely sure if it's exactly a problem or intended behavior. My question is: are classes that have a |
I've pushed potential fixes to commit e824acf but I haven't tested them. Could you test them for me? |
The LoadLibraryA fix works, but the inheritance of the library() doesn't. I have presumably fixed it, but to be honest I haven't ever made a commit to a github repository so I'll have to look into that before I can commit the changes for review :D |
Here what fixed it for me 896f288 here the code searches through all enclosing classes, starting with the ones that are in the |
The original code already searches through all enclosing classes. It should be possible to fix this by changing only a line or two somewhere. |
It does? That would be great, but I couldn't find it. I saw the |
Well, anyway, please provide a complete but small example that fails, and I'll see what we can do about it |
Okay, here is an example: test_header.hpp
test_source.cpp
Mapper:
Main:
Now you just have to parse the test_header.hpp file, compile the parsed .java files into .class files , link the test_source.cpp any way you wish, generate and compile the cpp files, run the program and you have yourself a crash.
And although I haven't noticed that before, the fix for the library property inheritance also fixed the generated cpp file being called |
With my fixes from commit e824acf, it both generates a GeneratedLibrary library just fine, and loads it just fine. I can't fix what isn't broken! Please provide me with an example that doesn't work. |
Okay, I was wrong, the fix does work. I am not entirely sure what I did last 2 times I ran it for it to go awry, but when I just reset everything to how it was before and recompiled it with the simple fix, it worked just fine. Sorry for the trouble and thanks for the fix! |
I have a problem where if I allocate something on the java side and pass it to a function on the native side it seems like natively all the properties of that object retain their default value. In other words int , double , long =0 even if they aren't and so on. This happened most recently when I tried to make an std::vectorstd::string and pass it to a c++ function. Here's a short example:
The cpp gets compiled into a dll, called Mvntest.dll and gets linked against in the mapper. I parse the files, compile them and run the example and it prints out 0. Also If I try to add any strings to this vector via push_back and print them out on the native side I get an ACCESS_VIOLATION
The text was updated successfully, but these errors were encountered: