tsdconseil / opencv-demonstrator

OpenCV demonstrator (GUI)
http://www.tsdconseil.fr/log/opencv/demo/index-en.html
GNU Lesser General Public License v3.0
141 stars 57 forks source link

Minor build issue compiling on Linux #22

Closed applemuncy closed 8 years ago

applemuncy commented 8 years ago

Great demo, thanks.

My first attempts to compiling failed with linking errors that went away when I uninstalled prior OpenCV installed from Ubuntu repositories. That was on a Ubuntu 15.10 distribution.

On a second Ubuntu 14.04 machine I removed older OpenCV before following your build instructions and except for a few compiler warnings all went well.

juliena82 commented 8 years ago

@applemuncy Thanks for your feedback! I will add a warning in the build instructions about this issue. By the way, if you tell how you did remove the old OpenCV version, we could write it too. Thanks, Julien

applemuncy commented 8 years ago

I used synaptic but on the CL I tested: $ sudo aptitude remove '~nopencv' does it or $ sudo apt-get remove 'opencv' should work but using apt-get is untested by me.

So I saw some buzz about aptitude going away from distribution sometime in the future. Software is such a moving target.

But now I find that my tutorial programs no longer work because libraries they depend on are gone : ( and will need to be compiled against the opencv-3.0.0 libraries. And I don't have much experience working with cmake. perhaps ovcdemo should be setup to be built with cmake?

juliena82 commented 8 years ago

@applemuncy Thanks for the details. Sorry that the opencv 3.0 installation has breaked your dependencies. Apparently, it is not so easy to have more than one OpenCV version on the same Linux (on Windows it is easy, because all OpenCV build process are restricted in specific build directory, there is no installation in any common folder, like /usr/include, ...).

Last time I had to port an OpenCV 2.4 program to 3.0, it was not so difficult, the API is almost identical, only some special functions have changed (more specifically, the constructors for some detectors..). I hope that you will be able to resolve those problem easily. Yet it was with C++. I don't know for the other languages.

Yes building ocvdemo with cmake is an option. But for now, as there are not so many depandencies, I find that a plain Makefile is sufficient (and the tool make being 40 years old, is some kind of stable piece of software in this world of ever moving softwares). Maybe we'll change in the future, depending on the porting dificulties.

Also, if you have made OpenCV tutorials program, maybe integrating one or several of them in the demonstrator could be a good idea?

applemuncy commented 8 years ago

Not to worry @juliena82. Perhaps I'll look into fixing up ovcdemo's Makefile to pick the correct libraries to link to so the old opencv libraries can co-exist.

shervinemami commented 8 years ago

You can have multiple OpenCV versions installed at the same time in Linux but it can add complications, so yes it's a good idea to mention at the start of the installation doc that the user should consider removing OpenCV if it was already installed. Another option is to mention to the user that instead of running the "sudo make install" command to copy OpenCV into the system folders, we can show how to get opencv-demonstrator to use a custom OpenCV build folder. That would allow people to leave their existing OpenCV installation alone and just get opencv-demonstrator to use the ~/build-from-source/opencv-3.0.0 folder directly.

juliena82 commented 8 years ago

@shervinemami Great remark Shervin! That seems to be the best way to do. So we need to enable somehow in the ocvdemo build to specify which opencv version to use. I think (if it is like on Windows) that one has just to specify where to find the:

Can you confirm me also that these are the same path on your distribution (except of the "build-from-source" part, which we have removed from the build instructions recently). If it is ok, I will update the Makefile to enable manual (and optional) specification of OpenCV location.

shervinemami commented 8 years ago

@juliena82 yes it's just the lib and include folder that you need to set. If you provide a way for the user to optionally set custom OpenCV lib and include folders, then that allows users to potentially have multiple installations of OpenCV at the same time.

shervinemami commented 8 years ago

@juliena82 Note that the OpenCV header files won't be in the "~/opencv-3.0.0/build/include" folder, they will be in the "~/opencv-3.0.0/include" folder, because header files aren't build (ie: they are the same files you downloaded). Whereas libs are generated when you build OpenCV, and so they are in the "~/opencv-3.0.0/build/lib" folder.

juliena82 commented 8 years ago

@shervinemami Yes it would be the most logical way to find the opencv headers. However, on my Windows opencv installation, the headers are "build" (or copied from somewhere) in build/instal/include. And in the include folder, there is not all the include files. Maybe something special with Windows... Just to be sure, can you check if in your Linux install, include files are not present in build/install/include too?

shervinemami commented 8 years ago

@juliena82 Yes the build and install folders are treated differently in Windows vs Linux for some reason, because header files are in the "build" folder in Windows but not in the Linux version. As long as the user has a way to override the default "include" folder and the "lib" folder for OpenCV, then it should be fine for both Windows and Linux. Another reason why it is useful to manually override it is that not every user will have root permissions (eg: if they are on a university server), so "sudo make install" (that basically just copies files from "include", "build/lib" and "data" to system folders) might not work for some people, but atleast they will be able to manually point directly to the local "~/build-from-source/opencv-3.0.0" folders.

juliena82 commented 8 years ago

@shervinemami +1 . Yes I will enable to build without root privilege, I didn't think about this good side effect. I already updated the Makefiles and build instruction to enable one to specify where the opencv folders are (2 variables, one for the include dir, one for the lib dir, as it is not the same on all targets).