The procedure entry point could not be located

Started by Charsmud, 09 January 2014, 22:33:20

Charsmud

Hello!  I am getting the following error when I attempt to run my program:


The procedure entry point ?begin@String@sf@QAE?AV?$_String_iterator@V?$_String_val@U?$_Simple_types@I@std@@@std@@@std@@XZ could not be located in the dynamic link library sfml-system-2.dll.


This error occurs during runtime before a window appears.  This error only appeared after the installation of TGUI, which leads me to believe that it is the cause.  I have tried both the version of TGUI that the download includes and building it.  I am using VS2010.  Here is the .cpp file and the .hpp relevant line:



#pragma once

#include "ResourceHolder.hpp"
#include "ResourceIdentifiers.hpp"
#include "Player.hpp"
#include "StateStack.hpp"

#include <SFML/System/Time.hpp>
#include <SFML/Graphics/RenderWindow.hpp>
#include <SFML/Graphics/Text.hpp>

#include <TGUI\TGUI.hpp>


class Application
{
private:
sf::RenderWindow mWindow;
tgui::Gui mGui;

};


and here is the complete .cpp file:


#include "Application.hpp"
#include "Utility.hpp"
#include "State.hpp"
#include "StateIdentifiers.hpp"
#include "TitleState.hpp"
#include "GameState.hpp"
#include "MenuState.hpp"
#include "PauseState.hpp"

const sf::Time Application::timePerFrame = sf::seconds(1.f/60.f);

Application::Application()
: mWindow(sf::VideoMode(640, 480), "States", sf::Style::Close)
, mGui(mWindow)
, mTextures()
, mFonts()
, mPlayer()
, mStateStack(State::Context(mWindow, mTextures, mFonts, mPlayer))
, mStatisticsText()
, mStatisticsUpdateTime()
, mStatisticsNumFrames(0)
{
mWindow.setKeyRepeatEnabled(false);

mFonts.load(Fonts::Main, "Media/Sansation.ttf");
mTextures.load(Textures::TitleScreen, "Media/Textures/TitleScreen.png");

mStatisticsText.setFont(mFonts.get(Fonts::Main));
mStatisticsText.setPosition(5.f, 5.f);
mStatisticsText.setCharacterSize(10u);

mGui.setGlobalFont(mFonts.get(Fonts::Main));

registerStates();
mStateStack.pushState(States::Menu);
}


void Application::registerStates()
{
mStateStack.registerState<MenuState>(States::Menu);
mStateStack.registerState<GameState>(States::Game);
mStateStack.registerState<PauseState>(States::Pause);
}

void Application::run()
{
sf::Clock clock;
sf::Time timeSinceLastUpdate = sf::Time::Zero;

while (mWindow.isOpen())
{
sf::Time dt = clock.restart();
timeSinceLastUpdate += dt;
while (timeSinceLastUpdate > timePerFrame)
{
timeSinceLastUpdate -= timePerFrame;

processInput();
update(timePerFrame);

// Check inside this loop, because stack might be empty before update() call
if (mStateStack.isEmpty())
mWindow.close();
}

updateStatistics(dt);
render();
}
}

void Application::processInput()
{
sf::Event event;
while (mWindow.pollEvent(event))
{
mStateStack.handleEvent(event);
mGui.handleEvent(event);

if (event.type == sf::Event::Closed)
mWindow.close();
}
}

void Application::update(sf::Time dt)
{
mStateStack.update(dt);
}

void Application::render()
{
mWindow.clear();

mStateStack.draw();

mWindow.setView(mWindow.getDefaultView());
mWindow.draw(mStatisticsText);

mGui.draw();

mWindow.display();
}

void Application::updateStatistics(sf::Time dt)
{
mStatisticsUpdateTime += dt;
mStatisticsNumFrames += 1;
if (mStatisticsUpdateTime >= sf::seconds(1.0f))
{
mStatisticsText.setString("FPS: " + toString(mStatisticsNumFrames));

mStatisticsUpdateTime -= sf::seconds(1.0f);
mStatisticsNumFrames = 0;
}
}



Any ideas?

texus

I would guess that your SFML and TGUI libraries aren't compatibe.

Both should be compiled for your exact compiler. Did you compile tgui yourself? You'll have to because there are no precompiled libs for VS2010 (yet).

Both libs should be linked in the same way. In a debug build, you need the debug libs and in release you will need the release libs. If sfml is static, then tgui has to be static as well (or both dynamic).

Charsmud

I have built TGUI for VS2010, and my SFML is also for VS2010.  I built TGUI for both Debug and Release dynamically, and have linked the files.  SFML is also linked dynamically.  I still receive the error.

texus

I never had the problem myself so I don't really know what you could do.

Quickly googling for that error tells me that you might need to set /OPT:NOREF in linker optimzation settings.

I'm going to sleep now, and tomorrow I have an exam, but I can try to take a look at it afterwards. So if the above doesn't fix the problem and you are 100% sure that you are linking correctly then put your sfml and tgui libs somewere (e.g. dropbox) and I'll see if I can find something special about them tomorrow.

Charsmud

Setting that in Linker Optimization did not work.  Here is a link to my lib, include and dll files:

https://www.dropbox.com/sh/8amwvbbvb4rsf3b/SPCpvxLiAW

The Illusionist Mirage

You might use this tool to check if all the functions are exported to your DLLs and that they have access to them.

I used to get some of these "procedure entry point could not be located" errors in VS12 myself with SFML. And every time the reason was either incorrect build or incorrect linking.

Also, this thread here might contain some info you are looking for.

Charsmud

I downloaded that program, and i get the following output in the bottom window (I selected the .exe file that was compiled with Release):


Error: At least one module has an unresolved import due to a missing export function in an implicitly dependent module.
Error: Modules with different CPU types were found.
Warning: At least one delay-load dependency module was not found.
Warning: At least one module has an unresolved import due to a missing export function in a delay-load dependent module.


texus

Which generator did you select in CMake when building TGUI?

Charsmud

I selected Visual Studio 10.  Is it possibly because of conflicting bits (x32 and x64)?

texus

I would guess something like that from the "Error: Modules with different CPU types were found." line.

All libraries do need to be build for the same architecture.

texus

I just tested your libraries and I don't have any problem with them.

Do you have vs2010 sp1 installed?

Could you send me your vcxproj file, and create a minimal example code (so that we test with the exact same code)?

Charsmud


texus

#12
I'm getting a http error 500 on that page.

Edit: I can acces it now

texus

There is something wrong with the dlls.

I removed the dlls from your Release folder, and replaced them with the onces that you send earlier, and then everything worked fine.

Charsmud

It worked for me as well.  :P  I'm not sure how moving the dlls from dropbox fixed them, but it works now.  Thanks for helping!