The procedure entry point could not be located
« on: 09 January 2014, 22:33:20 »
Hello!  I am getting the following error when I attempt to run my program:

Code: [Select]
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:

Code: [Select]

#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:

Code: [Select]
#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

  • *****
  • 1143
    • View Profile
    • Texus's Blog
Re: The procedure entry point could not be located
« Reply #1 on: 09 January 2014, 22:49:00 »
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).

Re: The procedure entry point could not be located
« Reply #2 on: 09 January 2014, 22:54:05 »
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

  • *****
  • 1143
    • View Profile
    • Texus's Blog
Re: The procedure entry point could not be located
« Reply #3 on: 09 January 2014, 23:03:36 »
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.

Re: The procedure entry point could not be located
« Reply #4 on: 09 January 2014, 23:10:15 »
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

  • *
  • 2
  • My Life = C++ & Computers
    • View Profile
    • fleptic
Re: The procedure entry point could not be located
« Reply #5 on: 10 January 2014, 15:53:25 »
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.
Long Live C++

Re: The procedure entry point could not be located
« Reply #6 on: 10 January 2014, 18:29:06 »
I downloaded that program, and i get the following output in the bottom window (I selected the .exe file that was compiled with Release):

Code: [Select]
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

  • *****
  • 1143
    • View Profile
    • Texus's Blog
Re: The procedure entry point could not be located
« Reply #7 on: 10 January 2014, 18:31:15 »
Which generator did you select in CMake when building TGUI?

Re: The procedure entry point could not be located
« Reply #8 on: 10 January 2014, 18:33:08 »
I selected Visual Studio 10.  Is it possibly because of conflicting bits (x32 and x64)?

*

texus

  • *****
  • 1143
    • View Profile
    • Texus's Blog
Re: The procedure entry point could not be located
« Reply #9 on: 10 January 2014, 18:34:33 »
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

  • *****
  • 1143
    • View Profile
    • Texus's Blog
Re: The procedure entry point could not be located
« Reply #10 on: 10 January 2014, 19:56:45 »
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)?

Re: The procedure entry point could not be located
« Reply #11 on: 11 January 2014, 18:40:34 »
I do have VS2010 SP1 installed.  Here is a link to my project:

https://www.dropbox.com/sh/du3l7ms4bboetf3/QdVpctfjbc

*

texus

  • *****
  • 1143
    • View Profile
    • Texus's Blog
Re: The procedure entry point could not be located
« Reply #12 on: 11 January 2014, 18:54:33 »
I'm getting a http error 500 on that page.

Edit: I can acces it now
« Last Edit: 11 January 2014, 19:08:31 by texus »

*

texus

  • *****
  • 1143
    • View Profile
    • Texus's Blog
Re: The procedure entry point could not be located
« Reply #13 on: 11 January 2014, 19:23:51 »
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.

Re: The procedure entry point could not be located
« Reply #14 on: 11 January 2014, 20:10:11 »
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!