-
-
Notifications
You must be signed in to change notification settings - Fork 18.7k
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
Usage of included functions resulting in .dll
not being found
#38961
Comments
Some more information as I had 2 teammates reproduce the error, one is on MacOS, the other is on Windows. The person on MacOS is not able to reproduce the error, they follow the same steps I did and it's successfully working for them. They've also cloned the project that I was working on and that is also still working for them. The other person on Windows does run into the same error that I do. So I'm starting to think it might have to with either the environment or build tools. So some information regarding this environment;
|
By now I've attempted to do this with CMake, but that unfortunately results in the exact same issue as described above. The Steps to reproduce
CMakeLists.txt: cmake_minimum_required(VERSION 3.1...3.15)
if(${CMAKE_VERSION} VERSION_LESS 3.12)
cmake_policy(VERSION ${CMAKE_MAJOR_VERSION}.${CMAKE_MINOR_VERSION})
endif()
# set the project name
project(TouchThaBomb VERSION 0.1
DESCRIPTION "Defuse bomb game with hand tracking"
LANGUAGES CXX)
# https://cmake.org/cmake/help/latest/command/find_package.html#search-procedure
find_package(OpenCV 4.3 EXACT REQUIRED PATHS /OpenCV/opencv-4.3.0-vc16/)
include_directories(AFTER "${OpenCV_INCLUDE_DIRS}" "include")
link_libraries(${OpenCV_LIBS})
link_libraries("../godot-cpp/bin/libgodot-cpp.windows.debug.64")
# create the .dll
#file(GLOB source_list "src/*.h" "src/*.cpp")
add_library(libgdexample SHARED "../src/gdexample.cpp" "../src/gdlibrary.cpp")
include_directories(
"../godot-cpp/godot_headers/"
"../godot-cpp/include/"
"../godot-cpp/include/core/"
"../godot-cpp/include/gen/"
"../godot-cpp/bin/"
)
Remains the exact same, the error is as follows:
|
For some reason it can't open the DLL that is created:
Assuming it has compiled the DLL and it is placed in that folder, it could be that it can't load OpenCV itself as a dependency. You need to make sure the opencv dll(s) are also placed in the bin/win64 folder and that you name those dlls in your gdnlib file in the dependencies section |
Hey, thanks for responding. We're actually not including any opencv dll(s), we're including For ease, I've uploaded the project that I'm using to reproduce this. https://github.com/S3B4S/opencv-gdnative/tree/gdnative. In the repository I've added a example-opencv-dependency.txt file that shows the structure of the opencv (4.3.0) dependency so you can see what I'm talking about. |
Though, by now I'm running in a new error that might provide more information. If I try to include an additional line in
So usually this means that it cannot find certain header files and/or libraries from my understanding, but I cannot find what I'm missing here. I think I've set it up fine in the SConstruct. I've also set up a seperate project with only opencv, using Visual Studio and when I set these same locations it worked fine when building with Visual Studio. (For more information on how I did this project, I followed the steps described here). So I don't feel like there's something wrong with the locations themselves, however I might miss something else that's needed for building a |
That all depends on whether you've compiled OpenCV as a static library or not. If it is compiled as a static library the .lib file contains all. If you've compiled it as a dynamic library the .lib file only contains the glue that allows you to use the OpenCV dll and the dll needs to be included. The new error you're getting means that you are calling the circle function in the OpenCV library but that it doesn't know this function. That suggest the library file isn't being included correctly. Makes no sense though, from what I understand circle is a core function of OpenCV and you are including the core library.. Unless there is some other reason it skips that code in the SConstruct file.. |
Okay that was insightful, since the libraries I'm using are pre-built ones downloaded from here, so I went and checked if they were dynamic or static by running So running
gave me the output of
... 814 times 😆. I think it seems fair to conclude then that this means these The circle not being found is indeed very strange, I will keep digging around about that, in any case I wanted to report above findings. |
Regarding the "circle function not being found", when I build with CMake this issue does not appear. I'm succesfully able to build the same source files. So with this out of the way, I tried to see if adding the
But unfortunately, the error still remains 🤔 |
Oh, I hadn't realised there was an issue opened for this here too. FYI, I replied to your other issue in case it's still useful: godotengine/godot-cpp#403 (comment) I've also subsequently discovered that GDNative does its own (redundant?) dynamic library path manipulation before calling the I've also discovered what appears to be an edge case problem that occurs if you try to run an exported godot/platform/windows/os_windows.cpp Lines 2250 to 2253 in b0eca58
AFAICT the I think if the path is converted to an absolute path first then both entities would see things the same way--but that may have its own issues. Anyway, I only mention that here because it was a bizarre scenario where I knew I'd had a particular executable run & find its DLL dependencies previously but now it couldn't--and it turned out to be related to now being in the project directory on the command line. Given all this, I'd recommend you use a file access logging tool to find out what paths are actually being accessed. Since I was doing this investigation on a Mac with WINE (it's a long story... :D ) I was able to use |
TLDR: Same issue here on Godot 3.3.4 when trying to call a method of DiscordGameSDK from a C++ gdnative project. It works fine if I define any variable which is of a type from the DiscordGameSDK but as soon as I try to call any method from it I get the same error "cant open dynamic library..." in the Godot editor. Godot version: 3.3.4 What I have so far
I get the error "Cant open dynamic library" in the Godot editor only when the c++ project trys to call any method from discord_Game_sdk. |
Godot version: 3.2.1
OS/device including version: Windows 10, build 1903
The issue
Hey, I hope I'm in the right place with this, I've followed the example in the docs for c++: https://docs.godotengine.org/en/stable/tutorials/plugins/gdnative/gdnative-cpp-example.html. This went all right, my next step was to include opencv, so I appended additonal locations to
CPPPath
,LIBPATH
andLIBS
in SConstruct: https://github.com/S3B4S/opencv-gdnative/blob/gdnative/SConstruct#L165-L184When my code only includes the opencv libraries, it will compile and run fine in Godot (below example would have modified
src/gdexample.cpp
in the example repository);But when I do want to use a method from the imported code (so it's the exact same code snippet as above, but the
Mat image = Mat::zeros(300, 600, CV_8UC3);
line is uncommented), I run into the following error:I'm honestly confused by the fact that it's saying it cannot find
libgdexample.dll
anymore, it's definitely there. When the lines that includeOpenCV
are commented out it does find the.dll
file.I'm new to this kind of stuff, so I'm not sure if I've overlooked something or that this is unexpected behaviour.
Additional information in case it's needed
I've pushed the project I'm working on to here.
Steps to reproduce:
Assuming that OpenCV is installed &
OPENCV_DIR
environment variable is set.scons platform=windows
, this should output alibgdexample.dll
among other files in<Godotproject>/bin/win64
The text was updated successfully, but these errors were encountered: