I have a C++ project on eclipse which compiles and runs fine from eclipse, but when trying to run it from the terminal inside the workspace directory, i get the following error :
./my_project: error while loading shared libraries: libstdc++.so.3: cannot open shared object file: No such file or directory
What can be the problem?
It's likely that Eclipse is adding libstdc++.so.3 to your LD_LIBRARY_PATH environment variable when you run it inside of eclipse, but it isn't there in your regular shell.
Check to make sure LD_LIBRARY_PATH is defined and includes all the necessary libraries your program needs and you should be good.
Related
I'm using Ubuntu and I have written my c++ code in Eclipse Neon.
My workspace contain 4 projects. The main project is called BaseCppProjectRun (it contains main.cpp file) and I have other projects with these names: Encoders, frmwrk, NetworkLayer - the BaseCppProjectRun using each one of them.
If I running my program directly from eclipse everything works.
But I want to running my program from terminal - and I can't.
Because When I'm trying to run my progrm like this:
root#ubuntu:/builds/BaseCppProject/BaseCppProjectRun# ./Debug/BaseCppProjectRun
I'm getting this error:
./Debug/BaseCppProjectRun: error while loading shared libraries: libfrmwrk.so: cannot open shared object file: No such file or directory
As I said before, if I'm running it directly from eclipse everything works.
How can I run my program from terminal?
How is Linux supposed to know where to find libfrmwrk.so, if you don't put that either where it normally looks nor tell it where it can be found.
Eclipse seems to set up the paths the runtime linker looks into so, that when your program is loaded, the runtime linker knows where to find your libfrmwrk.so and so on.
You'll either have to
install these libraries (.so's) so that they are found in default locations, or
set LD_LIBRARY_PATH to contain all the folders to look into.
I haven't worked with Eclipse CDT in ages, but you can by now probably export some project formats that allow you to easily install things.
Another thing: It seems you're running software you're still debugging as root: That is a terrible idea, and if it can be avoided, avoid it.
I finally figure it out!
Refere to Marcus Muller's answer + my steps this is how I have fixed it ( all steps via terminal):
Create new directory in my workspace directory and called it libs.
In each one of your projects do: right click > c/C++ Build > Build Steps (tab) and in Post-build steps paste this:
cp ${BuildArtifactFilePrefix}${BuildArtifactFileName} "${WorkspaceDirPath}/libs/"
This code copy the so files directly into your libs directory when you compile your program.
And finally, in your terminal execute this:
export LD_LIBRARY_PATH=/builds/BaseCppProject/libs/
Now you can run your program via terminal.
Yet another shared library question.
I am trying to run a code that depends on a package which resides in a separate workspace, /home/foo/opt/bar-workspace.
I can build the package inside this bar-workspace with make build and run the executable, but I want to use the package in my ECLIPSE workspace, /home/foo/workspace.
I am using Release configuration. The code compiles, but when I run it in ECLIPSE, I get the error
libeigen-cdd.so: cannot open shared object file: No such file or directory
In ECLIPSE IDE, libeigen-cdd.so path is added to Library Search Path(-L) and eigen-cdd is added to Libraries(-l). I also tried adding the path of libeigen-cdd.so as an environment variable LD_LIBRARY_PATH, which resides in /build/release/src of the package, but it did not help.Plus, even if I succeed in this, there are other .so libraries the code depends, so I wonder after I succeed in this, how can I add all those .so as environment variables, as they all reside in seperate locations.
Thanks.
I wrote a program in C/C++ and compiled it using Cygwin. When I ran the compiled file, I receive an error about a missing library.
Cygwin is like a simple framework: With every program you build you have to include the library cygwin1.dll.
Important note: Downloading the library online might be risky as it can be a virus.
To fix the issue:
1. Go to your cygwin directory. Usually that is C:\cygwin or C:\cygwin64.
If you don't know where cygwin is, download the setup file and run it. The installation path the installer suggests is the Cygwin installation location.
Tip: Don't use a directory to put cygwin in that includes spaces (" ") as it will be easier to run programs with command-line parameters.
2. Copy the file. It should be in <Drive>:\cygwin\bin\cygwin1.dll.
3. Copy the file to your program folder, the same directory as your exe file.
Your program should run without throwing an exception.
I have created a program in Codeblocks (wxWidgets Application) I have compiled it and it runs perfectly when executed from the codeblocks interface ....however when i go into the release folder and run the executable it gives me *.dll file errors :/
How do i make the program ?
There's a good chance that Code:Blocks has a default setting for the executable path that includes the path to the libraries. As Windows finds the DLLs using the PATH environment variable this will ensure that your application works inside CodeBlocks.
However in order to run it outside CodeBlocks you'd need to either copy all the dependencies into the directory that holds your application or you'll have to set your PATH variable to include the directories that hold the dependencies.
I just installed MinGW using the automatic installer MinGW-get-inst that I found on their website. I am using eclipse to write my C++ programs. My code compiles fine, and I get a .exe file. However, when I try to open this executable, I get the error that libgcc_s_dw2-1.dll is missing from my computer. I have located this file under MinGW\bin so I know it exists.
This is for all C/C++ programs, I am testing with a simple hello-world program. Any fixes?
Thanks
You need to ensure that the MinGW\bin directory is on the path from where you are running application.
If you were running the resulting executable, say a.exe for example, from a CMD window do the following to check that MinGW\bin is on the path.
set PATH
At this point you will see the current value for the command path. Make sure the MinGW\bin directory is in it somewhere.