Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

MSVS 2017: Impossible to link against BRFv4_WIN_trial.lib #1

Open
mathieu-b opened this issue May 9, 2018 · 28 comments
Open

MSVS 2017: Impossible to link against BRFv4_WIN_trial.lib #1

mathieu-b opened this issue May 9, 2018 · 28 comments

Comments

@mathieu-b
Copy link

Hi

It looks like the BRFv4_WIN_trial.lib library has been generated with an older compiler version, possibly MSVS 2015.
This might have happened at the time of loading the old project in the new MSVS 2017, where the toolset stayed to that older version instead of being switched to the newest. So the result is a valid MSVS 2017 project that uses the older toolset (which will not necessarily be present on the host machine).

In the meantime I'll try to run the example by downloading the older toolset and selecting it explicitly.

Another (compilmentary) idea would be to use the GitHub "releases" features, where after creating a tag in the repository it becomes possible to upload precompiled binaries and resources associated with that release / tag. In this way the software could be tested without even needing to download and install any version of MSVS, nor having to configure the project either.

Regards.

@MarcelKlammer
Copy link
Member

Thanks for the heads up, will keep that in mind for any new release.

@mathieu-b
Copy link
Author

@MarcelKlammer great, thanks!

@mathieu-b
Copy link
Author

Update:

  1. I installed Visual Studio Community 2015 (with Update 3) via web installer executable.
  2. Then, from MSVS 2017, I could choose the right toolset.
  3. The above mentioned error went away, however I got the "missing CL.exe" error.
    1. The solution was to re-run the web installer, and explicitly choose to instal Visual C++ (not selected by default at first installer run...)
  4. Then I could finally compile the brfv4 executable (and be able to run it after putting on its side the OpenCV DLL opencv_world341.dll).
  5. I also had to edit the camera ID parameter in CameraUtils::init(), setting it to zero (I only have a single camera connected)
    1. camera.open(0);

But then... new surprise!

I received the following error when running brfv4 from the command prompt:
OpenCV(3.4.1) Error: No OpenGL support (Library was built without OpenGL support) in cvNamedWindow, file C:\build\master_winpack-build-win64-vc14\opencv\modules\highgui\src\window_w32.cpp, line 810

The unfun bit: it looks like OpenCV Windows mantainers don't provide OpenCV for Windows builds with OpenGL support enabled.

Dang.

It's a pity that there is no easy / immediate way of testing your native windows program on Windows desktop systems (as for the javascript / emscripten case)...

Regards :)

@MarcelKlammer
Copy link
Member

Thanks again for the heads up. I guess that might be the reason no one actually used the Windows version until now :)...

@mathieu-b
Copy link
Author

mathieu-b commented May 9, 2018

@MarcelKlammer yes... :)

So I decided to try and compile the latest OpenCV (3.4.1) with Open GL support enabled.

OpenCV uses CMake to generate project files, so I downloaded the current version (3.11.1) and pointed it to the cloned OpenCV 3 repository folder.

After choosing Configure in CMake GUI for the first time, I selected the MSVS 2015 x64 option in the initial configuration step.

I also had to solve an issue with CMake not recognizing the Windows SDK / toolchain.
So I had to install a specific version of the Windows SDK (10586) so that CMake could detect it and go on with the Configure step.

Then, for the configure step to succeed, I had to disable a pair of *_TEST build flags.
The Open GL enabled flag was already enabled by default.

At that point I could successfully run Configure, Generate, and then Open Project. Yay! :)

I then built both Debug and Release targets for OpenCV 3.4.1.

I then opened the brfv4 project and set in Project Settings the proper include and lib folders (The .lib files were located into the lib\Debug and lib\Release folders which appeared right into the same originally downloaded OpenCV3 folder.)

Since various separate .lib files were generated by the OpenCV build steps, I had to manually specify the following libraries to be linked against:

  opencv_core341.lib
  opencv_highgui341.lib
  opencv_imgproc341.lib
  opencv_videoio341.lib

(with the d right before the .lib extension for the Debug target)

And finally to copy the corresponding compiled OpenCV 3 DLLs (similarly to the above .lib files, in the bin\Debug and bin\Release folders) plus the opencv_imgcodecs341.dll DLL.

That's all, and it works... phew!

A question: having an NVidia GPU, would enabling CUDA in OpenCV compiling speed up the detection?
Which tweaks can increase detection speed?

Regards.

@MarcelKlammer
Copy link
Member

Great. That's what I meant in the Readme:

Windows - C++ utilizing OpenCV for camera access and drawing
Good luck in trying to compile OpenCV for your Windows. Update the Visual Studio (2017) project properties that mention OpenCV. Then run the Release x64 target. Fingers crossed!

@MarcelKlammer
Copy link
Member

And no, the OpenCV stuff is only for camera access and drawing the shapes. All the tracking stuff is BRFv4 at work (face detection/tracking)

@MarcelKlammer
Copy link
Member

@mathieu-b So I tried the whole process again, just to find a way to use the standard download of opencv v3.4.1...

So download the self extracting packing of opencv from their source forge page.

Once extracted, load this BRFv4 project from github (download zip).

Then open the BRFv4 VS project and open the project settings (Release/x64).

Debugging/Environment (Umgebung in German), add

PATH=C:\Users\YOURUSERNAME\PATHTO\opencv\build\x64\vc15\bin;%PATH%

So no need to copy any dll.

Under C/C++, change the include folder to :

C:\Users\YOURUSERNAME\PATHTO\opencv\build\include

Under Linker, change the lib folder:

C:\Users\YOURUSERNAME\PATHTO\opencv\build\x64\vc15\lib

and under Linker/Input (Eingabe in German), change opencv_world320.lib to opencv_world341.lib.

In the code itself use:

main.cpp:
cv::namedWindow("main", cv::WINDOW_NORMAL);

CameraUtils.hpp
camera.open(0)

... this will make the current Windows example project work with the current OpenCV standard download.

@mathieu-b
Copy link
Author

Ok, good to know :)

hukan008 pushed a commit to hukan008/brfv4_win_examples that referenced this issue Feb 2, 2020
Shouldn't be pinning to 2.0 - many people will only have the 2.1 SDK installed
Fixes Tastenkunst#1
@someoneitsme
Copy link

@mathieu-b So I tried the whole process again, just to find a way to use the standard download of opencv v3.4.1...

So download the self extracting packing of opencv from their source forge page.

Once extracted, load this BRFv4 project from github (download zip).

Then open the BRFv4 VS project and open the project settings (Release/x64).

Debugging/Environment (Umgebung in German), add

PATH=C:\Users\YOURUSERNAME\PATHTO\opencv\build\x64\vc15\bin;%PATH%

So no need to copy any dll.

Under C/C++, change the include folder to :

C:\Users\YOURUSERNAME\PATHTO\opencv\build\include

Under Linker, change the lib folder:

C:\Users\YOURUSERNAME\PATHTO\opencv\build\x64\vc15\lib

and under Linker/Input (Eingabe in German), change opencv_world320.lib to opencv_world341.lib.

In the code itself use:

main.cpp:
cv::namedWindow("main", cv::WINDOW_NORMAL);

CameraUtils.hpp
camera.open(0)

... this will make the current Windows example project work with the current OpenCV standard download.

how do you include the library for that?

@MarcelKlammer
Copy link
Member

I don't understand the question. The whole post is about adding OpenCV to the project settings.

@someoneitsme
Copy link

CameraUtils.hpp
camera.open(0)

For this part,I added it into the main.cpp however it says these two are undeclared hence I found out that these are suppose to have a library so it can be declared.

@someoneitsme
Copy link

CameraUtils.hpp
camera.open(0)

These two parts of the codes seem to be undeclared identifier. How to solve this issue?

@MarcelKlammer
Copy link
Member

You supposed to be loading main.cpp, this includes CameraUtils.hpp, which itself includes camera.open(1). Not sure how to help you without error message or code.

@someoneitsme
Copy link

The error code is C2065. Error is " 'CameraUtils': undeclared identifier"

@MarcelKlammer
Copy link
Member

Please take a look at

https://github.com/Tastenkunst/brfv4_win_examples/blob/master/brfv4_win_examples/main.cpp

and how CameraUtils are imported and used correctly.

@someoneitsme
Copy link

Capture

@MarcelKlammer
Copy link
Member

Why would you add those two lines? Remove them.

@someoneitsme
Copy link

Capture

@someoneitsme
Copy link

I dont really understand how to solve these errors.

@MarcelKlammer
Copy link
Member

Seems like the BRF library is not in the lib path?

@someoneitsme
Copy link

Do you mean this PATH=C:\Users\YOURUSERNAME\PATHTO\opencv\build\x64\vc15\bin;%PATH% ?

@MarcelKlammer
Copy link
Member

That would be a path you have to set for OpenCV, which was the topic of this thread.
I mean, that it seems, that the BRF library is not in the path. Not sure though and I currently don't have time.

@someoneitsme
Copy link

Are they all included in your post?

@MarcelKlammer
Copy link
Member

The project already includes the paths to the libs I guess. Again, I don't have the time to check it.

@someoneitsme
Copy link

Re-downloaded and redid all your steps.Still got the external errors issues. Anyways,thanks alot for your time,Marcel

@rayleigh007
Copy link

@MarcelKlammer yes... :)

So I decided to try and compile the latest OpenCV (3.4.1) with Open GL support enabled.

OpenCV uses CMake to generate project files, so I downloaded the current version (3.11.1) and pointed it to the cloned OpenCV 3 repository folder.

After choosing Configure in CMake GUI for the first time, I selected the MSVS 2015 x64 option in the initial configuration step.

I also had to solve an issue with CMake not recognizing the Windows SDK / toolchain.
So I had to install a specific version of the Windows SDK (10586) so that CMake could detect it and go on with the Configure step.

Then, for the configure step to succeed, I had to disable a pair of *_TEST build flags.
The Open GL enabled flag was already enabled by default.

At that point I could successfully run Configure, Generate, and then Open Project. Yay! :)

I then built both Debug and Release targets for OpenCV 3.4.1.

I then opened the brfv4 project and set in Project Settings the proper include and lib folders (The .lib files were located into the lib\Debug and lib\Release folders which appeared right into the same originally downloaded OpenCV3 folder.)

Since various separate .lib files were generated by the OpenCV build steps, I had to manually specify the following libraries to be linked against:

  opencv_core341.lib
  opencv_highgui341.lib
  opencv_imgproc341.lib
  opencv_videoio341.lib

(with the d right before the .lib extension for the Debug target)

And finally to copy the corresponding compiled OpenCV 3 DLLs (similarly to the above .lib files, in the bin\Debug and bin\Release folders) plus the opencv_imgcodecs341.dll DLL.

That's all, and it works... phew!

A question: having an NVidia GPU, would enabling CUDA in OpenCV compiling speed up the detection?
Which tweaks can increase detection speed?

Regards.

Possible to share your cmakelists.txt

@someoneitsme
Copy link

@MarcelKlammer yes... :)
So I decided to try and compile the latest OpenCV (3.4.1) with Open GL support enabled.
OpenCV uses CMake to generate project files, so I downloaded the current version (3.11.1) and pointed it to the cloned OpenCV 3 repository folder.
After choosing Configure in CMake GUI for the first time, I selected the MSVS 2015 x64 option in the initial configuration step.
I also had to solve an issue with CMake not recognizing the Windows SDK / toolchain.
So I had to install a specific version of the Windows SDK (10586) so that CMake could detect it and go on with the Configure step.
Then, for the configure step to succeed, I had to disable a pair of *_TEST build flags.
The Open GL enabled flag was already enabled by default.
At that point I could successfully run Configure, Generate, and then Open Project. Yay! :)
I then built both Debug and Release targets for OpenCV 3.4.1.
I then opened the brfv4 project and set in Project Settings the proper include and lib folders (The .lib files were located into the lib\Debug and lib\Release folders which appeared right into the same originally downloaded OpenCV3 folder.)
Since various separate .lib files were generated by the OpenCV build steps, I had to manually specify the following libraries to be linked against:

  opencv_core341.lib
  opencv_highgui341.lib
  opencv_imgproc341.lib
  opencv_videoio341.lib

(with the d right before the .lib extension for the Debug target)
And finally to copy the corresponding compiled OpenCV 3 DLLs (similarly to the above .lib files, in the bin\Debug and bin\Release folders) plus the opencv_imgcodecs341.dll DLL.
That's all, and it works... phew!
A question: having an NVidia GPU, would enabling CUDA in OpenCV compiling speed up the detection?
Which tweaks can increase detection speed?
Regards.

Possible to share your cmakelists.txt

hi Rayleigh, have you manage to configure it for windows?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants