Ogre DLL Warnings

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

Re: Ogre DLL Warnings

Post by paroj »

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).
Owl53
Halfling
Posts: 92
Joined: Sat Jul 22, 2017 2:32 pm
x 4

Re: Ogre DLL Warnings

Post by Owl53 »

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.
paroj
OGRE Team Member
OGRE Team Member
Posts: 1994
Joined: Sun Mar 30, 2014 2:51 pm
x 1074
Contact:

Re: Ogre DLL Warnings

Post by paroj »

please read the link. You must build your project using cmake if you want to use Ogre.
Owl53
Halfling
Posts: 92
Joined: Sat Jul 22, 2017 2:32 pm
x 4

Re: Ogre DLL Warnings

Post by Owl53 »

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.
loath
Platinum Sponsor
Platinum Sponsor
Posts: 290
Joined: Tue Jan 17, 2012 5:18 am
x 67

Re: Ogre DLL Warnings

Post by loath »

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...
paroj
OGRE Team Member
OGRE Team Member
Posts: 1994
Joined: Sun Mar 30, 2014 2:51 pm
x 1074
Contact:

Re: Ogre DLL Warnings

Post by paroj »

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.
Owl53
Halfling
Posts: 92
Joined: Sat Jul 22, 2017 2:32 pm
x 4

Re: Ogre DLL Warnings

Post by Owl53 »

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.
loath
Platinum Sponsor
Platinum Sponsor
Posts: 290
Joined: Tue Jan 17, 2012 5:18 am
x 67

Re: Ogre DLL Warnings

Post by loath »

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.
Owl53
Halfling
Posts: 92
Joined: Sat Jul 22, 2017 2:32 pm
x 4

Re: Ogre DLL Warnings

Post by Owl53 »

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!
Owl53
Halfling
Posts: 92
Joined: Sat Jul 22, 2017 2:32 pm
x 4

Re: Ogre DLL Warnings

Post by Owl53 »

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.
rpgplayerrobin
Gnoll
Posts: 619
Joined: Wed Mar 18, 2009 3:03 am
x 353

Re: Ogre DLL Warnings

Post by rpgplayerrobin »

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
Owl53
Halfling
Posts: 92
Joined: Sat Jul 22, 2017 2:32 pm
x 4

Re: Ogre DLL Warnings

Post by Owl53 »

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!
Owl53
Halfling
Posts: 92
Joined: Sat Jul 22, 2017 2:32 pm
x 4

Re: Ogre DLL Warnings

Post by Owl53 »

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
rpgplayerrobin
Gnoll
Posts: 619
Joined: Wed Mar 18, 2009 3:03 am
x 353

Re: Ogre DLL Warnings

Post by rpgplayerrobin »

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.
Owl53
Halfling
Posts: 92
Joined: Sat Jul 22, 2017 2:32 pm
x 4

Re: Ogre DLL Warnings

Post by Owl53 »

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!
Post Reply