Open FelipeRamones opened 2 years ago
As far as I know, a Godot binary compiled with MinGW (like the official builds) cannot use GDNative add-ons compiled with MSVC. This is especially the case for GDNative add-ons written in C++ that link to the standard library, as the MSVC and GNU ABIs are incompatible with each other.
As far as I know, a Godot binary compiled with MinGW (like the official builds) cannot use GDNative add-ons compiled with MSVC.
GDNative / GDExtension API is pure C, so it should work fine across MinGW/MSVC, as long as you are not passing file/socket descriptors between different libs. But a different runtime used by libpqxx
and add-on might cause issues.
As long as libpq
and all of its dependencies are in the same folder as GDNative lib, it will load fine:
It worked indeed, thanks @bruvzg and @Calinou for your answers ^^ tried adding libpq.dll before but never it's dependencies too, appreciate it ^^
Godot version
3.4.4.stable
System information
Windows 10 Pro x64, Intel I7-9750H x64, 16GB RAM, NVIDIA GeForce GTX 1650, Driver Version 30.0.15.1179, Backend GLES3
Issue description
I'm trying to link PostgreSQL to Godot thru GDNative using libpqxx, after i link all the necessary files and the windows socket in the scons file it generates a .dll file, but every time i try to instantiate the GDNative class it crashes and throws the error "Attempting to call function 'new' in base 'NativeScript' on a null instance".
I also get this message in the cmd:
Steps to reproduce
I'm using this GDNative example project and the regular godot cpp repo, cloned the godot-cpp repo using --recursive -b 3.x thru git bash and built it with:
scons generate_bindings=yes platform=windows target=release bits=64
After that i draged it into the GDNative example directory ending up with something like this:
Then i've downloaded and installed PostgreSQL Version 12.11 for Windows x86_64
After that i cloned the libpqxx repo inside of my GDNative directory, ending up with something like this:
Then i've built it following this tutorial 'till the minute 10:20, the only difference being that in the Visual Studio 2019 interface i got the C++ version to standard C++17 and not latest in both the files he built.
After that i've linked the necessary paths to the SConstruct file. Here's the code:
After that i've added
/std:c++17
as a CCFLAG as in the following code:So then i changed the .cpp and .h files with the necessary code, they ended up like this:
.CPP FILE:
.H FILE:
GDLIBRARY.CPP FILE:
The src directory content is like this:
After All that was built using:
scons platform=windows target=release bits=64
Every scons line was typed on
x64 Native Tools Command Prompt for VS2019
running as administratorAfter that all dlls were linked in Godot so i clicked the gdexample.gdns file and in the editor inside Godot i typed on Script Class property Name "GDExample" and changed the Main.gd script to:
the bug happened as soon as i opened the Godot project with the library files but then after i tried to run it crashed and reinforced the error.
Minimal reproduction project
Couldn't upload the file (maybe it's too big) [73.1MB]
Here's a link:
https://ufile.io/ebcz844v