JNI system.loadlibrary problem - native C++ dll using C library - c++

I have a pretty annoying compiling problem.
I am trying to do a System.loadlibrary on a C++ DLL in VS2010, which in turns uses a C DLL compiled in VS2008.
The error I am getting is:
java.lang.UnsatisfiedLinkError: The application has failed to start because
its side-by-side configuration is incorrect
This occurs whenever my C++ DLL tries to do a call to a function in the C DLL. Both compiles just fine, and both are in a folder accessible by Java Applet.
Is this possible to solve somehow? Do you need any more info?

You should try and use the dependency walker on your DLLs.
From the side-by-side error I assume that one of the c runtime redist packages or one of the noredist packages is missing.
But the dep walker should show you this.
If this does not help you can get some more information from the event log of Windows since side by side errors are logged there, or you need to use sxstrace for more info.

Have you installed the runtimes of VC2010 and VC2008?
Additionally you have to make sure the manifests of both DLLs are correctly configured so that the correct version of the used library can be loaded.
See also: http://msdn.microsoft.com/en-us/library/ms235342.aspx

Related

log4cplus cannot find AppenderFactory

I regularly use log4cplus, but I have encountered a new problem.
I have a windows application which uses a dll (LoadLibrary)
They are built on different compilers, but use dlls with the same name (including log4cplus.dll) also built on different compilers. The app and all the dlls it uses are built in one environment (vs2008). The dll and all the dlls it uses are built on another environment (vs2013).
LoadLibrary failed until I changed the application to pass the LOAD_WITH_ALTERED_SEARCH_PATH flag to LoadLibraryEx, which appears to allow the dll to load its own dependencies successfully, except now I get these runtime errors
log4cplus:ERROR PropertyConfigurator::configureAppenders()- Cannot find AppenderFactory: log4cplus::RollingFileAppender
log4cplus:ERROR PropertyConfigurator::configureAppenders()- Cannot find AppenderFactory: log4cplus::ConsoleAppender
log4cplus:ERROR PropertyConfigurator::configureLogger()- Invalid appender: ROLLING
Logging works for all applications built in either environment.
Logging also works for this app and dll both built in the same environment.
I changed the dll to statically link log4cplusS.lib, but I still get the same errors.
First off, use the same compiler for everything. It is basically impossible to make things work when using different compiler versions. Once you are compiling everything with the same compiler, try to solve other problems, if any still remain.

How to run a Qt executable file dependent on .dll files?

So I've finished my Qt application, and I need to implement testing using the Squish testing application (first time using). Apparently I require a working exe file, but I can't get the executable to run. I added all the .dll files to the same directory, only to get the error:
Prior to that I was getting errors saying that XXXX.dll is missing, but like I said, I've added them to the directory. I've tried using both debug and release builds of my project with the same results. I've also tried building a stand-alone executable, but that has it's own problems (one thing at a time). The program runs great in Qt Creator and VS2013...just not on its own.
Any solutions to this?
EDIT:
From Dependency Walker...
0x7B is the error code for invalid image format.
You're either trying to run a 64-bit application on a 32-bit system, or linking to a 64-bit library (ie you copied the wrong DLLs).
Or your binaries are just corrupted.
If you run the application standalone (i.e. not from Qt Creator) you also need the Qt library DLLs. which one you need, depends on the components you are using.
Dependency Walker is also a useful tool to find missing DLLs under Windows.
As for me it seems that something is missing. Qt on windows has the script windeployqt, it will provide all needed dependencies. See documentation http://doc.qt.io/qt-5/windows-deployment.html about use of this. On Windows you will be able to run cmd with loaded qt environment variables ( on Windows 7 see under windows applications menu - it will be available if qt is installed ). As Simon stated Dependency Walker is good tool.

How to get AssImp to work properly?

I have been trying to do this for about a week with no good anyhow. I am building a .dll (UNDONE Engine .dll) that depends upon Assimp to load models. The .dll compiles and links with no problems at all, but when I try to use it with some application, I get the following error:
'Test_Game.exe' is the application I made that uses the .dll library that is using assimp.
I downloaded assimp from the sourceforge repository. I got the version 3.0 SDK for windows, installed it and I did do whatever was nessesary to get the project linked.
Here is how the directory with the .exe looks like:
I have included the right bitness of the lib, that is 32 bit versions.
Why does it not work? Is there some internal bug inside Assimp which prevents me from using it? Or is there something I am missing? Is it causing problems because i am using it from a dll? Can you please get me through the steps to install and use properly? I use visual studio 13.
EDIT
After running Dependency walker over my exe, I get this:
And I have very less idea of what that means, but, just guessin, does it mean that assimp.exe has some undefined functions?
What depends.exe is telling you is that undone_engine.dll's import table includes an entry for AssImp.exe, which includes an entry for the function ??0Importer#AssImp##QAE#XZ and some friends. Windows then expects to find the functions ??0Importer#AssImp##QAE#XZ and friends in the export table of AssImp.exe.
Depends is also telling you that there is nothing in the export table of AssImp.exe, which is unsurprising, as exe's seldom export anything. Interestingly, it's also telling you that assimp.exe imports assimp32.dll.
You're probably intending to link with assimp32.lib, not assimp.lib. (#Dirk hints at this in the comments; I suspect he's nailed it.) Do you have an assimp32.lib that you could try linking against instead of assimp.lib?
I wonder if AssImp32.dll imports code from the static library ButtGremlin.lib? /twelveyearold

REGSVR32: the module "xxxxx.dll" failed to load ... dependent assembly could not be found

I'm having an issue with regards to registering a *.dll under Windows 7 x64.
I've tried placing the *.dll in both, C:/Windows/System32 and C:/Windows/SysWOW64 and attempting to register with "regsvr32 xxxxx.dll" under an elevated command prompt. I also tried to register it from a seperate directory. It responds with the following error:
The module "xxxxx.dll" failed to load.
Make sure the binary is stored at the specified path or debug it to check for problems with the binary or dependent .DLL files.
The application has failed to start because its side-by-side configuration is incorrect. Please see the application event log or use the command-line sxstrace.exe tool for more detail.
The EventLog notes:
Activation context generation failed for "C:\(path-to-dll)
Dependent Assembly
Microsoft.VC90.ATL,processorArchitecture="x86",publicKeyToken="1fc8b3b9a1e18e3b",type="win32",version="9.0.21022.8" could not be found.
Please use sxstrace.exe for detailed diagnosis
N.B. I have installed both x86 and x64 Microsoft Visual C++ 2010 Redistributables.
An interesting aside is that I attempted to register the same *.dll on my work x64 Windows 7 laptop and it registered as expected. I guess this leans towards the fact that some kind of C++ dependency is missing / ATL related?
If anyone could help point me in the right direction or shed any additional light on the matter; i'd be more than grateful.
Regards.
This is almost certainly due to a missing dependency. Use a tool like Dependency Walker to find the required dependencies of the DLL. Or, if the DLL is supplied by a third party, read their documentation which should specify the required dependencies.
Note that Microsoft.VC90.ATL indicates version 9 of MSVC which is VS2008. So you would need to install the MSVC 2008 runtime to meet that dependency. It looks like you installed the MSVC 2010 runtime by mistake.
Finally, please don't put files into the system directory. It belongs to the system and should not be modified by you.
Dependent Assembly
Microsoft.VC90.ATL,processorArchitecture="x86"
This indicates missing Visual C++ runtime module (see Visual C++ Libraries as Shared Side-by-Side Assemblies). It is available as redistributable installer (this is presumably the one you need; x86 variant), which you need to install before registering your DLL (which is in turn dependent on missing component).
There is also another reason why this fails. I just ran into this myself. I was using API methods that did not support Windows 7, such as PathCchRemoveFileSpec which I had to update to the older, deprecated PathRemoveFileSpec. I used Dependency Walker to verify this was the cause. Dependency Walker lies a bit. If you look at my screenshot (below), the red section shows the actual problem - the methods it wasn't able to resolve in DLLs it has, etc. - but the blue shows DLLs that are actually not the problem at all (these DLLs exist). Since Dependency Walker is so old, it lies a bit (its outdated, it thinks something isn't available from time to time), but usually, it also tells the truth...you just have to scroll down a bit from the top left pane like I did. Note to self: please scroll down next time. Anyways, once I ditched pathcch.h, everything worked on 7. Happy coding.
I got relieved from this error message. In my binary path, I had a SPACE. Just replaced the SPACE with UNDERSCORE(_). It worked for me.
as i have also faced the same issue while registering the x.dll through Regsvr32,there is one of the possible reason is that x.dll might be unmaged dll.
To use unmanged dll export function in the dot net code, you have to use Dllimport.

What would cause a C++ .exe and .dll to only work on the machine it was built on?

I am using VS2010 and am working with this project.
http://www.codeproject.com/KB/audio-video/Asio_Net.aspx
Initially, I downloaded the demo binary and it would crash on my machine. After reading through some of the comments, it said to download the source, build it, (after getting the ASIO SDK), and it should work on your machine. This is correct, after building it in VS it works, on that machine.
When I moving the rebuilt .exe and .dll to a different machine, it crashes with the same error as the originally downloaded demo binary. So I am unsure what would cause this. How can I make this C++ binary work on any machine??
I am a C# developer and most of the code is c++, so am kind of at a loss.
BTW, here is the error message:
"Unhandled Exception: System.IO.FileNotFoundException: Could not load file or ass
embly 'Bluewave.Interop.Asio.dll' or one of its dependencies. The specified module could not be found.at BlueWave.Interop.Asio.Test.TestConsole.Main(String[] args)"
EDIT: Answer found here:
http://msdn.microsoft.com/en-us/library/8kche8ah(v=VS.100).aspx
Use dependency walker to find which .dll is missing.
Assuming you mean that you've included this dll - Bluewave.Interop.Asio.dll then there only a couple of explanations I can think of:
One of it's dependencies is missing from the machine. You can use something like Dependency Walker to find out what's missing.
The dll is not in a location the exe can see (unlikely but you never know).
The missing dll may well be part of the VC++ runtime and not necessarily part of Asio.
What else is in the output folder on the machine where you built it?
I've downloaded that demo project from Code Project and I think the most likely cause of the problem is that the Visual Studio C++ 2008 runtime dependency is missing. Solve this by installing the runtime redistributable package on the machine.
Note: I checked the dependencies of this DLL using Dependency Walker. You can even run this in profiling mode so that it will tell you at runtime exactly which dependency is proving troublesome.