SFML community forums
Help => Window => Topic started by: bladelock on December 15, 2011, 10:26:21 pm
-
Hello, I'm currently using SFML to detect user input, it gives a system error that goes something like this
The program can't start because sfml-window-d.dll is missing from your computer. Try reinstalling the program to fix this problem.
Currently, I have a folder named "SFML" that contains the include and library files that I need. Here is the setup of my computer
Additional Include Directories:
$(OGRE_HOME)\include;$(OGRE_HOME)\include\OIS;$(OGRE_HOME)\include\OGRE;$(OGRE_HOME)\Samples\Common\include;$(OGRE_HOME)\boost_1_44;./SFML
Additional Library Directories:
$(OGRE_HOME)\lib\$(Configuration);$(OGRE_HOME)\boost_1_44\lib;./SFML/lib;
Additional Dependencies
OgreMain.lib;OIS.lib;sfml-main.lib;sfml-system-s-d.lib;sfml-window-d.lib;%(AdditionalDependencies)
Some of the files inside SFML (not all)
:
System.hpp
Window.hpp
lib (folder)
the files inside SFML\lib
:
sfml-main.lib
sfml-system-s-d.dll
sfml-system-s-d.lib
sfml-window-d.dll
sfml-window-d.lib
And finally (if you need it) my code (my ogre code is based on the ogre3d tutorial, and the cpp file in focus now is my tutorialapplication.cpp file (it's where most of the code i insert takes place. it's also where i put the sfml code)
/*
-----------------------------------------------------------------------------
Filename: TutorialApplication.cpp
-----------------------------------------------------------------------------
This source file is part of the
___ __ __ _ _ _
/___\__ _ _ __ ___ / / /\ \ (_) | _(_)
// // _` | '__/ _ \ \ \/ \/ / | |/ / |
/ \_// (_| | | | __/ \ /\ /| | <| |
\___/ \__, |_| \___| \/ \/ |_|_|\_\_|
|___/
Tutorial Framework
http://www.ogre3d.org/tikiwiki/
-----------------------------------------------------------------------------
*/
#include "TutorialApplication.h"
//add SFML
#include<SFML\System.hpp>
#include<SFML\Window.hpp>
#include<SFML\Graphics.hpp>
sf::Window App(sf::VideoMode(800, 600, 32), "SFML Window");
TutorialApplication::TutorialApplication(void)
{
}
TutorialApplication::~TutorialApplication(void)
{
}
//-------------------------------------------------------------------------------------
void TutorialApplication::createScene(void)
{
mSceneMgr->setAmbientLight(Ogre::ColourValue(0,0,0));
mSceneMgr->setShadowTechnique(Ogre::SHADOWTYPE_STENCIL_ADDITIVE);
Ogre::Entity* entNinja = mSceneMgr->createEntity("Ninja","ninja.mesh");
entNinja->setCastShadows(true);
mSceneMgr->getRootSceneNode()->createChildSceneNode()->attachObject(entNinja);
//the plane
Ogre::Plane plane(Ogre::Vector3::UNIT_Y,0);
Ogre::MeshManager::getSingleton().createPlane("ground", Ogre::ResourceGroupManager::DEFAULT_RESOURCE_GROUP_NAME,
plane, 1500, 1500, 20, 20, true, 1, 5, 5, Ogre::Vector3::UNIT_Z);
Ogre::Entity* entGround = mSceneMgr->createEntity("GroundEntity","ground");
mSceneMgr->getRootSceneNode()->createChildSceneNode()->attachObject(entGround);
//materials for the floor
entGround->setMaterialName("Examples/Rockwall");
entGround->setCastShadows(false);
//lights
Ogre::Light* pointLight = mSceneMgr->createLight("pointLight");
pointLight->setType(Ogre::Light::LT_POINT);
pointLight->setPosition(Ogre::Vector3(0,150,250));
pointLight->setDiffuseColour(1.0,0.0,0.0);
pointLight->setSpecularColour(1.0,0.0,0.0);
//directional light
Ogre::Light* directionalLight = mSceneMgr->createLight("directionalLight");
directionalLight->setType(Ogre::Light::LT_DIRECTIONAL);
directionalLight->setDiffuseColour(.25,0.25,0.0);
directionalLight->setSpecularColour(.25,0.25,0.0);
directionalLight->setDirection(Ogre::Vector3(0,-1,1));
//spotlight
Ogre::Light* spotLight = mSceneMgr->createLight("spotLight");
spotLight->setType(Ogre::Light::LT_SPOTLIGHT);
spotLight->setDiffuseColour(0, 0, 1.0);
spotLight->setSpecularColour(0, 0, 1.0);
spotLight->setDirection(-1, -1, 0);
spotLight->setPosition(Ogre::Vector3(300, 300, 0));
spotLight->setSpotlightRange(Ogre::Degree(35),Ogre::Degree(50));
//SFML STUFF
sf::Event Event;
while(App.IsOpened())
{
while (App.GetEvent(Event))
{
if ((Event.Type == sf::Event::KeyPressed) && (Event.Key.Code == sf::Key::U))
mSceneMgr->getRootSceneNode()->translate(Ogre::Vector3(10,0,0));
}
}
}
void TutorialApplication::createCamera(void)
{
mCamera = mSceneMgr->createCamera("PlayerCam");
mCamera->setPosition(Ogre::Vector3(0,10,500));
mCamera->lookAt(Ogre::Vector3(0,0,0));
mCamera->setNearClipDistance(5);
mCameraMan = new OgreBites::SdkCameraMan(mCamera);
}
void TutorialApplication::createViewports(void)
{
Ogre::Viewport* vp = mWindow->addViewport(mCamera);
vp->setBackgroundColour(Ogre::ColourValue(0,0,0));
mCamera->setAspectRatio(Ogre::Real(vp->getActualWidth())/Ogre::Real(vp->getActualHeight()));
}
#if OGRE_PLATFORM == OGRE_PLATFORM_WIN32
#define WIN32_LEAN_AND_MEAN
#include "windows.h"
#endif
#ifdef __cplusplus
extern "C" {
#endif
#if OGRE_PLATFORM == OGRE_PLATFORM_WIN32
INT WINAPI WinMain( HINSTANCE hInst, HINSTANCE, LPSTR strCmdLine, INT )
#else
int main(int argc, char *argv[])
#endif
{
// Create application object
TutorialApplication app;
try
{
app.go();
} catch( Ogre::Exception& e ) {
#if OGRE_PLATFORM == OGRE_PLATFORM_WIN32
MessageBox( NULL, e.getFullDescription().c_str(), "An exception has occured!", MB_OK | MB_ICONERROR| MB_TASKMODAL);
#else
std::cerr << "An exception has occured: " << e.getFullDescription().c_str() << std::endl;
#endif
}
return 0;
}
#ifdef __cplusplus
}
#endif
So where did I go wrong? where should I put the dll file anyway? Cheers
PS:
My Project is set under "Release" when being built and run, there are no other errors that are pointed out by visual studio other than the missing dll
-
where should I put the dll file anyway?
In the same directory as the executable.
-
I placed the dll file in the Release folder (Projects/*project name*/Release) folder already. It still claims that the dll file is missing from my computer.
How do I fix this?
-
I placed the dll file in the Release folder
sfml-window-d.dll suggests that you're in debug mode.
-
okay, so I modified my settings to use sfml-window.lib instead of sfml-window-d.lib
I placed sfml-window.dll in my Release folder because my project is set to "Release" instead of "Debug".
How could I fix this? Also the Ogre code only runs in Release atm (which is a different story)
-
Does it work if you run the executable from the explorer rather than from your IDE?
-
It is possible that the IDE is using the project folder as current directory, and not the folder where the executable is on.
-
I dragged all the necessary dlls, and executed the exe from the release folder (using the explorer).
Now it says the .exe "has stopped working."
What causes this crash?
Thanks
-
Anything could cause this crash. You could use the debug to find where it crashes.
-
okay, I'll try fix this tomorrow by rebuilding the downloadable sfml solution from the website, maybe that will help.
I'll give you guys a heads-up if anything happens
-
rebuilt the sdk into "Release", still nothing.
It still claims that the sfml-window.dll file is still missing from my computer.
It's in the location of my exe (it's in the Release folder since I set my project to Release)
why is it missing? what disables Visual Studio from detecting the dll file? I mean, it's in my exe's folder...
-
bladelock, have you tried to put it on the project folder instead of Release?
-
Yes, still the same problem.
-
Try using
system("cd");
to know where your program is running from. In order to see the result you should compile the project as a console application.
-
Try using
system("cd");
to know where your program is running from. In order to see the result you should compile the project as a console application.
I see, but how do I use the code in my .cpp file? Can you give me a sample code of it being used in action?
Also, by the way, I was able to find the problem. The "current directory" of the exe was in
<OgreSDKFolder>\bin\release
I believe that the current directory was modified by this code given during the setup of the OGRE sdk in the wiki, which goes like
setx OGRE_HOME %CD%
pause
Which i believe sets the current directory of an ogre project into the OGRE SDK instead of the Project's own directory for the use of OGRE.
at the very least, that solved the dll problem.
Now I'm getting
Unhandled exception at 0x7740f7cc in <nameofproject>.exe: 0xc0000005: Acess violation reading location 0x6e695720.
which i believe is caused by sfml because when I turned my sfml code in to comment code (using /* and */), the same error still occured, which makes me deduce that there's a problem somewhere in my ogre code, which I may have to solve myself at this point.
Thank you guys for helping!