Ogre DLL Warnings

Problems building or running the engine, queries about how to use features etc.
paroj
OGRE Team Member
OGRE Team Member
Posts: 872
Joined: Sun Mar 30, 2014 2:51 pm
x 176
Contact:

Re: Ogre DLL Warnings

Post by paroj » Fri Feb 01, 2019 5:02 pm

dll interface warnings usually mean that dllimport is not working properly. Are you using cmake to import ogre like that?
https://ogrecave.github.io/ogre/api/latest/setup.html

for the static build: currently you will have to call find_package for all libraries that ogre depends on in your own project as well - e.g. find_package(ZLIB). (see Dependencies.cmake).
0 x

Owl53
Halfling
Posts: 83
Joined: Sat Jul 22, 2017 2:32 pm
x 4

Re: Ogre DLL Warnings

Post by Owl53 » Fri Feb 01, 2019 5:11 pm

paroj wrote:
Fri Feb 01, 2019 5:02 pm
dll interface warnings usually mean that dllimport is not working properly. Are you using cmake to import ogre like that?
https://ogrecave.github.io/ogre/api/latest/setup.html

for the static build: currently you will have to call find_package for all libraries that ogre depends on in your own project as well - e.g. find_package(ZLIB). (see Dependencies.cmake).
I'm sorry but I don't understand what you mean regarding using "cmake to import ogre like that". I've built Ogre, and I've linked the various Ogre .libs to my project in the VS properties, the same way I would for Bullet Physics, for example. I'm not building my project as a DLL (I notice people in general that get these warnings are building their projects as a DLL), it's built as an application.
0 x

paroj
OGRE Team Member
OGRE Team Member
Posts: 872
Joined: Sun Mar 30, 2014 2:51 pm
x 176
Contact:

Re: Ogre DLL Warnings

Post by paroj » Fri Feb 01, 2019 5:22 pm

please read the link. You must build your project using cmake if you want to use Ogre.
0 x

Owl53
Halfling
Posts: 83
Joined: Sat Jul 22, 2017 2:32 pm
x 4

Re: Ogre DLL Warnings

Post by Owl53 » Fri Feb 01, 2019 5:31 pm

paroj wrote:
Fri Feb 01, 2019 5:22 pm
please read the link. You must build your project using cmake if you want to use Ogre.
I did read the link, but I was confused by it initially. I didn't realise that the project needed to be built using cmake. I have never used cmake to build my own project, only to build libraries that I intended to use in a project (like Bullet Physics). I will have to research how to do this, thank you for clarifying that. Hopefully once I've successfully used cmake to build the project and linked Ogre to it it will resolve these DLL warnings.
0 x

loath
Platinum Sponsor
Platinum Sponsor
Posts: 98
Joined: Tue Jan 17, 2012 5:18 am
x 2

Re: Ogre DLL Warnings

Post by loath » Fri Feb 01, 2019 5:43 pm

i use the dll version of ogre on windows and my project is not using cmake (although i wish it was and i may port it at some point).

trying out static ogre builds now and will get back to you...
0 x

paroj
OGRE Team Member
OGRE Team Member
Posts: 872
Joined: Sun Mar 30, 2014 2:51 pm
x 176
Contact:

Re: Ogre DLL Warnings

Post by paroj » Fri Feb 01, 2019 6:00 pm

yes technically speaking cmake only sets some VS properties which you can as well do manually - but to do it right you have to set up everything as stated in OgreTargets.cmake - which requires you to know exactly what you are doing.
0 x

Owl53
Halfling
Posts: 83
Joined: Sat Jul 22, 2017 2:32 pm
x 4

Re: Ogre DLL Warnings

Post by Owl53 » Fri Feb 01, 2019 6:02 pm

paroj wrote:
Fri Feb 01, 2019 6:00 pm
yes technically speaking cmake only sets some VS properties which you can as well do manually - but to do it right you have to set up everything as stated in OgreTargets.cmake - which requires you to know exactly what you are doing.
Yeah I see what you're saying, it makes sense to learn how to set the project up using cmake rather than doing it manually so I can use the lines specified in the link you posted. Thanks for the advice.
0 x

loath
Platinum Sponsor
Platinum Sponsor
Posts: 98
Joined: Tue Jan 17, 2012 5:18 am
x 2

Re: Ogre DLL Warnings

Post by loath » Fri Feb 01, 2019 6:32 pm

the issue is static builds place the pdb in the INTERMEDIATE directory:
d:\source\ogre\build\OgreMain\OgreMain.dir\Debug\ogre\OgreMain.pdb

NON-static configurations place the pdb in the BINARY directory:
d:\source\ogre\build\bin\debug\ogremain.pdb

when install runs it looks in the BINARY location.

unfortunately i don't know cmake very well. i assume we need to add a line to d:\source\ogre\CMake\InstallDependencies.cmake like:
install(FILES DESTINATION lib/release CONFIGURATIONS Release)
except for the pdb

or we need to move / output the pdb

@owl, in the short term, if you really need static libs... your best bet would be to copy each of the pdbs to the location install expects.
copy D:\source\ogre\build\OgreMain\OgreMain.dir\Debug\ogremain.pdb D:/source/ogre/build/lib/ogrestaticmain_d.pdb

<repeat for every static lib like the render systems etc>

cmake isn't super complicated so you could also read a tutorial and fix it for ogre which would be awesome. i need to get started on work.

at a minimum you should open a bug some someone can tackle it eventually.
0 x

Owl53
Halfling
Posts: 83
Joined: Sat Jul 22, 2017 2:32 pm
x 4

Re: Ogre DLL Warnings

Post by Owl53 » Fri Feb 01, 2019 6:40 pm

loath wrote:
Fri Feb 01, 2019 6:32 pm
the issue is static builds place the pdb in the INTERMEDIATE directory:
d:\source\ogre\build\OgreMain\OgreMain.dir\Debug\ogre\OgreMain.pdb

NON-static configurations place the pdb in the BINARY directory:
d:\source\ogre\build\bin\debug\ogremain.pdb

when install runs it looks in the BINARY location.

unfortunately i don't know cmake very well. i assume we need to add a line to d:\source\ogre\CMake\InstallDependencies.cmake like:
install(FILES DESTINATION lib/release CONFIGURATIONS Release)
except for the pdb

or we need to move / output the pdb

@owl, in the short term, if you really need static libs... your best bet would be to copy each of the pdbs to the location install expects.
copy D:\source\ogre\build\OgreMain\OgreMain.dir\Debug\ogremain.pdb D:/source/ogre/build/lib/ogrestaticmain_d.pdb

<repeat for every static lib like the render systems etc>

cmake isn't super complicated so you could also read a tutorial and fix it for ogre which would be awesome. i need to get started on work.

at a minimum you should open a bug some someone can tackle it eventually.
Yeah I had the same thoughts regarding cmake, I've now started learning from tutorials how to write cmakelists, but given I have never done it before I'd imagine it'll be a while before I'm confident in tackling anything complex. I don't particularly need static libs, it was just a means to an end to get rid of the DLL warnings. Once I've got a project that works set up that links to ogre using cmake hopefully that will result in fixing the warnings, as Paroj says it is the intended way to set up the project so hopefully everything will be in order.

Thank you for all the help!
0 x

Owl53
Halfling
Posts: 83
Joined: Sat Jul 22, 2017 2:32 pm
x 4

Re: Ogre DLL Warnings

Post by Owl53 » Wed Feb 13, 2019 2:44 pm

I have tried following your advice of creating the VS project using CMake, @Paroj.

Following research at the following links:

viewtopic.php?f=2&t=94823
http://wiki.ogre3d.org/CMakeLists

I have ended up with the following CMakeLists.txt

Code: Select all

cmake_minimum_required (VERSION 3.3.0)
project (TestProj)

set(OGRE_DIR "C:/Users/Name/Desktop/TestProj/Ogre3D/CMake")

# specify which version and components you need
find_package(OGRE 1.11 REQUIRED COMPONENTS RTShaderSystem)
# copy resource.cfg next to our binaries where OGRE looks for it
file(COPY ${OGRE_CONFIG_DIR}/resources.cfg DESTINATION ${CMAKE_BINARY_DIR})

add_executable(TestProj "C:/Users/Name/Desktop/TestProj/Main.cpp")

target_link_libraries(TestProj ${OGRE_LIBRARIES})
target_include_directories(TestProj PUBLIC "C:/Users/Name/Desktop/TestProj/Ogre3D/include")
From this, the project appears to have been generated correctly. I open the .sln and build the project, but I still get the DLL warnings that I had previously when building the VS project myself. Any suggestions on what I'm doing wrong now that I'm building the project using CMake would be welcome.

Thanks.
0 x

rpgplayerrobin
Gremlin
Posts: 151
Joined: Wed Mar 18, 2009 3:03 am
x 16

Re: Ogre DLL Warnings

Post by rpgplayerrobin » Wed Feb 13, 2019 6:53 pm

I think many people has that DLL warning. It is apparently because of STL members that are non-public.
In my project, I just add this in the start of my Stdafx.h file (taken from ogre-source itself):

Code: Select all

// disable: "<type> needs to have dll-interface to be used by clients'
// Happens on STL member variables which are not public therefore is ok
#   pragma warning (disable : 4251)
#   pragma warning (disable : 4275)
Here are some others that has had the same issue, and it seems to just go to the answer of "ignore it and stop worrying about it":
viewtopic.php?t=10562
viewtopic.php?t=21707
viewtopic.php?t=15224
0 x

Owl53
Halfling
Posts: 83
Joined: Sat Jul 22, 2017 2:32 pm
x 4

Re: Ogre DLL Warnings

Post by Owl53 » Wed Feb 13, 2019 7:57 pm

rpgplayerrobin wrote:
Wed Feb 13, 2019 6:53 pm
I think many people has that DLL warning. It is apparently because of STL members that are non-public.
In my project, I just add this in the start of my Stdafx.h file (taken from ogre-source itself):

Code: Select all

// disable: "<type> needs to have dll-interface to be used by clients'
// Happens on STL member variables which are not public therefore is ok
#   pragma warning (disable : 4251)
#   pragma warning (disable : 4275)
Here are some others that has had the same issue, and it seems to just go to the answer of "ignore it and stop worrying about it":
viewtopic.php?t=10562
viewtopic.php?t=21707
viewtopic.php?t=15224
Thanks for the suggestion. It might be the best option at this stage, I have tried everything I can think of and any other suggestions that have been made, with no luck. I had read one of those forum threads on the subject before, but it's good to have the extra reassurance of the others. I'll add the #pragma warning disable to my project then. Thanks!
0 x

Owl53
Halfling
Posts: 83
Joined: Sat Jul 22, 2017 2:32 pm
x 4

Re: Ogre DLL Warnings

Post by Owl53 » Thu Feb 28, 2019 6:16 pm

rpgplayerrobin wrote:
Wed Feb 13, 2019 6:53 pm
I think many people has that DLL warning. It is apparently because of STL members that are non-public.
In my project, I just add this in the start of my Stdafx.h file (taken from ogre-source itself):

Code: Select all

// disable: "<type> needs to have dll-interface to be used by clients'
// Happens on STL member variables which are not public therefore is ok
#   pragma warning (disable : 4251)
#   pragma warning (disable : 4275)
Here are some others that has had the same issue, and it seems to just go to the answer of "ignore it and stop worrying about it":
viewtopic.php?t=10562
viewtopic.php?t=21707
viewtopic.php?t=15224
Hi,

Could I just clarify something? If I add the line #pragma warning (disable : 4251) in my main.cpp, it only removes the warnings for the uses of Ogre in that particular source file. Do I need to add the disable to every file I write that uses Ogre? I have added the following code to each header file that has a class that uses Ogre, and it seems to work fine, but I wanted to make sure that this is the appropriate way of doing it:

Code: Select all

#pragma warning (push)
#pragma warning (disable : 4251)

//Ogre code in here

#pragma warning (pop)
(Even if I don't use the lines with push and pop, it still only works for the individual file). I don't have a precompiled header either that I could add the disable to, so is this the correct way for my code setup?

Thanks
0 x

rpgplayerrobin
Gremlin
Posts: 151
Joined: Wed Mar 18, 2009 3:03 am
x 16

Re: Ogre DLL Warnings

Post by rpgplayerrobin » Thu Feb 28, 2019 6:30 pm

Since you don't have a precompiled header to place it in, you could try setting it in the project settings, it might work: Configuration Properties->C/C++->Advanced->Disable Specific Warnings.

Also, you could probably do a file which does this for you which you include with each file that gets the error, like:
DisableWarnings.h:

Code: Select all

#   pragma warning (disable : 4251)
#   pragma warning (disable : 4275)
This file you then just include in the start of each file with the warnings. You could possibly also do a macro for it and use that in each file.
1 x

Owl53
Halfling
Posts: 83
Joined: Sat Jul 22, 2017 2:32 pm
x 4

Re: Ogre DLL Warnings

Post by Owl53 » Thu Feb 28, 2019 6:32 pm

rpgplayerrobin wrote:
Thu Feb 28, 2019 6:30 pm
Since you don't have a precompiled header to place it in, you could try setting it in the project settings, it might work: Configuration Properties->C/C++->Advanced->Disable Specific Warnings.

Also, you could probably do a file which does this for you which you include with each file that gets the error, like:
DisableWarnings.h:

Code: Select all

#   pragma warning (disable : 4251)
#   pragma warning (disable : 4275)
This file you then just include in the start of each file with the warnings. You could possibly also do a macro for it and use that in each file.
Thanks for the suggestions! I like the idea of having a specific header file for it that I can include rather than having to manually write the code around every time ogre variables are used in a class that I am doing at the moment. I'll do that then, thanks!
0 x

Post Reply