Cross compiling for RPi - error while loading shared libraries The 2019 Stack Overflow Developer Survey Results Are InMissing libcofi_rpi.so on host machineMongodb cross compilation on linux for Raspberry Pihow to install cross-compiled OpenCV's libraries on raspbery piCross Compiling Protobuf for Raspberry PiCross-Compiling kernel can't find gccEmbedded Xinu for RPiCross Compile Error Using arm-linux-gnueabihf-gccWhen I compile with arm-linux-gnueabihf-g++ version 4.7, I get error while loading shared libraries: libstdc++.so.6Is it possible to fix the “cannot find -lgcc” and “cannot find -lgcc_s” error messages when using arm-linux-gnueabihf-g++ as a linker?What's causing these crashes after cross-compiling?

In microwave frequencies, do you use a circulator when you need a (near) perfect diode?

How to manage monthly salary

How to change the limits of integration

Why is it "Tumoren" and not "Tumore"?

How was Skylab's orbit inclination chosen?

How can I fix this gap between bookcases I made?

Return to UK after being refused

Why do I get badly formatted numerical results when I use StringForm?

When to use the root test. Is this not a good situation to use it?

Falsification in Math vs Science

What could be the right powersource for 15 seconds lifespan disposable giant chainsaw?

Realistic Alternatives to Dust: What Else Could Feed a Plankton Bloom?

Where does the "burst of radiance" from Holy Weapon originate?

How are circuits which use complex ICs normally simulated?

Is this food a bread or a loaf?

Potential by Assembling Charges

How to create dashed lines/arrows in Illustrator

Could a US political party gain complete control over the government by removing checks & balances?

What does "rabbited" mean/imply in this sentence?

What do the Banks children have against barley water?

Access elements in std::string where positon of string is greater than its size

Spanish for "widget"

Can't find the latex code for the ⍎ (down tack jot) symbol

Does it makes sense to buy a new cycle to learn riding?



Cross compiling for RPi - error while loading shared libraries



The 2019 Stack Overflow Developer Survey Results Are InMissing libcofi_rpi.so on host machineMongodb cross compilation on linux for Raspberry Pihow to install cross-compiled OpenCV's libraries on raspbery piCross Compiling Protobuf for Raspberry PiCross-Compiling kernel can't find gccEmbedded Xinu for RPiCross Compile Error Using arm-linux-gnueabihf-gccWhen I compile with arm-linux-gnueabihf-g++ version 4.7, I get error while loading shared libraries: libstdc++.so.6Is it possible to fix the “cannot find -lgcc” and “cannot find -lgcc_s” error messages when using arm-linux-gnueabihf-g++ as a linker?What's causing these crashes after cross-compiling?



.everyoneloves__top-leaderboard:empty,.everyoneloves__mid-leaderboard:empty,.everyoneloves__bot-mid-leaderboard:empty margin-bottom:0;








3















I'm trying to compile a simple program on my Ubuntu using the ARM cross compile toolchain (arm-linux-gnueabihf-gcc) and run it on my Raspberry Pi. The program is using the wiringPi shared library (wiringPi.so) located in ~/wiringPi/wiringPi on Ubuntu. The code follows:



#include "wiringPi.h"

int main (void)

wiringPiSetup();
pinMode(0, OUTPUT);

for (;;)

digitalWrite(0, HIGH);
delay(500);
digitalWrite(0, LOW);
delay(500);


return 0;



I used the command:



arm-linux-gnueabihf-gcc blinking.c -o blinking -L ~/wiringPi/wiringPi -lwiringPi -I ~/wiringPi/wiringPi


to compile and successfully get the object file, which I then transfer to Raspberry Pi.

However, when trying to run the program on Pi, I get the following error:
./blinking: error while loading shared libraries: libwiringPi.so: cannot open shared object file: No such file or directory



What am I missing?










share|improve this question









New contributor




A6SE is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.




















  • It looks like it can't find the library on the Pi. Have you installed wiringPi on the Pi (it should be preinstalled in full Raspbian, but not in Raspbian Lite).

    – joan
    Apr 5 at 20:35











  • @joan Haven't installed wiringPi on Raspberry (using Raspbian Lite). I thought the compiler links the shared libraries to the program object files. I guess I need to learn more about dynamic libraries. Just saw the answer by Ralf which explains it.

    – A6SE
    Apr 5 at 20:41






  • 1





    The Answer and comment are true BUT the the library should be installed on standard Raspbian - it is used by gpio. Currently /usr/lib/libwiringPi.so.2.50 (with a link from /usr/lib/libwiringPi.so) I note the OP has not identified what OS is in use.

    – Milliways
    Apr 5 at 22:28


















3















I'm trying to compile a simple program on my Ubuntu using the ARM cross compile toolchain (arm-linux-gnueabihf-gcc) and run it on my Raspberry Pi. The program is using the wiringPi shared library (wiringPi.so) located in ~/wiringPi/wiringPi on Ubuntu. The code follows:



#include "wiringPi.h"

int main (void)

wiringPiSetup();
pinMode(0, OUTPUT);

for (;;)

digitalWrite(0, HIGH);
delay(500);
digitalWrite(0, LOW);
delay(500);


return 0;



I used the command:



arm-linux-gnueabihf-gcc blinking.c -o blinking -L ~/wiringPi/wiringPi -lwiringPi -I ~/wiringPi/wiringPi


to compile and successfully get the object file, which I then transfer to Raspberry Pi.

However, when trying to run the program on Pi, I get the following error:
./blinking: error while loading shared libraries: libwiringPi.so: cannot open shared object file: No such file or directory



What am I missing?










share|improve this question









New contributor




A6SE is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.




















  • It looks like it can't find the library on the Pi. Have you installed wiringPi on the Pi (it should be preinstalled in full Raspbian, but not in Raspbian Lite).

    – joan
    Apr 5 at 20:35











  • @joan Haven't installed wiringPi on Raspberry (using Raspbian Lite). I thought the compiler links the shared libraries to the program object files. I guess I need to learn more about dynamic libraries. Just saw the answer by Ralf which explains it.

    – A6SE
    Apr 5 at 20:41






  • 1





    The Answer and comment are true BUT the the library should be installed on standard Raspbian - it is used by gpio. Currently /usr/lib/libwiringPi.so.2.50 (with a link from /usr/lib/libwiringPi.so) I note the OP has not identified what OS is in use.

    – Milliways
    Apr 5 at 22:28














3












3








3








I'm trying to compile a simple program on my Ubuntu using the ARM cross compile toolchain (arm-linux-gnueabihf-gcc) and run it on my Raspberry Pi. The program is using the wiringPi shared library (wiringPi.so) located in ~/wiringPi/wiringPi on Ubuntu. The code follows:



#include "wiringPi.h"

int main (void)

wiringPiSetup();
pinMode(0, OUTPUT);

for (;;)

digitalWrite(0, HIGH);
delay(500);
digitalWrite(0, LOW);
delay(500);


return 0;



I used the command:



arm-linux-gnueabihf-gcc blinking.c -o blinking -L ~/wiringPi/wiringPi -lwiringPi -I ~/wiringPi/wiringPi


to compile and successfully get the object file, which I then transfer to Raspberry Pi.

However, when trying to run the program on Pi, I get the following error:
./blinking: error while loading shared libraries: libwiringPi.so: cannot open shared object file: No such file or directory



What am I missing?










share|improve this question









New contributor




A6SE is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.












I'm trying to compile a simple program on my Ubuntu using the ARM cross compile toolchain (arm-linux-gnueabihf-gcc) and run it on my Raspberry Pi. The program is using the wiringPi shared library (wiringPi.so) located in ~/wiringPi/wiringPi on Ubuntu. The code follows:



#include "wiringPi.h"

int main (void)

wiringPiSetup();
pinMode(0, OUTPUT);

for (;;)

digitalWrite(0, HIGH);
delay(500);
digitalWrite(0, LOW);
delay(500);


return 0;



I used the command:



arm-linux-gnueabihf-gcc blinking.c -o blinking -L ~/wiringPi/wiringPi -lwiringPi -I ~/wiringPi/wiringPi


to compile and successfully get the object file, which I then transfer to Raspberry Pi.

However, when trying to run the program on Pi, I get the following error:
./blinking: error while loading shared libraries: libwiringPi.so: cannot open shared object file: No such file or directory



What am I missing?







c wiringpi cross-compilation shared-libraries






share|improve this question









New contributor




A6SE is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.











share|improve this question









New contributor




A6SE is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.









share|improve this question




share|improve this question








edited 2 days ago







A6SE













New contributor




A6SE is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.









asked Apr 5 at 20:27









A6SEA6SE

1184




1184




New contributor




A6SE is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.





New contributor





A6SE is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.






A6SE is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.












  • It looks like it can't find the library on the Pi. Have you installed wiringPi on the Pi (it should be preinstalled in full Raspbian, but not in Raspbian Lite).

    – joan
    Apr 5 at 20:35











  • @joan Haven't installed wiringPi on Raspberry (using Raspbian Lite). I thought the compiler links the shared libraries to the program object files. I guess I need to learn more about dynamic libraries. Just saw the answer by Ralf which explains it.

    – A6SE
    Apr 5 at 20:41






  • 1





    The Answer and comment are true BUT the the library should be installed on standard Raspbian - it is used by gpio. Currently /usr/lib/libwiringPi.so.2.50 (with a link from /usr/lib/libwiringPi.so) I note the OP has not identified what OS is in use.

    – Milliways
    Apr 5 at 22:28


















  • It looks like it can't find the library on the Pi. Have you installed wiringPi on the Pi (it should be preinstalled in full Raspbian, but not in Raspbian Lite).

    – joan
    Apr 5 at 20:35











  • @joan Haven't installed wiringPi on Raspberry (using Raspbian Lite). I thought the compiler links the shared libraries to the program object files. I guess I need to learn more about dynamic libraries. Just saw the answer by Ralf which explains it.

    – A6SE
    Apr 5 at 20:41






  • 1





    The Answer and comment are true BUT the the library should be installed on standard Raspbian - it is used by gpio. Currently /usr/lib/libwiringPi.so.2.50 (with a link from /usr/lib/libwiringPi.so) I note the OP has not identified what OS is in use.

    – Milliways
    Apr 5 at 22:28

















It looks like it can't find the library on the Pi. Have you installed wiringPi on the Pi (it should be preinstalled in full Raspbian, but not in Raspbian Lite).

– joan
Apr 5 at 20:35





It looks like it can't find the library on the Pi. Have you installed wiringPi on the Pi (it should be preinstalled in full Raspbian, but not in Raspbian Lite).

– joan
Apr 5 at 20:35













@joan Haven't installed wiringPi on Raspberry (using Raspbian Lite). I thought the compiler links the shared libraries to the program object files. I guess I need to learn more about dynamic libraries. Just saw the answer by Ralf which explains it.

– A6SE
Apr 5 at 20:41





@joan Haven't installed wiringPi on Raspberry (using Raspbian Lite). I thought the compiler links the shared libraries to the program object files. I guess I need to learn more about dynamic libraries. Just saw the answer by Ralf which explains it.

– A6SE
Apr 5 at 20:41




1




1





The Answer and comment are true BUT the the library should be installed on standard Raspbian - it is used by gpio. Currently /usr/lib/libwiringPi.so.2.50 (with a link from /usr/lib/libwiringPi.so) I note the OP has not identified what OS is in use.

– Milliways
Apr 5 at 22:28






The Answer and comment are true BUT the the library should be installed on standard Raspbian - it is used by gpio. Currently /usr/lib/libwiringPi.so.2.50 (with a link from /usr/lib/libwiringPi.so) I note the OP has not identified what OS is in use.

– Milliways
Apr 5 at 22:28











1 Answer
1






active

oldest

votes


















4














Shared or dynamic libraries are needed at run time. So you need the library not only on the build system but in on the target system, in this case on the PI.



This is different from static libraries. If you use a static library at build time, all the needed code from the library would be included in the executable, and the library would not be needed to run the program.



So you have to copy the library to the PI into a directory that is searched for shared libraries, such as /usr/lib or /usr/local/lib. You can also set LD_LIBRARY_PATH to point to the library, but then you must make sure it is always set when you want to execute the program.






share|improve this answer























    Your Answer






    StackExchange.ifUsing("editor", function ()
    return StackExchange.using("schematics", function ()
    StackExchange.schematics.init();
    );
    , "cicuitlab");

    StackExchange.ready(function()
    var channelOptions =
    tags: "".split(" "),
    id: "447"
    ;
    initTagRenderer("".split(" "), "".split(" "), channelOptions);

    StackExchange.using("externalEditor", function()
    // Have to fire editor after snippets, if snippets enabled
    if (StackExchange.settings.snippets.snippetsEnabled)
    StackExchange.using("snippets", function()
    createEditor();
    );

    else
    createEditor();

    );

    function createEditor()
    StackExchange.prepareEditor(
    heartbeatType: 'answer',
    autoActivateHeartbeat: false,
    convertImagesToLinks: false,
    noModals: true,
    showLowRepImageUploadWarning: true,
    reputationToPostImages: null,
    bindNavPrevention: true,
    postfix: "",
    imageUploader:
    brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
    contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
    allowUrls: true
    ,
    onDemand: true,
    discardSelector: ".discard-answer"
    ,immediatelyShowMarkdownHelp:true
    );



    );






    A6SE is a new contributor. Be nice, and check out our Code of Conduct.









    draft saved

    draft discarded


















    StackExchange.ready(
    function ()
    StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fraspberrypi.stackexchange.com%2fquestions%2f96177%2fcross-compiling-for-rpi-error-while-loading-shared-libraries%23new-answer', 'question_page');

    );

    Post as a guest















    Required, but never shown

























    1 Answer
    1






    active

    oldest

    votes








    1 Answer
    1






    active

    oldest

    votes









    active

    oldest

    votes






    active

    oldest

    votes









    4














    Shared or dynamic libraries are needed at run time. So you need the library not only on the build system but in on the target system, in this case on the PI.



    This is different from static libraries. If you use a static library at build time, all the needed code from the library would be included in the executable, and the library would not be needed to run the program.



    So you have to copy the library to the PI into a directory that is searched for shared libraries, such as /usr/lib or /usr/local/lib. You can also set LD_LIBRARY_PATH to point to the library, but then you must make sure it is always set when you want to execute the program.






    share|improve this answer



























      4














      Shared or dynamic libraries are needed at run time. So you need the library not only on the build system but in on the target system, in this case on the PI.



      This is different from static libraries. If you use a static library at build time, all the needed code from the library would be included in the executable, and the library would not be needed to run the program.



      So you have to copy the library to the PI into a directory that is searched for shared libraries, such as /usr/lib or /usr/local/lib. You can also set LD_LIBRARY_PATH to point to the library, but then you must make sure it is always set when you want to execute the program.






      share|improve this answer

























        4












        4








        4







        Shared or dynamic libraries are needed at run time. So you need the library not only on the build system but in on the target system, in this case on the PI.



        This is different from static libraries. If you use a static library at build time, all the needed code from the library would be included in the executable, and the library would not be needed to run the program.



        So you have to copy the library to the PI into a directory that is searched for shared libraries, such as /usr/lib or /usr/local/lib. You can also set LD_LIBRARY_PATH to point to the library, but then you must make sure it is always set when you want to execute the program.






        share|improve this answer













        Shared or dynamic libraries are needed at run time. So you need the library not only on the build system but in on the target system, in this case on the PI.



        This is different from static libraries. If you use a static library at build time, all the needed code from the library would be included in the executable, and the library would not be needed to run the program.



        So you have to copy the library to the PI into a directory that is searched for shared libraries, such as /usr/lib or /usr/local/lib. You can also set LD_LIBRARY_PATH to point to the library, but then you must make sure it is always set when you want to execute the program.







        share|improve this answer












        share|improve this answer



        share|improve this answer










        answered Apr 5 at 20:39









        RalfFriedlRalfFriedl

        6851210




        6851210




















            A6SE is a new contributor. Be nice, and check out our Code of Conduct.









            draft saved

            draft discarded


















            A6SE is a new contributor. Be nice, and check out our Code of Conduct.












            A6SE is a new contributor. Be nice, and check out our Code of Conduct.











            A6SE is a new contributor. Be nice, and check out our Code of Conduct.














            Thanks for contributing an answer to Raspberry Pi Stack Exchange!


            • Please be sure to answer the question. Provide details and share your research!

            But avoid


            • Asking for help, clarification, or responding to other answers.

            • Making statements based on opinion; back them up with references or personal experience.

            To learn more, see our tips on writing great answers.




            draft saved


            draft discarded














            StackExchange.ready(
            function ()
            StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fraspberrypi.stackexchange.com%2fquestions%2f96177%2fcross-compiling-for-rpi-error-while-loading-shared-libraries%23new-answer', 'question_page');

            );

            Post as a guest















            Required, but never shown





















































            Required, but never shown














            Required, but never shown












            Required, but never shown







            Required, but never shown

































            Required, but never shown














            Required, but never shown












            Required, but never shown







            Required, but never shown







            Popular posts from this blog

            Wikipedia:Vital articles Мазмуну Biography - Өмүр баян Philosophy and psychology - Философия жана психология Religion - Дин Social sciences - Коомдук илимдер Language and literature - Тил жана адабият Science - Илим Technology - Технология Arts and recreation - Искусство жана эс алуу History and geography - Тарых жана география Навигация менюсу

            Bruxelas-Capital Índice Historia | Composición | Situación lingüística | Clima | Cidades irmandadas | Notas | Véxase tamén | Menú de navegacióneO uso das linguas en Bruxelas e a situación do neerlandés"Rexión de Bruxelas Capital"o orixinalSitio da rexiónPáxina de Bruselas no sitio da Oficina de Promoción Turística de Valonia e BruxelasMapa Interactivo da Rexión de Bruxelas-CapitaleeWorldCat332144929079854441105155190212ID28008674080552-90000 0001 0666 3698n94104302ID540940339365017018237

            What should I write in an apology letter, since I have decided not to join a company after accepting an offer letterShould I keep looking after accepting a job offer?What should I do when I've been verbally told I would get an offer letter, but still haven't gotten one after 4 weeks?Do I accept an offer from a company that I am not likely to join?New job hasn't confirmed starting date and I want to give current employer as much notice as possibleHow should I address my manager in my resignation letter?HR delayed background verification, now jobless as resignedNo email communication after accepting a formal written offer. How should I phrase the call?What should I do if after receiving a verbal offer letter I am informed that my written job offer is put on hold due to some internal issues?Should I inform the current employer that I am about to resign within 1-2 weeks since I have signed the offer letter and waiting for visa?What company will do, if I send their offer letter to another company