antiprism / libu8g2arm

Other
9 stars 5 forks source link

Wiring Pi not found #1

Closed win10Device closed 1 year ago

win10Device commented 1 year ago

I compiled the libu8g2arm repo on my raspberry pi, then copied the compiled library to my main computer for use in visual studio, had no issues with that what so ever, whenever i go to compile any random code relating to libu8g2arm library, i get this error (Note, Visual Studio is remoting into my raspberry pi, the error is coming from the raspberry pi)

1>/usr/bin/ld : error : cannot find -lwiringPi
1>collect2 : error : ld returned 1 exit status
antiprism commented 1 year ago

Hi

I searched the libu8g2arm source tree and found no mention of wiringPi. I don't have Wiring Pi installed when I use the library on a Raspberry Pi.

I don't have any experience with Visual Studio. When you compile the "random code", is this a Visual Studio project? Does the Visual Studio project include a setting to link to wiringPi? (Are you using a project that is modified from another project that included this setting?) You could look at the lines printed before the error line for the command that caused the error, What part of the build configuration created the command lat led to the error?

Adrian.

win10Device commented 1 year ago

Ok, so i checked vcxproject file, and it contained this;

    <Link>
      <LibraryDependencies>wiringPi</LibraryDependencies>
    </Link>

After removing it, it no longer tries to include wiringPi on compile But now i get these errors, no matter what i try, (Yes, i've install libu8g2arm to the raspberry pi, the error is coming from the pi again)

1>/usr/bin/ld : error : /home/(username)/projects/Blink1/main.cpp:17: undefined reference to `u8x8_InitDisplay'
1>/usr/bin/ld : error : /home/(username)/projects/Blink1/main.cpp:18: undefined reference to `u8g2_ClearDisplay'
1>/usr/bin/ld : error : /home/(username)/projects/Blink1/main.cpp:22: undefined reference to `u8g2_ClearBuffer'
1>/usr/bin/ld : error : /home/(username)/projects/Blink1/main.cpp:23: undefined reference to `u8g2_SetFont'
1>/usr/bin/ld : error : /home/(username)/projects/Blink1/main.cpp:24: undefined reference to `u8g2_DrawStr'
1>/usr/bin/ld : error : /home/(username)/projects/Blink1/main.cpp:25: undefined reference to `u8g2_SendBuffer'
1>/usr/bin/ld : error : /home/(username)/projects/Blink1/main.cpp:31: undefined reference to `u8g2_ClearBuffer'
1>/usr/bin/ld : error : /home/(username)/projects/Blink1/main.cpp:32: undefined reference to `u8g2_SendBuffer'
1>/usr/bin/ld : error : /home/(username)/projects/Blink1/main.cpp:35: undefined reference to `u8x8_arm_linux_gpio_and_delay'
1>/usr/bin/ld : error : /home/(username)/projects/Blink1/main.cpp:35: undefined reference to `u8x8_byte_arm_linux_hw_spi'
1>/usr/bin/ld : error : /home/(username)/projects/Blink1/main.cpp:35: undefined reference to `u8g2_cb_r0'
1>/usr/bin/ld : error : /home/(username)/projects/Blink1/main.cpp:35: undefined reference to `u8g2_font_ncenB08_tr'
1>collect2 : error : ld returned 1 exit status

Here's the code:

#include <libu8g2arm/u8g2.h>
#include <libu8g2arm/u8g2arm.h>

u8g2_t u8g2;

int main(void)
{
    u8g2_Setup_st7920_128x64_f(&u8g2, U8G2_R0, u8x8_byte_arm_linux_hw_spi, u8x8_arm_linux_gpio_and_delay);

    u8g2_InitDisplay(&u8g2);
    u8g2_ClearDisplay(&u8g2);
    //u8g2_SetPowerSave(&u8g2, 0);

    // Draw something to the display
    u8g2_ClearBuffer(&u8g2);                    // clear the internal memory
    u8g2_SetFont(&u8g2, u8g2_font_ncenB08_tr);  // choose a suitable font
    u8g2_DrawStr(&u8g2, 0, 10, "Hello World!"); // write string to internal mem
    u8g2_SendBuffer(&u8g2); // transfer internal memory to the display

    // Leave it on the screen for a time
    sleep(5);

    // Clear the screen
    u8g2_ClearBuffer(&u8g2); // clear the internal memory
    u8g2_SendBuffer(&u8g2);  // transfer internal memory to the display

    return 0;
}
win10Device commented 1 year ago

Stopped using visual studio, and just using the g++ command, now getting segment fault when trying to run a compiled program