2017-06-06 2 views
0

So arbeite ich nicht auf einem Computer, sondern auf einem eingebetteten Gerät mit Ubuntu.Linux Compilation - widersprüchliche Bibliotheken

Ich versuche, OpenCV-Code zu kompilieren, aber ich habe das Gefühl, dass ich in einer Sackgasse bin!

Dies ist der Fehler, den ich bekommen: Problem:

/usr/bin/ld: warning: libopencv_core.so.3.2, needed by //usr/local/lib/libopencv_imgcodecs.so, may conflict with libopencv_core.so.2.4 
/usr/bin/ld: /tmp/ccYlsBYW.o: undefined reference to symbol '_ZN2cv11setIdentityERKNS_17_InputOutputArrayERKNS_7Scalar_IdEE' 
/usr/local/lib//libopencv_core.so.3.2: error adding symbols: DSO missing from command line 
collect2: error: ld returned 1 exit status 

2,4 Bibliotheken umbenennen:

[email protected]:/usr/lib$ sudo mv libopencv_core.so libopencv_core.soMyOld 
[email protected]:/usr/lib$ sudo mv libopencv_core.so.2.4 libopencv_core.so.2.4MyOld 
[email protected]:/usr/lib$ sudo mv libopencv_core.so.2.4.10 libopencv_core.so.2.4.10MyOld 

recompile Code

/usr/bin/ld: warning: libopencv_core.so.2.4, needed by /usr/lib/gcc/arm-linux-gnueabihf/4.8/../../../../lib/libopencv_imgproc.so, not found (try using -rpath or -rpath-link) 
/usr/bin/ld: warning: libopencv_imgproc.so.3.2, needed by //usr/local/lib/libopencv_imgcodecs.so, may conflict with libopencv_imgproc.so.2.4 
/usr/bin/ld: /tmp/ccmcvWug.o: undefined reference to symbol '_ZN2cv6circleERKNS_17_InputOutputArrayENS_6Point_IiEEiRKNS_7Scalar_IdEEiii' 
/usr/local/lib//libopencv_imgproc.so.3.2: error adding symbols: DSO missing from command line 
collect2: error: ld returned 1 exit status 

3,2 Bibliotheken Umbenennung:

[email protected]:/usr/local/lib$ sudo mv libopencv_core.so 
[email protected]:/usr/local/lib$ sudo mv libopencv_core.so.3.2 libopencv_core.so.3.2MyOld 
[email protected]:/usr/local/lib$ sudo mv libopencv_core.so.3.2.0 libopencv_core.so.3.2.0MyOld 

recompile

/usr/bin/ld: warning: libopencv_core.so.3.2, needed by //usr/local/lib/libopencv_imgcodecs.so, not found (try using -rpath or -rpath-link) 
/usr/bin/ld: warning: libopencv_imgproc.so.3.2, needed by //usr/local/lib/libopencv_imgcodecs.so, may conflict with libopencv_imgproc.so.2.4 
/usr/bin/ld: /tmp/cclHSHtB.o: undefined reference to symbol '_ZN2cv6circleERKNS_17_InputOutputArrayENS_6Point_IiEEiRKNS_7Scalar_IdEEiii' 
/usr/local/lib//libopencv_imgproc.so.3.2: error adding symbols: DSO missing from command line 
collect2: error: ld returned 1 exit status 

Was kann ich tun, um dieses Problem zu lösen? alles Deinstallation und Neuinstallation ist keine Option ...

EDIT:

ich mit diesem Befehl kompilieren:

g++ src/personDetection.cpp src/personRecognition.cpp main.cpp -lopencv_core -lopencv_imgproc -lopencv_highgui -lopencv_imgcodecs -lopencv_calib3d -lopencv_features2d -lopencv_video -lopencv_videoio -pthread -o main 
+0

Ich denke, Sie sind auf einem Tegra-Board.Vielleicht sollten Sie die standardmäßig installierte OpenCV-Bibliothek entfernen: 'OpenCV4Tegra'. – nglee

+0

@devnglee "vielleicht"? Warum bist du dir nicht sicher? Btw beachten Sie, dass die Fehler nicht über opencv Version 4 sind wie die, auf die Sie sich beziehen, und auf meinem Board gab es keine standardmäßig installierte openCV. – LandonZeKepitelOfGreytBritn

+0

'opencv4tegra' steht für opencv für tegra. Vergiss das, wenn dein Board das nicht hatte. Du hast also 2.4 bereits installiert und versuchst 3.2 zu installieren? – nglee

Antwort

1

-L Option verwendet wird die Verzeichnispfad angeben. Der Compiler durchsucht dieses Verzeichnis nach anderen Systemstandardverzeichnissen, z. B. nach Verzeichnissen in LIBRARY_PATH. Aber es durchsucht Verzeichnisse, die mit -L zuerst angegeben werden.

-l Option wird verwendet, um den Namen der Bibliothek anzugeben.

In Ihrem Fall sind 2.4 Version Bibliotheken in /usr/lib und 3.2 Version Bibliotheken sind in /usr/local/lib. Ihr Code erwartet wahrscheinlich die Version 2.4, aber Ihr System ist möglicherweise so eingestellt, dass es nach /usr/local/lib sucht, bevor es nach /usr/lib sucht. Dies könnte die Ursache Ihres Problems sein.

Mit der Angabe -L/usr/lib sagen Sie dem Compiler zuerst /usr/lib zu suchen, was zur Verwendung von 2.4-Versionsbibliotheken führt.


UPDATE

$ gcc -m64 -Xlinker --verbose 2>/dev/null | grep SEARCH | sed 's/SEARCH_DIR("=\?\([^"]\+\)"); */\1\n/g' | grep -vE '^$' 

Obiger Befehl erhalten Sie die Liste der Standard zeigen Verzeichnisse durchsucht, wenn die Verknüpfung. (kopiert den Befehl von this article)

In meinem Rechner (Ubuntu 16.04, 64-Bit), /usr/local/lib erscheint vor /usr/lib. Dies bedeutet, dass eine Bibliothek in /usr/local/lib Bibliotheken in /usr/lib überschreiben kann. (link)