Compile a simple program on ubuntu arm

后端 未结 3 1184
滥情空心
滥情空心 2020-12-21 18:21

I have a simple program

#include 
int main(){
  g_print(\"hallo\\n\");
}

and try to compile it on the embedded system (Odroid

3条回答
  •  太阳男子
    2020-12-21 18:44

    You need to add the $(pgk-config --libs glib-2.0) after the main.c in your compile line - because library functions are only dragged into the binary if there is anything using them - so main.c is what is using the g_print, and if the -lglib (or whatever the result of the pkg-config bit is) is before main.c, it doesn't get included in the resulting binary.

提交回复
热议问题