Linking against dynamic libraries [CrossCompiling][Resolved]



  • Good Evening,

    How can I link against dynamic libs when cross compiling programs for the Omega2+?
    Is there some guide on how I can do it?

    I managed to compile the opencv sources using the toolchain
    and copied the generated lib files (shared .so) into the /usr/lib directory of the Omega2+.
    It seems to work since I can run the create_samples and create_traincasscade binarys to
    produce the casscade detecting files used to detect objects on pictures.

    At the moment I am trying to cross compile a simple sample program that only opens an image for processing it but I am not able to build the binary because there seems to be an error when linking everything together.

    I tried building it using this command:

    mipsel-openwrt-linux-musl-g++ -Wall -I/home/test/omega2 -L$LD_LIBRARY_PATH -o test Test1.cpp

    LD_LIBRARY_PATH is set to the folder where I have put the cross compiled library files of opencv
    and
    /home/test/omega2 is the path where the headers are.

    Executing it will generate these errors:

    Bild Text

    I dont really know what to do :/

    Thanks for any help / guid / lecture ...



  • -L$LD_LIBRARY_PATH

    -L specifies a search directory, but you still need to tell it what object or library to look for

    ie, you need a -lwhatever which it would have searching for something like "libwhatever.something" or to explicitly list the library file you want to link against along with your objects.

    Also depending on how you have set LD_LIBRARY PATH, your shell may or may not substitute it with the syntax you are using, so try echo $LD_LIBRARY_PATH and see if you get a sensible result.

    What you are trying to do it not simple, I'm only trying to address the immediate surface issues, the actual goal will probably present many more challenges.



  • Could you give an example for

    -lwhatever

    Ive tried it like this with no success

    Bild Text

    So I think this is not the right way.

    I know that this is a very complex thing and all but for linux beginners :D
    The whole stuff with the make system and the compiler system under linux with the trillions of parameters and stuff that have to be set. :D

    Thats why im asking here cause I was not able to get it working after about 5 hours of research and hundrets of failed attempts.

    Before this linking problem I had the problem that the system was not able to locate the headers but at least that I was able to fix :D



  • -llibopencv_world.so

    -l does not take a filename, but rather a library name, so the correct argument would be -lopencv-world or perhaps -lopencv as I'm not entirely sure if "-world" is coming from the opencv suite or from a library naming convention on the system. The "lib" prefix and whatever appropriate suffix will be automatically added behind the scenes.

    If instead you want to specify an actual (hopefully appropriate) filename such as "libfoo.so" then just do so, without the -l



  • Ohh my gosh :D
    I think it finally worked
    At least I have an binary now :dancer_tone3:

    open_world

    was the rigth name.

    Thank you so much really you saved my almost ended day :D

    Now I only need to test it on the omega

    Before I end this
    do you have furth information about this compiling system
    like good websites or anything else so that I can read myselfe into this whole stuff.

    I ve found quiet a lot myself but I more is always better :D



  • @Adrian-Rix Only thing I could suggest beyond just general familiarity with Linux and GCC is checking writeups about both LEDE which is the Omega stack's direct parent, and also OpenWRT, which is in turn LEDE's parent.

    OpenWRT does typically use a different C library than LEDE, but while the linked results are thus incompatible the methods to generate them are mostly parallel.



  • Ok thank you

    (Binary worked :3 now I can do pretty awesom stuff :D)


Log in to reply
 

Looks like your connection to Onion Community was lost, please wait while we try to reconnect.