raspberrypi / userland

Source code for ARM side libraries for interfacing to Raspberry Pi GPU.
BSD 3-Clause "New" or "Revised" License
2.05k stars 1.09k forks source link

warning: cannot find entry symbol _start when linking /usr/local/lib/libmmal_core.so #646

Closed iamdavidcz closed 4 years ago

iamdavidcz commented 4 years ago

Hi,

I have the following code in the camera.c file:

#include "interface/mmal/mmal.h"
#include "interface/mmal/mmal_component.h"
#include "interface/mmal/util/mmal_default_components.h"

int main(int argc, char* argv[]) {
   MMAL_COMPONENT_T *camera_info;
   MMAL_STATUS_T status;
   status = mmal_component_create(MMAL_COMPONENT_DEFAULT_CAMERA_INFO, &camera_info);
   return 0;
}

Then I'm compiling it with gcc 9.3.0 without any issues:

$ gcc -c -o camera.o camera.c

And eventually I'd like to link it using ld, but I'm getting a warning:

$ ld -o camera camera.o /usr/local/lib/libmmal_core.so /usr/local/lib/libmmal_components.so
ld: warning: cannot find entry symbol _start; defaulting to 00000000000102d4

When I'm trying to execute camera binary I'm getting the following error:

$ ./camera
-bash: ./camera: No such file or directory

Here is the ldd output:

$ ldd camera
        linux-vdso.so.1 (0xbe87a000)
        libmmal_core.so => /usr/local/lib/libmmal_core.so (0xb6ec7000)
        libmmal_components.so => /usr/local/lib/libmmal_components.so (0xb6ea6000)
        libvcos.so => /usr/local/lib/libvcos.so (0xb6e94000)
        libc.so.6 => /lib/libc.so.6 (0xb6d2d000)
        libcontainers.so => /usr/local/lib/libcontainers.so (0xb6d14000)
        libmmal_util.so => /usr/local/lib/libmmal_util.so (0xb6cf0000)
        libpthread.so.0 => /lib/libpthread.so.0 (0xb6cc4000)
        libdl.so.2 => /lib/libdl.so.2 (0xb6cb1000)
        librt.so.1 => /lib/librt.so.1 (0xb6c9a000)
        /usr/lib/ld.so.1 => /lib/ld-linux-armhf.so.3 (0xb6eeb000)
        libgcc_s.so.1 => /lib/libgcc_s.so.1 (0xb6c6b000)
popcornmix commented 4 years ago

This question isn't related to the userland libraries, but is purely a question of gcc/ld syntax (you are asking to link together libraries without any crt code). e.g. you'd have the same issue if you removed mmal calls and added puts("hello world") and tried to build it this way.

Please use the forum for this type of help.