missing libnoise.dll prevents program from running - c++

I have made a project and linked the libnoise library to it, it runs fine when I include the files but as soon as I run this bit of code -
noise::module::Perlin myModule;
double value = myModule.GetValue (14.50, 20.25, 75.75);
std::cout << value << std::endl;
it throws me this error:
the program can't start because libnoise.dll is missing from your computer. Try re installing the program to fix this problem.
I already have the .dll in the same folder as the .exe and it should be linked correctly.
thanks in advance.

I say you were using Visual Studio. The IDE has the concept of 'working directory', which happens to be the directory the loader starts looking for dynamic libraries your executable might depend on.
Properly setting the WD to the directory in which the executable gets generated is the way to go.

Related

System error - "the code cannot proceed because .dll was not found."

I'm getting this error when I try to run my app:
I checked and there is no reason that I can see that it wouldn't be able to find libnlopt-0.dll. Here it is (note GlassModelCalcualator is the DLL that uses libnlopt-0.dll), in the GlassModelCalcualatorDLL folder:
and in the debug folder of GlassModelCalcualatorDLL:
I have a different program that has a console which uses GlassModelCalcualator.dll and that also has this issue. To fix that, I had to put libnlopt-0.dll in the Debug folder of GlassModelCalcualator.
I'm assuming this is not the same problem here since you can clearly see that libnlopt-0.dll is in GlassModelCalcualator's Debug folder.
Any ideas?
Windows will follow a hierarchical order when searching for dll's.
You could place your dll in the same directory as the exe or even in the Windows system folders (only if you're absolutely sure you want to keep this dll forever as there's no cleanup)
https://msdn.microsoft.com/en-us/library/windows/desktop/ms682586(v=vs.85).aspx

Executable error : Can't start program

After finishing my C++ program (on windows os using codeblocks)(using libcurl) when i try to launch the program from the executable it displays an error saying that i can't start the program because libcurldll is missing,reinstall program then retry. I don't think any line of code is needed here,it's just a configuration and logics problem,any ideas,would be great !
Please note that,running it from the codeblocks's console works fine.
Common issue with DLLs or SOs is that the executable needs to know where they are.
A common solution is to place the DLL library in the same folder as the executable:
Find the libcurldll file.
Find the folder containing your executable.
Copy the libcurldll file into the folder containing your executable.

Running a compiled executable in Xcode gives a different result from directly invoking the executable in the shell

The program uses OpenSceneGraph to generate an .osg file.
int main( int, char** )
{
osg::ref_ptr<osg::Node> root = createSceneGraph();
if (!root.valid())
{
osg::notify(osg::FATAL) << "Failed in createSceneGraph()." << endl;
}
bool result = osgDB::writeNodeFile( *(root.get()), "Simple.osg" );
if ( !result )
{
osg::notify(osg::FATAL) << "Failed in osgDB::writeNode()." << endl;
}
}
The code excerpt is from openscenegraph Quick Start Guide http://www.lulu.com/items/volume_51/767000/767629/3/print/OSGQSG.pdf
page 40
The program can be compiled and run in XCode.
But, it shows the following error:
Error writing file Simple.osg: Warning: Could not find plugin to
write nodes to file "Simple.osg".
Failed in osgDB::writeNode().
However, the compiled binary can be executed without error by directly running in the shell.(./program) And the program correctly generates the Simple.osg file.
This is not the end of story. It is most likely because xcode invokes the compile program differently from invoking it in the shell. So, I copy and paste two dependent libraries into the directory where the compiled binary resides. (In case who knows OSG, the two libraries are osgdb_deprecated_osg.so and osgdb_osg.so)
This time, the Xcode correctly runs the program without errors, generating the Simple.osg file.
Therefore, there are two questions.
1) Why the shell is able to locate the dependent libraries automatically whereas the Xcode cannot?
2) How to make Xcode work without manually copying the dependent libraries or via post compile copy options?
This is simply a matter of the shell PATH being different in the shell and in Xcode.
A lot of the time an IDE will let you specify what PATH is in use at executable run-time. Make sure it contains all the important entries the normal shell has.
OK. After several hours I finally get it resolved.
The reason why the libraries are loaded under the shell is because of the shell's default environmental variable settings in ~/.profile, so that the program can search the libraries with these variables.
As XenonofArcticus pointed out, xcode doesn't inherit the environmental variable settings in the ~/.profile so the program running under xcode cannot resolve the actual path of the libraries.
However, at first I copied those variables in the environmental variable settings in the xcode but it didn't work.
It turns out that the environmental variable settings in xcode is not expandable across different ones. e.g:
HELLO=123/hi
WORLD=$HELLO/enter
The second WORLD variable does not replace the HELLO defined previously into the path.
Therefore, I need to manually write like this:
HELLO=123/hi
WORLD=123/hi/enter

Trouble with OpenCv in code blocks

I have followed the official guide for setting up OpenCv in codeblocks.I did everything as in the guide.I succeded to compile one code of the samples of opencv but when I run I have an error that some .dll is missing.More precisely this is the error:The application can't start because libopencv_core242.dll is missing from your computer..Try reinstaling the application...The awkward thing is that this static library is present in the bin folder under build->x64->mingw->bin..
Any help would be appreciated.
Try to copy the dll into the folder containing the executable.
For a "cleaner" solution, it has been answered here (with libgcc) : The program can't start because libgcc_s_dw2-1.dll is missing
Basically, either you copy the dll containing folder into the PATH ENV, or you can try to link with the statically.

c++ boost library cannot open file

I tried to work with the boost library to read/write configuration files but I just don't get it.
I even can't run the example code from boost.org (5 Minute Tutorial)
http://www.boost.org/doc/libs/1_49_0/libs/property_tree/examples/debug_settings.cpp
I've downloaded the boost_1_49_0.zip package and unzipped it to my c++ program folder. The code compiles (TheIDE - U++) but it always says "Error: debug_settings.xml: cannot open file" which basically means that the program works, but runs into the exception.
I didn't change the code, I just copy and pasted it to get a working example which I could try to understand then. But I don't even get this one to work. (Since it's exactly the same as in the link, I don't paste the code here... unless you think it's better.)
Please help me... or point to a different way to store variables in a file with some kind of structure (I wan't to learn a way that works for windows and linux, because some of my apps are cross-platform.)
Thanks.
EDIT: debug_settings.xml is in the same folder as the .cpp file
EDIT2: Working now, the debug_settings.xml is now in the folder where the executable is stored. (in my case, U++/TheIDE it's C:\upp\out\MyApps\MINGW.Debug.Debug_Full.Sse2 for debugging)
The configuration file would need to be in the working directory of the executable when it's running.