J'ai compilé un petit module c++ pour lequel j'obtiens en retour une erreur de symbole non définit.

Je compile (sous Ubuntu 14.04 64bits) avec ceci:
Code : Sélectionner tout - Visualiser dans une fenêtre à part
1
2
3
4
5
6
7
 
#!/bin/sh
 
echo "compiling colortemp.cpp"
g++ -ggdb -Wall -g `pkg-config --cflags opencv` -c colortemp.cpp -o colortemp.o -lm `pkg-config --libs opencv` -fPIC 
echo "create libcolortemp.so"
g++ -ggdb -Wl,-soname,libcolortemp.so.0 -o libcolortemp.so -shared colortemp.o `pkg-config --cflags opencv` `pkg-config --libs opencv`
Je n'ai pas de message d'erreur à la compilation mais lorsque j'importe le module j'obtiens
Code : Sélectionner tout - Visualiser dans une fenêtre à part
1
2
 
ImportError: /usr/lib/libcolortemp.so: undefined symbol: _ZTV9ColorTemp
Si je vérifie avec mn
Code : Sélectionner tout - Visualiser dans une fenêtre à part
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
~$ nm /usr/lib/libcolortemp.so.0
0000000000002f88 W _ZNSt12_Vector_baseIiSaIiEE19_M_get_Tp_allocatorEv
0000000000002efc W _ZNSt12_Vector_baseIiSaIiEEC1Ev
... longue liste ...
0000000000002e1e W _ZNSt6vectorIiSaIiEED1Ev
0000000000002e1e W _ZNSt6vectorIiSaIiEED2Ev
                 U _ZNSt8ios_base4InitD1Ev@@GLIBCXX_3.4
                 U _ZSt4cout@@GLIBCXX_3.4
000000000000304c W _ZSt8_DestroyIPiEvT_S1_
0000000000002f96 W _ZSt8_DestroyIPiiEvT_S1_RSaIT0_E
00000000002041c9 b _ZStL8__ioinit
                 U _ZStlsISt11char_traitsIcEERSt13basic_ostreamIcT_ES5_PKc@@GLIBCXX_3.4
                 U _ZTV9ColorTemp
0000000000203d88 d _ZZL18__gthread_active_pvE20__gthread_active_ptr
Tout d'abord, est-ce normal que l'on puisse lire les symboles d'une lib partagée ?

Je pose la question parce que j'ai une autre lib que je compile avec exactement le même build, que d'autres utilisateurs utilisent sous diverses senteurs Linux (en ayant compilé eux-même) or si j'utilise mn sur cette autre lib:
Code : Sélectionner tout - Visualiser dans une fenêtre à part
1
2
3
 
~$ nm /usr/lib/liboqapy-iproc.so.0
nm: /usr/lib/liboqapy-iproc.so.0: aucun symbole


À toute fin utile:
colortemp.h
Code : Sélectionner tout - Visualiser dans une fenêtre à part
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
 
#include "/usr/include/opencv2/highgui/highgui.hpp"
#include "/usr/include/opencv2/imgproc/imgproc.hpp"
 
using namespace cv;
 
class ColorTemp
{
 
public :
    ColorTemp();
    int loadImage(const char *filename, int mode=1);
    bool isLoaded_;
    Mat src;
    bool isLoaded();
    int applyColorTemperature(int red, int green, int blue, int strength,
                                     const char* outf);
    virtual ~ColorTemp();
 
private :
    Mat hls;
 
};
colortemp.cpp
Code : Sélectionner tout - Visualiser dans une fenêtre à part
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
 
#include "/usr/include/opencv2/highgui/highgui.hpp"
#include "/usr/include/opencv2/imgproc/imgproc.hpp"
#include <iostream>
#include <stdio.h>
#include <fstream>
#include <math.h>
#include "colortemp.h"
 
using namespace std;
using namespace cv;
 
ColorTemp::ColorTemp()
{
    bool isLoaded_ = false;
}
 
 
int ColorTemp::loadImage(const char *filename, int mode)
{
    src = imread(filename, mode);
 
    if( !src.data )
    { 
        cout << "Image " << filename << " not loaded\n";
        isLoaded_ = false;
        return 0; 
    }
 
    else
    {
        isLoaded_ = true;
        return 1;
    }
}
 
bool ColorTemp::isLoaded()
{
    if (!isLoaded_)
    {
        return false;
    }
    return true;
}
 
int ColorTemp::applyColorTemperature(int red, int green, int blue, int strength,
                                     const char* outf)
{
    float b, g, r, min, max;
    float strg = 1 - strength;
    for( int y = 0 ; y < src.rows ; y++ )
    { 
        for( int x = 0 ; x < src.cols ; x++ )
        {
            b = src.at<Vec3b>(y, x)[0];
            g = src.at<Vec3b>(y, x)[1];
            r = src.at<Vec3b>(y, x)[2];
 
            /* Keep the original luminance */
            min = fmin(b, fmin(g, r));
            max = fmax(b, fmax(g, r));
            float ol = (min + max) / 2;
 
            float bb = (b * strg) + (blue * strength);
            float gg = (g * strg) + (green * strength);
            float rr = (r * strg) + (red * strength);
 
            Mat hls(1, 1, CV_8UC3);
            hls.at<Vec3b>(0, 0)[0] = bb;
            hls.at<Vec3b>(0, 0)[1] = gg;
            hls.at<Vec3b>(0, 0)[2] = rr;
 
            /* Convert to HLS */
            cvtColor(hls, hls, CV_BGR2HLS, 0);
 
            /* Reset the original luminance */
            hls.at<Vec3b>(0, 0)[1] = ol;
 
            /* Return to BGR */
            cvtColor(hls, hls, CV_HLS2BGR, 0);
 
            src.at<Vec3b>(y, x)[0] = hls.at<Vec3b>(0, 0)[0];
            src.at<Vec3b>(y, x)[1] = hls.at<Vec3b>(0, 0)[1];
            src.at<Vec3b>(y, x)[2] = hls.at<Vec3b>(0, 0)[2];
 
        }
    }
    imwrite( outf, src );
    return 0;
}
Je ne vois plus trop dans quelle direction chercher, merci pour vos conseils.