Archive 17/01/2023.

Urho 3D project, Having some issues in VS 15 2017

LtPinecone

hello everyone. I am helping the Open Space Program team with code, and I decided to try and see if I could build the project in VS 2017 on Windows(it is originally linux). We have run into an issue.

First, I was able to build everything just fine, until I came to the the project (which opens in VS fine)

There is a GetObject reference to the Urho3D::JSON, however VS thinks its something else and references #define GetObject GetObjectA in the wingdi.h file (which is a VS thing.) I have a screen shot. Source code linked below in our GitHub.

image

https://github.com/TheOpenSpaceProgram/urho-osp

ab4daa

In PlanetWrenderer.h, delete #include <Urho3D/Engine/Application.h> seems work for me.

Probably there is platform specific thing in it, not sure.

jmiller

Hello and welcome to the forum! :confetti_ball:

While I am not being very specific… <windows.h> dumping thousands of macros and types into the global namespace, aka ‘namespace pollution’, can cause conflicts.

A chunk of code I was using to target MSW:

#pragma once
// Somewhat limit windows header namespace pollution.

#ifdef _WIN32
#define WIN32_LEAN_AND_MEAN
#define NOSERVICE
#define NOMCX
#define NOIME
#define NONLS
#include <windows.h>
#undef CreateDirectory
#undef GetClassName
#undef GetProp
#undef RemoveProp
#undef SetProp
#endif
Leith

At (or near) the top of OspUniverse.cpp, add this:

#undef GetObject

That should resolve the problem, for that file.
I notice that MachineRocket.cpp has the same problem.
Rather than adding it to each cpp file, you could add it to a core .h file, it’s up to you.

LtPinecone

Thank you, This worked for me too, however I get another error, it is

image

ab4daa

add #include <Urho3D/Core/Context.h> :upside_down_face:

LtPinecone

That created 61 errors…
I deleted it after it created the errors, and back to the context issue. it happens on the line here:

image

ab4daa

What I did is:

  1. Delete #include <Urho3D/Engine/Application.h> in PlanetWrenderer.h
  2. add #include <Urho3D/Core/Context.h> in PlanetTerrain.cpp
  3. help Pow in PlanetWrenderer.h: UpdateRange(): m_start(Pow((int)2ul, (int)sizeof(buindex) * 8) - 1u), m_end(0)

I can build successfully by doing the 3 steps.

LtPinecone

Thank you for the help! It worked, I will add your instructions to our wiki if you don’t mind

ab4daa

Glad it helps. :slightly_smiling_face:

LtPinecone

Also, how do I…play the game from Visual Studio? Sorry for the dumb question, I am kind of new to Urho3D.

ab4daa

You mean execute the program?
There is a button with this icon
%E5%9C%96%E7%89%87

or press F5 I think

EDIT: remember to right click on the osp project in solution explorer and set it as startup project, then F5 will run osp project.

LtPinecone

I got that, Was able to run it except an exception was thrown causing it to crash. Keeps happening in a random place every time. For example:

image

Leith

That’s a breakpoint, a special kind of exception, it’s deliberate! Assuming you’re on windows, when the breakpoint is reached, examine the “call stack”, and double click on the most recent (topmost?) “stack frame” - that should take you to the exact line of sourcecode that contains this “harcoded breakpoint” - likely it will say “__asm {int 3}” or similar. If so, remove it.
If you can’t find the breakpoint in the topmost stack frame, then look at the next one before it, which will give you a clue about where the call to the offending code originated, which you can then follow to find the issue.