octave libs not linking properly - c++

I built octave-4.4.0 and created binaries and libs in my own path instead of /usr/local, and i am able to link my cpp program through CMakeList and its working fine.
the same octave folder when i shipped to different ubuntu in another machine and try linking the cpp program as same way through CMakeList i am unable to do execute the binary. i am getting this error. I moved octave by tar (with symlink)
error: feval: function 'pkg' not found terminate called after throwing
an instance of 'octave::execution_exception'
please help me to resolve this

Related

Is there anyway to copy linked libraries directly into the executable?

I have a C++ project I'm compiling with CMake. One of the dependencies is LevelDB which I have installed using homebrew. In my CMakeLists.txt I have the following line:
target_link_libraries(test /usr/local/Cellar/leveldb/1.23/lib/libleveldb.dylib)
The binary that is generated works fine on my computer but it crashes when I run it on a computer that does not have libleveldb installed, stating that the library could not be found.
Is there any way that I could simply bundle the leveldb .dylib file into the executable itself -- this seems like the most reasonable way of making a binary that is simple for the end user to download and run.

How to link fftw3 on a macOS using CMake?

I have the following fftw3 header files under /usr/local/include:
Further, I have the following fftw3 static libraries under /usr/local/lib:
However, when I try to compile my file using cmake and running make afterwards, I get the following errors:
What I find particularly odd is that when compiling the individual *.cpp files, I get no error despite the fact that these files use fftw_malloc and other functionality from fftw3.h.
I'm using gcc and g++ version 10.2.0. I configure my CMake file using cmake -DCMAKE_CXX_COMPILER=g++-10 -DCMAKE_C_COMPILER=gcc-10.
I configured fftw3 through the download on the fftw3 website and running ./configure, make, sudo make install in that order. As mentioned before, the files seem to have been installed in the correct place. I also tried the same with homebrew and MacPorts and ended up with the same result.
I'm also using findFFTW. Without this, even the *.cpp files don't seem to compile properly. Further, even findFFTW claims to have found the FFTW3 library, giving the following output during the configuration of the make file:
-- Found FFTW: /usr/local/include
Finally, my target link libraries are set to the following in the CMake file:
target_link_libraries(cartogram CGAL::CGAL Boost::program_options fftw3)
Is there any way I can solve the error I get? (ld: library not found for -lfftw3)
Edit: On a side note, the exact same cmake file works perfectly find on Ubuntu, Linux!

Using SFML in Eclipse (Linux)

I'm trying to get SFML (www.sfml-dev.org) running under Eclipse which is running on Ubuntu 16.04, my c++ compiler is nvcc as this is a cuda project. I have my includes and libraries set up as follows:
The project builds fine, but when I run it I get the error message:
error while loading shared libraries: libsfml-window.so.2.4: cannot open shared object file: No such file or directory
This is weird, because the file exists (/home/timo/cuda-workspace/CudaTutorial/SFML/lib). Does anyone know how I can resolve this issue?
Well, in the end creating a conf file did it:
gksudo gedit /etc/ld.so.conf.d/sfml.conf
/lib/SFML/lib
sudo ldconfig
(I put the SFML build into lib in case I want to use it in another project).

SFML headers not found when compiling using CMake and GCC (MacOS Sierra)

I have been trying to use SFML in a CMake project, specifically the header SFML/Audio.hpp. I installed SMFL using Homebrew, and both the .dylib-files and the headers should be located correctly, in /usr/local/lib and /usr/local/include, respectively.
Now running CMake works fine, telling me that it has Found SFML 2.4.2 in /usr/local/include.
However, when compiling the project (using make), I get the following error:
/path/to/project.hpp:12:10: fatal error: 'SFML/Audio.hpp' file not found.
Does anyone know why this is happening?
Note: Compiling works fine for colleagues of mine using the same CMake- and source files on various Linux operating systems.
This sounds like you simply forgot to add SFML's include directory. On Linux, they probably install SFML to some system path where GCC (or Clang) look by default, so they don't need any additional CMake directives.
Luckily, fixing this is pretty simple.
Add the following line to your CMakeLists.txt somewhere before defining targets:
include_directories(${SFML_INCLUDE_DIR})
The variable SFML_INCLUDE_DIR is populated when you successfully call find_package(SFML...).
While you're at it, you might also want to ensure to link to the proper library files in the correct order:
target_link_libraries(myTargetName ${SFML_LIBRARIES} ${SFML_DEPENDENCIES})
Again, both variables are populated automatically.

{OpenCV Error} error while loading shared libraries: libgfortran.so.1: cannot open shared object file: No such file or directory

SYSTEM: Ubuntu 16 LTS
Compiler: g++
I)
I have built OpenCV from source. I followed these steps:
1.) Downloaded OpenCV source / code (3.1.0)
2.) Unzipped it
3.) Used cmake with default settings (cmake ..) because any other options were throwing up make errors later on
4.) make -j4
5.) successful install
Now when I compile from the command line using
g++ -o testwav wavfil.cpp `pkg-config opencv --cflags --libsopencv`;./testwav
I get the following error
./testwav: error while loading shared libraries: libgfortran.so.1: cannot open shared object file: No such file or directory
This happens for all c++ files using OpenCV only. Normal c++ files (using only standard c++ in-built libraries) work fine though.
On doing some research I cant find anything specific to this error, but I can find a solution to a general case for it, i.e., when an .so file is not found (means your libraries are missing or you dont have access permissions or need to use sudo to run the command).
I think it is because of OpenCV pointing to the wrong libraries. I had come across something about modifying .pc files but I cant seem to find it right now. I may be wrong about this.
II)
I need help setting up the OpenCV with geany, does anyone have experience with this?