Tony Kerr
Tony Kerr

Reputation: 11

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

Upvotes: 0

Views: 1033

Answers (1)

nos
nos

Reputation: 229108

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

Upvotes: 4

Related Questions