Netbeans EXE not working when executed from Terminal - CentOs - c

I made Netbeans work environment with SASL. The sample codes get build and it also run properly from Netbeans. But when I try to run my exe from Terminal it is not working. The error says as below:
./cppapplication_1: error while loading shared libraries:
libanonymous.so.2: cannot open shared object file: No such file or
directory
I tried setting the PATH using the below Command :
export PATH=/usr/lib64/sasl2/:$PATH
Still I am getting the same error. Do I need anything extra to do?

You need to add the path to libanonymous to the enviroment variable LD_LOAD_LIBRARY.
Update:
To do so:
Locate the library, for example doing: find / -name "libanonymous.so.2" or by locate libanonymous.so.2
Add the path found like so: export LD_LOAD_LIBRARY=$LD_LOAD_LIBRARY:<path to lib>
Update 1:
From your comment to Anon's answer I see that the lib in question is located under /usr/lib64/sasl2/.
So you might like to set LD_LOAD_LIBRAY path like so:
export LD_LOAD_LIBRARY=$LD_LOAD_LIBRARY:/usr/lib64/sasl2/
Update 2
This needs to be done in the same shell that later then executes the program needing the libraries (cppapplication_1).
cd <dir for cppapplication_1>; export LD_LOAD_LIBRARY=$LD_LOAD_LIBRARY:/usr/lib64/sasl2/; ./cppapplication_1

You can also try this.
ldd <name of executable>
You will see dependent libs and their expected paths. See if the lib is present at the path executable is expecting.

Related

Cant find project for PackageCompiler

I am trying to create an executable using PackageCompiler.jl. However, whenever I run the command
create_app("src/UnsteadyFlowSolvers.jl","UNSflowCompiled")
I keep getting the error
ERROR: could not find project at "C:\\Users\\Matthew\\OneDrive - Mississippi State University\\Research\\UNSflow\\Ramesh Live\\src\\UnsteadyFlowSolvers.jl"
This is the exact location of the file. For instance:
include("src/UnsteadyFlowSolvers.jl") ; UnsteadyFlowSolvers.julia_main()
works perfectly fine and generates the exact result I would like the executable to return. The Project.toml file is in the current directory if that matters. I have tried an alternate version of the package where the module file is not located in another directory to no avail.
Thanks
create_app(package_dir::String, compiled_app::String; kwargs...)
Compile an app with the source in package_dir to the folder compiled_app.
So the first argument to create_app is the package folder, not the .jl file. I'd suggest a ;cd .. to get outside your project folder, then
create_app("Ramesh Live", "UNSflowCompiled")

How do I link a compiled ".so" library with Scons?

I have an existing .so library (libgit2), and I would like to use this within a C program (the build system is Scons). I read through the entirety of the Scons documentation for "Chapter 4. Building and Linking with Libraries", but there is no mention of how to use an existing .so library. The only mention of .so in the entirety of chapter 4 is on the first page, and it is only about Scons using a .so file for output. How do I use an existing compiled .so library in Scons?
If you are using an sconscript then you should add a LIBS= arguments and a LIBS_PATH=.
if you want to directly add it to the build line, use -L for lib path and -l to link a lib.
You can find further information here: https://scons.org/doc/0.97/HTML/scons-user/x628.html
With help from the SCons Discord server and other places, I've gotten farther than when I first posted this question. I haven't solved my specific problem of using .so libraries with GDNative, but I think I've figured out the SCons side.
As of me posting this question, the SConstruct file was able to compile working code if I didn't use libgit2 and instead just printed out the text. With only the header included, my test call to git_libgit2_version compiled but didn't run, as Godot said undefined symbol: git_libgit2_version.
First of all, you need to add the named parameter for LIBS to your env.SharedLibrary or env.Program line. The lib prefix and .so suffix seem to be added automatically, I still haven't figured out how to make it point to libgit2.so.1.0.1 (so for now I have the library copied and named as libgit2.so, but I would like to have it point to libgit2.so.1.0.1 eventually instead). Also, the SCons team suggested adding LIBPATH, but this doesn't seem to actually do anything.
library = env.SharedLibrary(target=env["target_path"] + env["target_name"] , source=sources, LIBS=['git2'])
Then, the SConstruct file needs to have this magic line:
env['STATIC_AND_SHARED_OBJECTS_ARE_THE_SAME'] = 1
With the above code, ldd will report not found, and Godot will say Error: libgit2.so.1.0: cannot open shared object file: No such file or directory (I have no idea why it's asking for .so.1.0 instead of the .so or .so.1.0.1 file, and yes I tried copying and naming as libgit2.so.1.0 and that doesn't change anything either).
I also added this, which was suggested by another GDNative user.
env.Append(LINKFLAGS=[
'-Wl,-rpath,addons/git_for_godot/gdnative/linuxbsd'
])
With all of the above code, this seems to allow ldd and Godot to find the library just fine with a relative path (when running ldd you have to be cd'd into the project folder). I can run the project fine without any errors, but the project crashes immediately after opening, with no error messages printed. If I comment out the call to git_libgit2_version but keep the header included, the file does compile and run. Any time I try to call anything from libgit2 it causes Godot to crash without printing any errors. At this point I'm stuck and I don't know what I'm doing wrong.
I did try adding libgit2 to the Dependencies section of the .gdnlib file, but this doesn't seem to affect anything. Another thing I tried which didn't work is this line (+ variants on the extension) which append to the sources list passed as the named source parameter. I'll post it here for completeness, but for the moment I have this line commented out because it doesn't work:
sources.append(File("project/addons/git_for_godot/gdnative/linuxbsd/libgit2.so"))

libcap.so.2 missing while updating to GLIBC_2.29

I had problem with GLIBC version while executing an exe file compiled in c.
/lib/x86_64-linux-gnu/libm.so.6: version 'GLIBC_2.29' not found
I found that I was using GLIBC_2.27. I updated to GLIBC_2.29 as mentioned the post
Once I installed GLIBC_2.29, I set the library path using patchelf command like below,
patchelf --set-interpreter /path/to/newglibc/ld-linux.so.2 --set-rpath /path/to/newglibc/ myapp
Now I got a new error,
error while loading shared libraries: libcap.so.2: cannot open shared object file: No such file or directory
On checking for the file libcap.so.2 mentioned, I could see it is in the /lib/x86_64-linux-gnu/ path.
I am not sure how to set path for the libcap as I already set path to the glib.
Did I set the path in the wrong manner?. Is there anything I missed during the path setup in the above step?
NOTE : My Operating system is Ubuntu 18.01
I am not sure how to set path for the libcap as I already set path to the glib.
You can set multiple RUNPATHs like so:
patchelf --set-interpreter /path/to/newglibc/ld-linux.so.2 \
--set-rpath /path/to/newglibc:/lib myapp

Current directory in CLion

I use Clion 2016.1. For example, I run such code in the directory ~/CLionProjects/Tutorial:
#include <stdio.h>
int main() {
char * string;
string = "Hello, everyone";
printf(string);
}
Why does Clion go for this code to this directory?:
/home/ken/.CLion2016.1/system/cmake/generated/Tutorial-9a39f70/9a39f70/Debug/Tutorial
Hello, everyone
Process finished with exit code 15
How to make the programs running in "normal" directory ~/CLionProjects/Tutorial?
UPD
I want to read a "data.csv" file locates in the current directory (where main.c is). But CLion looks for it in /home/ken/.CLion2016.1/system/cmake/generated/Tutorial-9a39f70/9a39f70/Debug/Tutorial. How to make that CLion looks for data.csv in ~/CLionProjects/Tutorial?
If you want to appear your binaries in a folder you've specified, you need to tell it CLion by adjusting your CMakeLists.txt like this:
set(CMAKE_RUNTIME_OUTPUT_DIRECTORY ${PROJECT_SOURCE_DIR}/bin)
set(CMAKE_ARCHIVE_OUTPUT_DIRECTORY ${PROJECT_SOURCE_DIR}/lib)
set(CMAKE_LIBRARY_OUTPUT_DIRECTORY ${PROJECT_SOURCE_DIR}/lib)
Edit:
Somehow it seems that these options are not respected in the current version of CLion (2016.2). Therefore one might has to change the desired output directory via: Build, Execution, Deployment | CMake settings and set it there.
For CLion v2016.1 and earlier
To change build output path, open CLion Settings and go to Build, Execution, Deployment | CMake settings and set it there.
This is more an answer for the UPD question than the original. But the answers are related. .EXE is built into a folder that depends on the build options (debug, release, etc). An exe's default working directory is the folder where the exe is found. That is the folder where the program will look for data files, etc, unless you tell it to look elsewhere.
You can change the working directory for the exe with a runtime option. I made a YouTube tutorial for my COSC1030 (Beginning C++) students but the solution is the same for everyone: https://youtu.be/dTtZEAfh_LM

How do I run source code in a mac terminal?

Please please help me, I am a computer illiterate female looking to convert a group of (.cng files) into jpegs. I found a source code on a blog that instructs me to
Build it, then run it with something like this:
cng2jpg /path/to/images/199x/1990101/*.cng
Here is a link to the source code
Does anyone know how I can run the source code to convert the files?
Here is a link to the blog post for reference for what exactly I am doing
First, put the source code into a file named cng2jpg.c. Then open a terminal, navigate with cd into the directory where you placed that file and type
cc -o cng2jpg cng2jpg.c
This creates the program cng2jpg. You can execute it by typing
path/to/cng2jpg input_file.cng
where path/to/cng2jpg is the path where cng2jpg was generated in the previous step.

Resources