I copied only the Octave lib and include folders from the original build folders and pasted into another (toolbox) folder. The toolbox folder has C++ code that has embedded Octave functions. The LD flags and C flags for compiling the code are-
LD flags- "-L/path/to/lib -loctave -L/path/to/lib -loctinterp -Wl,-rpath=/path/to/lib/folder"
I flags- "-I/usr/include/scilab -I/path/include/octave-4.0.3 -I/path/include/octave-4.0.3/octave/"
When I compile the C++ code, I get the error
libtool: link: warning: library `/home/fossee/Desktop/FSOIToolbox/thirdparty/linux/lib/x64/octave/4.0.3/liboctave.la' was moved.`
libtool: link: warning: library `/home/fossee/Desktop/FSOIToolbox/thirdparty/linux/lib/x64/octave/4.0.3/liboctinterp.la' was moved.
/usr/bin/ld: cannot find -liboctave.la
/usr/bin/ld: cannot find -liboctinterp.la
I understand the issue is due to copying the lib files.
How do I include .la files in the flags so that the error is resolved for my system?
I need this code to work on any system. How do I include the Octave lib and include folders in the toolbox thirdparty folder such that it works on any system. When I go through the liboctave.la file, the paths in the file refer to my system. I need to make this general.
The source code is available here- https://github.com/shamikam/FOSSEE_Scilab_Octave_Interface_Toolbox
The Octave files are in thirdparty folder.
Related
I'm compiling a c++ program using g++ and i am using two libraries called libsdl2-dev and libsdl2-image-dev
I installed both these libraries in my ubuntu machine with the commands
apt install libsdl2-dev libsdl2-image-dev and when I compile the program everything works fine. Then I copied these libraries from /usr/lib/x86_64-linux-gnu/ to my working dir with the binary file to be able to give this folder to someone else.
The problem comes when the user that hasn't installed these libraries tries to open my program by writing ./main (the binary file). Since he hasn't installed these libraries he would get an error like "can't open shared object: no such file or directory".
This happens because the binary file looks for these libraries in /usr/lib etc...
What i need
I need that my binary file looks for these libraries in the same folder,and not in /usr/lib/x86 etc.., from what I read I have to do something like rpath
The IDE used is Sublime Text and the syntax used to compile all my files is this:
g++ -c src/*.cpp -std=c++14 -m64 -g -Wall -I include && g++ *.o -o bin/debug/main -lSDL2main -lSDL2 -lSDL2_image && ./bin/debug/main`
Structure of folders
I got the project dir with and inside that i got 4 more directories, each one called: bin (with the debug subdirectory, where we got the final compile), include (with hpp files), res (with all textures), and src with all cpp files to compile, the other files are project files and .o files
I'm using Ubuntu 20.04-2 LTS and the same is for the other user's PC
Thanks in advance for any help!
That's because the dynamic linker loading runtime dependencies looks for them in some specified locations, which are "by default" your system library directories (where those libraries got installed by apt).
The other user should ideally install those libraries too (which could be done "automatically" if you build a .deb package with proper dependencies)
Otherwise you would have to change the runpath of your program by adding -Wl,-rpath='$ORIGIN', which makes the dynamic linker look for dependencies just where the binary is located.
$ORIGIN here is a special variable meaning "this executable" which is what you wanted to achieve.
see rpath
and A description of RPATH $ORIGIN
I found a way to resolve!
I used the program patchelf to add an rpath to my directory (linked to the binary file) now everything works
use ldd ./bin/debug/main to check the library
export LD_LIBRARY_PATH =$LD_LIBRARY_PATH:"your library path"
run the program,if this is not work. use patchelf to change the rpath to you r library
I have an SFML application I would like to compile it for Windows from Linux. Up until now, I've compiled with g++ and -lsmfl-graphics -lsfml-window -lsfml-system
Now I've installed g++-mingw-w64-x86-64 and I have to compile with '/usr/bin/x86_64-w64-mingw32-g++'
Now it says SFML/.../...hpp: No such file or directory
I read that I need to give it the location of the .so files of the library.
I've never seen those, where are those typically? SFML is installed in /usr/local/include/SFML
-L'/location???'
L'/usr/lib/x86_64-linux-gnu'
L provides the search directory where the .so files are located.
The SFML .so files just happen to be in /usr/lib/x86_64-linux-gnu
Then you use your library flags normally
-lsfml-...
-I: path to header file *.h, *.hpp (i upper)
-L: path to library (*.so *.a)
-l: library name (L lower)
g++ -I /path/to/header -lmylib -L /path/to/library
Now it says SFML/.../...hpp: No such file or directory
compile error because header file not found. fix it first.
When I am including the asio header:
#include <boost/asio.hpp>
I got the error:
undefined reference to boost::system::generic_category()
So I read that I had to link to boost_system which I did. But now it gives the error::
cannot find -lboost_system
Why can it not find boost_system. I'm using Codeblocks on Windows.
boost is a separate library that needs to be installed on you building machine.
Please follow these instructions to install:
http://www.boost.org/doc/libs/1_55_0/doc/html/bbv2/installation.html
http://www.boost.org/
After installation your application needs to be able to find it if it is not installed in a standard location.
you will need to supply the header and lib directories to the build process.
g++ source source.cpp -I/path to boost headers -L path to boost libs -lboost_system
Look inside you libs directory to be sure that you have boost_system. It is possible depending on the build that you may only have boost_system-mt
I am trying to use SDL2_mixer for sound but I get these errors
undefined reference to `Mix_OpenAudio'
undefined reference to `Mix_LoadWAV_RW'
undefined reference to `Mix_PlayChannelTimed'
According to Lazy Foo's tutorials undefined references mean that I have something wrong in my linker settings how every I believe I have it right. It goes as follows:
-lmingw32 -lSDL2main -lSDL2 -lSDL2_mixer -lSOIL -lOpenGL32
Additionally the search directories for the header and lib files are correct (I have triple checked) and the .dll is in the same directory as the executable. The code files also have the corresponding #include directories. There are not any more things I can think to try so any help is appreciated
I was trying to compile a 64-bit Mixer with the 32-bit SDL.
I think you've the SDL mixer runtime binaries alone extracted into a directory. However, for compiling and linking you need the development libraries which has the stub library libSDL2_mixer.dll.a file necessary for linking.
In the SDL_mixer page, you've two sections: Runtime Binaries and Development Libraries. In the second section, download SDL2_mixer-devel-2.0.0-mingw.tar.gz (MinGW 32/64-bit). Extract it to a directory and add the (/lib) directory path to C::B and pass -lSDL2_mixer and it should link just fine.
When you run the executable, make sure SDL2_mixer.dll (from the \bin directory of the download) is present in the same directory for runtime dynamic linking to work.
I am writing a C++ program in Linux with NetBeans. I am having difficulty setting it up to use external sources/shared objects. I have the .so files from the compiled external package and the source files that go with it.
So far I have:
specified for the project to include all the source and header file directories (under Project properties->Build->C++ Compiler)
specified the .so files that correspond to the external source code (under Project properties->Build-Linker)
When I try to declare an object defined in the external sources NetBeans does not give me any syntax errors and even auto-completes the object name for me. However, when I build the program I get an error saying "undefined reference to" that object.
Am I doing something horribly wrong?
EDIT:
In response to quamrana's question, this is one of the output lines in the console when it attempts to build.
g++ -o dist/Debug/GNU-Linux-x86/JAUSTester build/Debug/GNU-Linux-x86/MainScreen.o build/Debug/GNU-Linux-x86/main.o build/Debug/GNU-Linux-x86/moc_MainScreen.o -L/usr/lib -Wl,-rpath /usr/local/lib/active /usr/local/lib/active/libcxutils.so -Wl,-rpath /usr/local/lib/active/libjauscore.so -Wl,-rpath /usr/local/lib/active/libjausextras.so -Wl,-rpath /usr/local/lib/active/libjausmobility.so -Wl,-rpath /usr/local/lib/active/libtinyxml.so -lQtGui -lQtCore -lpthread
The .so files I want to include are the ones specified there in /usr/local/lib/active/.