Using so dynamic link library g++ is correct, gcc undefined reference error

An undefined reference error occurs when calling libcyusb.so. The specific process is as follows:

test.c is as follows:

#include "cyusb.h"
int main(int argc, char ** argv)
{
    cyusb_open();
    return 0;
}

cyusb_open is a library function in libcyusb.so, use

g++ test.c -lcyusb compiles correctly

gcc test.c -lcyusb error, prompting cyusb_open() undefined reference

Try linking step by step:

g ++ test.c -o test.o

gcc test.o -lcyusb -o test compiles correctly

 

Guess you like

Origin http://43.154.161.224:23101/article/api/json?id=324981576&siteId=291194637