0 votes

First, the project am in is in the final stage of development and we cannot move to vs2019 until is released.

My problem: Am trying to create .dll files in Visual Studio 2017 for a GDNative module, that connects to different stores.

I've compiled the godot-cpp with the x64 native tools command prompt VS 2017, by running "scons p=windows generate_bindings=yes" targeting debug and release, creating a .lib file for each, I've done all the configurations in vs2017 following this tutorial:
https://www.youtube.com/watch?v=Ye23Fj94QzQ

And the test works, until I set my "hello world" code. Rebuiling the project (Debug/Release, x64) gives me multiple errors:
LNK2001 unresolved external symbol _CxxFrameHandler4 [My project name] libgodot-cpp.windows.debug.64.lib(Thread.obj)
LNK2001 unresolved external symbol _CxxFrameHandler4 [My project name] libgodot-cpp.windows.debug.64.lib(Dictionary.obj)
LNK2001 unresolved external symbol _CxxFrameHandler4 [My project name] libgodot-cpp.windows.debug.64.lib(Engine.obj)
and so on, all errors pointing to .obj.

This doesn't happen in vs2019, just for trying to discard that the .lib aren't corrects.

What am I missing in vs2017?

Library.cpp:

#include "Hello.h"

using namespace godot;

extern "C" void GDN_EXPORT godot_gdnative_init(godot_gdnative_init_options * o) {
    Godot::gdnative_init(o);
}

extern "C" void GDN_EXPORT godot_gdnative_terminate(godot_gdnative_terminate_options * o) {
    Godot::gdnative_terminate(o);
}

extern "C" void GDN_EXPORT godot_nativescript_init(void* handle) {
    Godot::nativescript_init(handle);
    register_class<Hello>();
}

Hello.h:

#pragma once

#include <Godot.hpp>
#include <Node.hpp>

namespace godot {
    class Hello: public Node {
    private:
        GODOT_CLASS(Hello, Node)
    public:
        static void _register_methods();
        void _init();
        String get_hello();
    };
}

Hello.cpp:

#include "Hello.h"

using namespace godot;

void Hello::_register_methods() {
    register_method((char*)"get_hello", &Hello::get_hello);
}

void Hello::_init() {

}

String Hello::get_hello() {
    return "Hello world";
}

Thanks.

in Engine by (29 points)

1 Answer

+1 vote
Best answer

I believe none of your code relates to this issue.
If it works in VS2019 and you did the same steps then I don't know what's up with 2017. The errors you get seem to indicate that your project did not link to the library, somehow. It found declarations because you included headers, but at link time it could not find the machine code behind these classes (which are in the lib files). Either because they were not found, or they were not specified in whatever build system you are using. Another possibility is the absence of these classes from the library, which is not supposed to happen if you built it correctly (and I assume you did since it works in 2019).

Last thing I'm thinking is that maybe you built the library with the 2019 compiler (if that's a thing?) and somehow it is not compatible with 2017 (like Microsoft often likes to do). _CxxFrameHandler4 sounds neither like a godot-cpp symbol nor one of your functions. It relates to internal exception handling of vs2019. Perhaps an incompatibility between compilers.
Did a random search and this tends to confirm it (from another project) https://otland.net/threads/problem-cxxframehandler4-gshandlercheck_eh4-on-compiling-tfs-1-3.267884/#post-2588958

I only have 2017 on my computer and GDNative development works fine, so perhaps you just need to get rid of 2019 altogether so that it doesn't get picked up maybe, or find an option in SCons to force it to choose the 2017 toolchain? Sorry if I can't give more info on that.

by (28,740 points)
selected by

Resolved by cleaning all installs and then re-installing 2017. I did some more Google-fu, and no matter what VS version is in use, the compiler files used will be from the newer version, creating the linking error in vs2017.

Welcome to Godot Engine Q&A, where you can ask questions and receive answers from other members of the community.

Please make sure to read How to use this Q&A? before posting your first questions.
Social login is currently unavailable. If you've previously logged in with a Facebook or GitHub account, use the I forgot my password link in the login box to set a password for your account. If you still can't access your account, send an email to webmaster@godotengine.org with your username.