Linux C ++ Shared Libraries

I have a shared library wise.so. How can I use it in my program? Do I need to include the headers of this library?

I work with Eclipce under Linux. I set the library path using -L and -l. But my function is not visible in the program.

Could you explain to me how the shared library works?

Sincerely.

EDIT:

I get the following error:

int main() {
    char* path = "/export/home/pdmazubi3/workspace/proj1/src/pic.jpg";
    CEDD_Descriptor::CEDD ced; // undefined reference to `CEDD_Descriptor::CEDD::CEDD[in-charge]()'
    ced.execute(path);
}

Title:

class CEDD
    {
        public:
            CEDD(double Th0, double Th1, double Th2, double Th3,bool CompactDescriptor);
            CEDD();
            ~CEDD(void);

            double T0;
            double T1;
            double T2;
            double T3;
            bool Compact;

            double* execute(char* path);

        private:
            int cedd_segnum;                //number of segments
            int* cedd_partitionSize;        //number of pixels in each segment
    };
+5
source share
2 answers

You need to include the header file in the application and a link to it.

See how to use libraries in shared libraries and Linux METHODS .

, ( ), , , -I/path/to/include , .

. , -L/path/to/lib , , -l<libname>, <libname> - lib, . libboost_serialization-d-1_34_1.so, -lboost_serialization-d-1_34_1

:

g++ -I/sw/include -Wall -g -I/usr/local/include/boost-1_36/ -c main.cpp -o main.o
g++ -L/sw/lib -lboost_serialization-d-1_34_1 -o x main.o 
+10

Include ( -I), , ? , // ..

0

All Articles