How do I solve Error 126/193 from using Loadlibrary? - c++

I'm working a on project to use the SDK from https://github.com/hypersen/HPS3D_SDK
but I'm having troubles loading the DLL file, it returns me an error 126 for "libhps3d32.dll" and error 193 while using "libhps3d64.dll". I've seen many posts regarding these 2 errors but none of the solution so far works for me. Please help!
The dll file is the same location as the exe file. I've tried disabling my anti virus too, didn't help.
printf("Hello world!\n");
/*LoadLibrary */
HMODULE module = LoadLibraryA((LPCSTR)"C:\\Users\\xx\\Desktop\\xx\\libhps3d32.dll");
//printf("module loaded %d)",module);
if (module == NULL)
{
DWORD error_id = GetLastError();
printf("error load %d\n",error_id);
return;
}

EDIT: I was able to solve this by using dependency walker to trace the DLL file and its path. Found out that i was missing a few key dlls. Fixed after put them in place. Hope this works for everyone facing the same problems.

Related

SDL Mix_LoadMUS not loading .mp3

So Apparently i've been trying to load an .mp3 using SDL_mixer. However, this does not work, as opposed to the libsdl wiki: SDL_mixer Mix_LoadMUS
I was hoping for it to work, but when loading and playing the file, the following errors popped in my console app:
Mix_LoadMUS: Unrecognized audio format
Mix_PlayMusic: music parameter was NULL
To my extent, i've been trying to load test.mp3 the following way:
Mix_Music * m_mainMusic;
m_mainMusic = Mix_LoadMUS("test.mp3");
if (m_mainMusic != nullptr)
printf("Loaded the file\n");
else
printf("Mix_LoadMUS: %s\n", Mix_GetError());
if (Mix_PlayMusic(m_mainMusic, -1) == -1)
printf("Mix_PlayMusic: %s\n", Mix_GetError());
I have obviously initialized the SDL subsystem.
With the help of the above explanations I tried to reproduce your issue, and the only thing that caused something similar was the lack of runtime libraries. Make sure that all the necessary libraries are available during runtime (copy them in the folder of your executable or set an environment variable or use static linking.) The runtime libraries distributed with SDL_mixer are the following ones: libmpg123-0, libmodplug-1, libFLAC-8, libogg-0, libopus-0, libopusfile-0, libvorbis-0, libvorbisfile-3 and SDL2_mixer.
These can be acquired here: https://www.libsdl.org/projects/SDL_mixer/

stat not returning properly on centos 7?

So I am running a C++ app, built with CMake (not by me). It works fine on other people testing with it, but not found anyone to test on centos7 yet.
The issue seems to arrise at this snippet of code:
struct stat fileStat;
if ( stat( pszFilePath, &fileStat) == -1 )
{
DEBUG_ERR(( "Can't open input dir [%s]\n", pszFilePath ));
return( false );
}
Which is the first part of the ReadFileInfo call here:
time_t dateChange;
DWORD dwSize;
if ( ! CFileList::ReadFileInfo( GetFilePath(), dateChange, dwSize ))
{
DEBUG_ERR(( "Can't get stats info for file '%s'\n", static_cast<LPCTSTR>(GetFilePath()) ));
return false;
}
Now, pszFilePath is many value, a few examples are:
'scripts/sphere_template_vend.scp'
'scripts/sphere_serv_triggers.scp'
The application is owned by root, the whole folder it all sits in is owned by root. The scripts folder is there and has read/write permissions as do all files (all also owned by root)
Running the application triggers both errors in the above code, there is nothing before them that influences anything.
Im not a C++ developer and do not have the tools to compile with debugs for checking the current path and so on, but I see no reason why it throws these errors. The files exist, the files are accessible, no one else seems to have this problem.
I do have cPanel on the server, but it shouldn't be causing any issues as I am using root user and also keeping out of the /home/ directory
Anyone know of any issue this could be because of? I tried with a '/sphere/' prepending the paths but it still has the same issue, it seems the application does not have access to the files (the application oddly reports line errors within the files it says it cannot read, but they do not match, so assuming its not correct).
Issue reported on the Github for the project here: https://github.com/Sphereserver/Source/issues/64
But no one seems to know whats going on

LoadLibraryEx error 87 (The parameter is incorrect)

One of my applications cannot load a system lib on the only machine. LoadLibraryEx returns 0 and the GetLastError returns 87 (The parameter is incorrect).
That can cause such error and how do I debug it?
Error appears only on a single machine which belongs to my client (server 2008R2). Libarary is located in system32 folder. Here is the code:
HMODULE lib = LoadLibraryEx(L"authui.dll", NULL,
LOAD_LIBRARY_AS_DATAFILE | LOAD_LIBRARY_SEARCH_SYSTEM32);
if (lib == NULL)
{
DWORD err=GetLastError();
Log(L"error id: ", err);
throw;
}
I cannot reproduce the error on my copy of 2008R2 and have no idea what can cause the error. My app is written in VS2015 C++ (pure WinApi, no MFC or third party libs) and it is 64-bit.
Joel was right. The problem is in KB2533623 update which was not installed on the problem machine. I have changed my code to use absolute path as David Heffernan recommended and it works fine now.
Use the absolute path of authui.dll as the first parameter of LoadLibraryEx.

SDL - TTF - font not loading

I am having Problem loading SDL_TTF font.
my program is so big, so there's a piece of code which is creating problem.
TTF_Font *font = NULL;
SDL_Color textColor = {255, 255, 255};
if(SDL_Init() == -1 || TTF_Init() == -1)
return 0;
font = TTF_OpenFont("calibri.ttf", 28);
if(font == NULL)
return 0;
Now please tell me why the funtion TTF_OpenFont is not working.
font remains NULL after the funtion and the program exits...
EDIT:
I cannot cout or printf TTF_GetError() but i used breakpoints to see which function is not working correctly and found the function TTF_OpenFont() returning null every time.
(BTW if there any way to print the Erroe on screen the tell please).
TTF_Init() is working correctly.
FOR PEOPLE WHO ARE ASKING TO INSTALL SDL_TTF SEPARATELY:
I have written the link below from which i am learning SDL in first tutorial it guides how to install SDL and integrate it which project, In 3rd lesson comes the SDL_IMAGE extension library which is to be needed to install separately (which i did and used all image functions easily), In 7th lesson it didn't teach how to install SDL_TFF rather says to do the same steps as for SDL_IMAGE but this time for SDL_TTf so i downloaded SDL_TTF and intalled and you know the rest after....
Windows 8.1, CodeBlocks, MinGW32, SDL1
Here's the link i am learning SDL from
SDL Tutorials
This is how i installed the Extension Library(SDL_TTF)
Setting Up Extention Library
If font is NULL you should use TTF_GetError to know what went wrong.
If the error message is opaque you may want then to take a look at TTF_OpenFont source.
Suggestions:
1) substitute this code for TTF_Init():
if(TTF_Init()==-1) {
printf("TTF_Init: %s\n", TTF_GetError());
exit(2);
}
2) Make sure you call it before any other SDL_ttf functions.
If you're still having problems, please specify
your platform (Windows? Linux?)
how you installed your TTF fonts.
3) See also: https://www.libsdl.org/projects/SDL_ttf/docs/SDL_ttf.html
===================================================================
I'm sorry you're still having problems displaying fonts. A few additional suggestions:
1) I'm sure the tutorial you're using is very good. But you can't assume that just because you followed all the steps, you didn't inadvertantly miss something. To resolve the problem, you're going to have to "look beyond" the tutorial.
2) For starters, we need to confirm whether or not TTF_Init() succeeded. We must be able to see TTF_Init() return status, and TTF_GetError() messages.
Q: What is the return value of TTF_Init?
There are several ways you can display "TTF_GetError":
Start your program from a command prompt ("cmd"):printf("TTF_Init: %s\n", TTF_GetError());
Copy the error to a string and look at it under a debugger: char[80] msg; strcpy (msg, TTF_GetError());
Use a Win32 MessageBox to display the error in a pop-up: MSDN - MessageBox function
3) Make sure you have these .dll's on your filesystem:
libfreetype*.dll
SDL2_ttf*.dll
zlib*.dll
4) Look at the fonts you have installed on your filesystem, for example: C:\Windows\Fonts\*.ttf
See also SDL_ttf - Font directory/Where do fonts go?
PROBLEM SOLVED.
Thanks EveryOne for giving your time...
the problem was program was not recognizing font(candara )
so it copy pasted in my project folder.
I know this was already answerd but i ran into a similar problem with SDL2_ttf under Visual Studio 2015 and want to share my solution to help maybe others in the future.
My problem was that when i started my SDLe application that used SDLe_ttf it could not load the font that was placed in the same directory. But when i executed the the build executable manualy from the command line everything was fine.
I think the problem is that Visual Studio 2015 executes the build executable from a different directory and since i used only the font file name(Sans.ttf) it could not load the font because it treats it as a relative path.
My soultion was to just prefix the font file name with the execution directory which can be optained by calling SDL_GetBasePath.

Eclipse SDL build error: "The program specified in the launch configuration does not exist"

I've tried working some SDL on my set-up eclipse, and as I tried running it it gave me the following error:
'Launching SDL.exe' has encountered a problem.
The program specified in the launch configuration does not exist
I instantly went to another project to see if it builds, and it did. I also tried re-building, debugging the SDL project. I don't know if it's an error in code but just in case, this is the code:
#include "SDL/SDL.h"
#include <string>
#include <SDL/SDL_image.h>
SDL_Surface *load_image( std::string filename ) {
SDL_Surface* loadedImage = NULL;
SDL_Surface* optimizedImage = NULL;
loadedImage = IMG_Load(filename.c_str());
if(loadedImage != NULL) {
optimizedImage = SDL_DisplayFormat(loadedImage);
SDL_FreeSurface(loadedImage);
}
return optimizedImage;
}
I've googled it, and there's a duplicate question on stackOverFlow here, however it has 0 answers, not even a comment. There are no answers on google regarding this problem, so if you'd answer it, you'd probably solve hours of headaches for more people.
I encountered the same problem with eclipse in Ubuntu. Spent 30 minutes and finally got it fixed as below:
Click Project -> Properties;
Select run/debug settings, and then the current configuration on the right pane, click edit;
In the c/c++ application textbox, select search project, and then click the binary you want to execute for the current project.
On my system, the previous problem is due to incorrect default file name --- the linker generates abinary.exe but in run configuration it is "abinary".
Such tiny (but time consuming) problems should have been fixed by Eclipse developers, if they got well paid as MS or apple developers. Alas, free software?
Right click on your project in the Project Explorer and select Debug As -> Local C/C++ Application.
Check to make sure you didn't accidentally hit a space first, when typing in the project name. Also, if on windows use CMD or Linux ls -al your workspace and look carefully at the columns of names. Try executing your .exe from the command line. If it's not there, well, look at your build output more closely! :-)
I'm using Eclipse Neon.
In my case I was copy pasting a code to understand enumerator, but the code was faulty. As I built the project, the binaries disappeared and it said:
the program file in launch configuration does not exist
Then I tried a simple hello world program and it still gave an error. The actual problem was that the src folder had both the files (I don't know how). When I deleted the other one it built and ran successfully. Hope this helped.