Bonjour à tous,
Je développe actuellement une librairie open source multi-plateforme basé sur opencv et pocketsphinx pour des applications robotique.
Sur windows tout marche bien et sur Linux l'installation se passe bien mais pas l'utilisation de la librairie.
Je m'explique: J'utilise CMake pour linker les librairies openCV, pocketsphinx et sphinxbase à ma librairie puis je link ma librairie et les autres librairies à mes exécutables. Cela marche bien quand je compile ma librairie et les codes d’exemples ensemble. Mais lorsque je veux compiler un code d'exemple sans recompiler toute ma librairie cela ne fonctionne pas j'ai à le droit à "undefined reference to" pour chaque fonction de ma librairie utilisant une librairie externe. Comme si le linkage effectuer lors de la création de la librairie statique n'était que temporaire... Comment régler cela ?
CMake pour compiler la librairie et les samples (fonctionnel):
Pour créer un projet linker avec ma librairie (non fonctionnel) :
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
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261 #################CMAKE FOR BUILD LIBRARY################ cmake_minimum_required(VERSION 2.8.8) set(CMAKE_MODULE_PATH ${CMAKE_MODULE_PATH} "${CMAKE_SOURCE_DIR}/cmake/Modules/") #project declaration project(RobotLabLibrary) if(NOT WIN32) set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -std=c++11") endif(NOT WIN32) option(BUILD_SAMPLE "if you want to build sample" ON) if(NOT WIN32) find_package(OpenCV) find_package(PocketSphinx) find_package(SphinxBase) endif(NOT WIN32) #variable declaration set(LIB_NAME RobotLabLibrary) set(CMAKE_ARCHIVE_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR}/bin) set(CMAKE_LIBRARY_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR}/bin) set(CMAKE_RUNTIME_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR}/bin) if(WIN32) set(POCKETSPHINX_LIB pocketsphinx sphinxbase) set(OPENCV_LIB opencv_ts300 opencv_world300) endif(WIN32) #add link for the lib if(WIN32) include_directories(3rdparty/opencv/include) include_directories(3rdparty/pocketSphinx/include) include_directories(3rdparty/sphinxbase/include) link_directories(3rdparty/pocketSphinx/bin) link_directories(3rdparty/opencv/bin) else(WIN32) include_directories(${POCKETSPHINX_INCLUDE_DIRS}) include_directories(${SPHINXBASE_INCLUDE_DIRS}) endif(WIN32) #auto find file file(GLOB_RECURSE source_files src/*) file(GLOB_RECURSE include_files include/*) file(GLOB_RECURSE faceRecognizerContrib_files 3rdparty/faceRecognizerContrib/*) #lib declaration add_library(${LIB_NAME} STATIC ${source_files} ${include_files} ${faceRecognizerContrib_files}) if(WIN32) target_link_libraries( ${LIB_NAME} ${OPENCV_LIB} ${POCKETSPHINX_LIB}) else(WIN32) target_link_libraries( ${LIB_NAME} ${OpenCV_LIBS} ${POCKETSPHINX_LIBRARIES} ${SPHINXBASE_LIBRARIES} ${SPHINXAD_LIBRARIES}) endif(WIN32) #build sample if(BUILD_SAMPLE) set(ROBOTLAB_LIB RobotLabLibrary) include_directories(include) link_directories(bin) #executions config add_executable( voiceRecognition samples/voiceRecognition.cpp ) add_executable( createFaceDatabase samples/createFaceDatabase.cpp ) add_executable( faceRecognition samples/faceRecognition.cpp ) add_executable( globalSample samples/globalSample.cpp ) add_executable( videoDetection samples/videoDetection.cpp ) add_executable( voiceAndDetection samples/voiceAndDetection.cpp ) if(WIN32) target_link_libraries( voiceRecognition ${OPENCV_LIB} ${POCKETSPHINX_LIB} ${ROBOTLAB_LIB}) target_link_libraries( createFaceDatabase ${OPENCV_LIB} ${POCKETSPHINX_LIB} ${ROBOTLAB_LIB}) target_link_libraries( faceRecognition ${OPENCV_LIB} ${POCKETSPHINX_LIB} ${ROBOTLAB_LIB}) target_link_libraries( globalSample ${OPENCV_LIB} ${POCKETSPHINX_LIB} ${ROBOTLAB_LIB}) target_link_libraries( videoDetection ${OPENCV_LIB} ${POCKETSPHINX_LIB} ${ROBOTLAB_LIB}) target_link_libraries( voiceAndDetection ${OPENCV_LIB} ${POCKETSPHINX_LIB} ${ROBOTLAB_LIB}) else(WIN32) target_link_libraries( voiceRecognition ${OpenCV_LIBS} ${POCKETSPHINX_LIB} ${SPHINXBASE_LIBRARIES} ${SPHINXAD_LIBRARIES} ${ROBOTLAB_LIB}) target_link_libraries( createFaceDatabase ${OpenCV_LIBS} ${POCKETSPHINX_LIB} ${SPHINXBASE_LIBRARIES} ${SPHINXAD_LIBRARIES} ${ROBOTLAB_LIB}) target_link_libraries( faceRecognition ${OpenCV_LIBS} ${POCKETSPHINX_LIB} ${SPHINXBASE_LIBRARIES} ${SPHINXAD_LIBRARIES} ${ROBOTLAB_LIB}) target_link_libraries( globalSample ${OpenCV_LIBS} ${POCKETSPHINX_LIB} ${SPHINXBASE_LIBRARIES} ${SPHINXAD_LIBRARIES} ${ROBOTLAB_LIB}) target_link_libraries( videoDetection ${OpenCV_LIBS} ${POCKETSPHINX_LIB} ${SPHINXBASE_LIBRARIES} ${SPHINXAD_LIBRARIES} ${ROBOTLAB_LIB}) target_link_libraries( voiceAndDetection ${OpenCV_LIBS} ${POCKETSPHINX_LIB} ${SPHINXBASE_LIBRARIES} ${SPHINXAD_LIBRARIES} ${ROBOTLAB_LIB}) endif(WIN32) endif(BUILD_SAMPLE)
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
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129 ######################CMAKE FOR BUILD PROJECT WITH ROBOTLABLIBRARY##################### cmake_minimum_required(VERSION 2.8.8) set(ROBOTLABLIBRARY_PATH /home/adrien/Documents/testAPI/RobotLabLibrary) set(CMAKE_MODULE_PATH ${CMAKE_MODULE_PATH} "${ROBOTLABLIBRARY_PATH}/cmake/Modules/") #project declaration project(myProject) if(NOT WIN32) set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -std=c++11") endif(NOT WIN32) if(NOT WIN32) find_package(OpenCV) find_package(PocketSphinx) find_package(SphinxBase) endif(NOT WIN32) #variable declaration set(EXEC_NAME myProject) set(CMAKE_ARCHIVE_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR}/bin) set(CMAKE_LIBRARY_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR}/bin) set(CMAKE_RUNTIME_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR}/bin) if(WIN32) set(POCKETSPHINX_LIB pocketsphinx sphinxbase) set(OPENCV_LIB opencv_ts300 opencv_world300) endif(WIN32) #add link for the lib if(WIN32) include_directories(${ROBOTLABLIBRARY_PATH}/3rdparty/opencv/include) include_directories(${ROBOTLABLIBRARY_PATH}/3rdparty/pocketSphinx/include) include_directories(${ROBOTLABLIBRARY_PATH}/3rdparty/sphinxbase/include) link_directories(${ROBOTLABLIBRARY_PATH}/3rdparty/pocketSphinx/bin) link_directories(${ROBOTLABLIBRARY_PATH}/3rdparty/opencv/bin) else(WIN32) include_directories(${POCKETSPHINX_INCLUDE_DIRS}) include_directories(${SPHINXBASE_INCLUDE_DIRS}) endif(WIN32) #For RobotLabLibrary set(ROBOTLAB_LIB RobotLabLibrary) include_directories(${ROBOTLABLIBRARY_PATH}/include) link_directories(${ROBOTLABLIBRARY_PATH}/bin) #executions config add_executable( ${EXEC_NAME} myProject.cpp ) if(WIN32) target_link_libraries( ${EXEC_NAME} ${OPENCV_LIB} ${POCKETSPHINX_LIB} ${ROBOTLAB_LIB}) else(WIN32) target_link_libraries( ${EXEC_NAME} ${POCKETSPHINX_LIB} ${SPHINXBASE_LIBRARIES} ${SPHINXAD_LIBRARIES} ${OpenCV_LIBS} ${ROBOTLAB_LIB}) endif(WIN32)
Piste: Je ne fais pas de make install pour ma librairie. Je ne sais pas si cela joue un role.
Un des messages d'erreur complet (du même type que tout les autres, cmd_ln_float_r est définit dans pocketsphinx ou sphinxbase):
/home/adrien/Documents/testAPI/RobotLabLibrary/bin/libRobotLabLibrary.a(Voice.cpp.o): In function `Voice::recognizeFromMicrophone()':
Voice.cpp.text+0x53f): undefined reference to `cmd_ln_float_r'
Partager