简体   繁体   中英

How do I include a library in an .so file in C++

I am trying to compile a .so file the relies on the FTDI library. I'm not sure how to include the library so that it compiles correctly. (Below is my best guess). Is this possible or is there another way to go about it?

shared: pldevice pldeviceenttecpro pluniverse
    $(CC) -shared  -Wl,-soname,libplanklight.so -o libplanklight.so\
    -L/usr/local/lib -lftd2xx \
    pldevice.o pldeviceenttecpro.o pluniverse.o

Edit: This is what the output is:

g++ -fPIC -c pldevice.cpp
g++ -fPIC -c pldeviceenttecpro.cpp
g++ -fPIC -c pluniverse.cpp
g++ -shared  -Wl,-soname,libplanklight.so -o libplanklight.so\
-L/usr/local/lib -lftd2xx \
pldevice.o pldeviceenttecpro.o pluniverse.o
/usr/bin/x86_64-linux-gnu-ld: cannot open output file   libplanklight.so-L/usr/local/lib: No such file or directory
collect2: error: ld returned 1 exit status
Makefile:5: recipe for target 'shared' failed
make: *** [shared] Error 1

You're missing a space.

 $(CC) -shared  -Wl,-soname,libplanklight.so -o libplanklight.so \
                                                                ^^
                                                     Add a space here

The \\ just makes the command continue on the next line, so when you have

-o libplanklight.so\
-L/usr/local/lib 

It will be the same as -o libplanklight.so-L/usr/local/lib

But you want -o libplanklight.so -L/usr/local/lib

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM