[SOLVED] Urho3D as external library in another C++ project

Trying to follow the suggestions given here

urho3d.github.io/documentation/H … brary.html

about creating a new C++ project that links to Urho3D as an external library (trying the first option, using Urho3D library directly from the Urho3D project build tree). I’ve set things up exactly as described there, and CMake does successfully build a Visual Studio project which appears to have all the correct dependencies.

But the C++ project I’ve made is intended to be a console application. When I build it, I get the error message:

“142 error LNK2019: unresolved external symbol _WinMain@16 referenced in function __tmainCRTStartup”

I think the problem is that, in my new project, I have copied the text (from the documentation linked above) into my CMakeLists.txt, which uses the macro setup_main_executable.

Any advice on how I could change the top level CMakeLists.txt in my new project, to still link to Urho3D as described in the documentation, but to just change the new project type to console application?

Or that doesn’t have to be the fix, I am really just trying to avoid the “unresolved external symbol _WinMain@16…”

Thanks all!

In Visual Studio (which I believe is the IDE you’re using), the relevant option is shown here:

I’ve no idea how to bake this into CMake though.

Try to build with this build option “URHO3D_WIN32_CONSOLE” set.

AFAIK, it looks like you are trying for something like a headless mode with a console or input.

Headless (bool) Headless mode enable. Default false.

Are you trying to do the same?

@thebluefish – thank you, yes I am using Visual Studio and changing that option solved the error

@weitjong – I gave it a try, and the VS solution was successfully built, although I still had to change the System/SubSystem option as thebluefish suggested. I’m okay with that.

@rasteron – yes what we’re doing is quite similar to running an Application in headless mode. In fact that was an earlier variant of our project. At this point we’re not even inheriting from Application, but using Scene, Octree and others by hand

Appreciate the responses!

Correction: I said weitjong’s suggestion to set the build option “URHO3D_WIN32_CONSOLE” didn’t work for me. Actually this definitely does work and I must have done it wrong.