Category Archives: How to Fix

Environment configuration at the beginning of OpenCV + vs2015

    First of all, the configuration of the system environment (after the computer has configured OpenCV once, there is no need to reconfigure). After the configuration of the system environment variables, the corresponding configuration is carried out on VS2015. First select the new project — VC++ — Win32 console program — empty project, and then right-click the source file to create a corresponding main function;

Then find the property manager in the view – Microsoft.cpp.x64.user in the Debugx64, and right-click to select the property; Add and edit the include file in the VC++ directory:
E:\opencv\opencv\build\include\opencv2
E:\opencv\opencv\build\include\opencv
E:\opencv\opencv\build\include
To add and edit the library directory:
E:\opencv\opencv\build\x64\vc15\lib
Add and edit the — input — attached dependencies in the linker:
Opencv_world341d. Lib
After the above three steps, click Apply and all the variables are configured. At this point, you can choose a simple program to run (e.g., display an image).
# include & lt; opencv2/opencv.hpp>
# include & lt; iostream>
Using the namespace CV;
Using namespace STD.
 
Int main(int argc, char** argv)
{
cout < < “Hello World” & lt; < Endl;
Mat image = imread (” E: \ \ v \ \ c + + \ \ hello word2 \ \ hello word2 \ \ 10. JPG “);
// NamedWindow (” test image “);
Imshow (” ceshi “, image);
/*if (image.empty())
{
imshow(“window”, image);
} * /
waitKey(0);
Return 0;
}
In particular, it is necessary to pay attention to:
1. Be sure to configure it on the solution configuration and solution platform. Debug+x64
2. The images that need to be opened must be placed in the same path as the.cpp file
The escape character in the path is uble slash.
Can consult to solve video https://v.qq.com/x/page/d0519qgy4lu.html?

Configure OpenGL development environment (glfw3 + glad) once and for all with visual studio

primers
There are many versions of OpenGL, we need to introduce additional third-party libraries to meet our usual rendering needs, which is more troublesome for students who just started learning.
I also met many many times behind the configuration of the tutorial, wasted time, also their technology and modern technology of OpenGL.
(2018), at the current time from learning OpenGL if glBegin () and a glEnd () that a is behind The Times, this tutorial is to demonstrate how to configure OpenGL3.3 over the environment.
> Learn the OpenGL tutorial: Learnopengl, you may need over the wall, there is a Chinese translation.
If you want to learn OpenGL quickly, here is the configured environment: (open it directly in VS2015 or above, Win7/10 test)
perlink: Resources
(> header files, lib files, DLLs used in the directory structure are also in this link)
The directory structure
The environment we configured is not only responsible for storing code and third party lib, but also some shader files and resource files, so we need to build a good directory structure.
The full configuration directory structure is as follows:

tr> <>> vsbuild> td>

/ table> <>d>
name

note

SRC

store code

external \ include

third-party library header files, Contains stb_image. J h, glad. J h, GLFW. J h, assimp. H such as

external \ lib

third-party libraries of lib

external \ DLL

third-party library DLL

resources

resource folder,
>
Focus on the folders under external\include
GLM OpenGL mathematical library, defined a lot of vector, matrix operations, concise and fast. GLFW is a cross-platform abstract library of window resources. Glad has different OpenGL implementations for different graphics card drivers, Glad helps us hide these differences and happily use OpenGL. STB_IMAGE lightweight library for reading images ASSIMP lightweight library for reading models
We have, so to speak, all the common components except the physics engine and sound control.
Now let’s construct the directory structure from scratch.
> First find an empty folder and create the following directory structure in it:

Instead of creating a vsbuild, VS will do it for us.
> Open Visual Studio and create an empty project. The project name is vsbuild.

After creation:

Next we need to configure lib, include to be introduced into our project.
Right-click on the vsbuild project and open the properties page:

Find the C/C++ Genral

note that the C/C++ option only appears when you create a new.cpp file)
E>the additional directory on the right:

Note that SolutionDir is a macro that represents the directory where VSBuild is located, so we can find External/Include relative to it.
(Type the information $(SolutionDir)… , external, include).
Similarly, select the additional library directory for Linker’s General

Open Edit:

In addition, open the Linker Input directory and enter the following values:



glfw3.lib
ad.lib
s>mage.lib
assimp.>
SolutionDir \external\lib
(here I compiled glad and stb_image into static libraries)
nally, because ASSIMP requires dynamic linking, we need to import the corresponding DLL into our project.
The easiest way to do this is as follows:

Select Debug and edit the environment entry:

The meaning of this line is to temporarily add the EXTERNAL \ DLL directory to the environment variable in debug mode so that we can successfully dynamically link.
After the configuration is complete, paste the following code into source.cpp and run.

#include <glad\glad.h>
#include <glfw\glfw3.h>
#include <iostream>


void framebuffer_size_callback(GLFWwindow* window, int width, int height);

void processInput(GLFWwindow *window);



// settings

const unsigned int SCR_WIDTH = 800;

const unsigned int SCR_HEIGHT = 600;



int main()

{

    // glfw: initialize and configure

    // ------------------------------

    glfwInit();

    glfwWindowHint(GLFW_CONTEXT_VERSION_MAJOR, 3);

    glfwWindowHint(GLFW_CONTEXT_VERSION_MINOR, 3);

    glfwWindowHint(GLFW_OPENGL_PROFILE, GLFW_OPENGL_CORE_PROFILE);



#ifdef __APPLE__

    glfwWindowHint(GLFW_OPENGL_FORWARD_COMPAT, GL_TRUE); // uncomment this statement to fix compilation on OS X

#endif



                                                         // glfw window creation

                                                         // --------------------

    GLFWwindow* window = glfwCreateWindow(SCR_WIDTH, SCR_HEIGHT, "LearnOpenGL", NULL, NULL);

    if (window == NULL)

    {

        std::cout << "Failed to create GLFW window" << std::endl;

        glfwTerminate();

        return -1;

    }

    glfwMakeContextCurrent(window);

    glfwSetFramebufferSizeCallback(window, framebuffer_size_callback);



    // glad: load all OpenGL function pointers

    // ---------------------------------------

    if (!gladLoadGLLoader((GLADloadproc)glfwGetProcAddress))

    {

        std::cout << "Failed to initialize GLAD" << std::endl;

        return -1;

    }



    // render loop

    // -----------

    while (!glfwWindowShouldClose(window))

    {

        // input

        // -----

        processInput(window);



        // render

        // ------

        glClearColor(0.2f, 0.3f, 0.3f, 1.0f);

        glClear(GL_COLOR_BUFFER_BIT);



        // glfw: swap buffers and poll IO events (keys pressed/released, mouse moved etc.)

        // -------------------------------------------------------------------------------

        glfwSwapBuffers(window);

        glfwPollEvents();

    }



    // glfw: terminate, clearing all previously allocated GLFW resources.

    // ------------------------------------------------------------------

    glfwTerminate();

    return 0;

}



// process all input: query GLFW whether relevant keys are pressed/released this frame and react accordingly

// ---------------------------------------------------------------------------------------------------------

void processInput(GLFWwindow *window)

{

    if (glfwGetKey(window, GLFW_KEY_ESCAPE) == GLFW_PRESS)

        glfwSetWindowShouldClose(window, true);

}



// glfw: whenever the window size changed (by OS or user resize) this callback function executes

// ---------------------------------------------------------------------------------------------

void framebuffer_size_callback(GLFWwindow* window, int width, int height)

{

    // make sure the viewport matches the new window dimensions; note that width and 

    // height will be significantly larger than specified on retina displays.

    glViewport(0, 0, width, height);

}

The following window shows that the configuration is successful.

The tutorial and difference of glew, glfw, glad and freeglut

Refer to the blog: https://blog.csdn.net/iteapoy/article/details/82937490
https://blog.csdn.net/what951006/article/details/79268897
1. OpenGL+VS2017 environment configuration
https://blog.csdn.net/AvatarForTest/article/details/79199807
Skip this configuration if you use the OpenGl-Tutorial Chinese tutorial below, which comes with the CMake compiler, and complete the configuration in one step.
2. OpenGL – Tutorial
http://www.opengl-tutorial.org/cn/beginners-tutorials/tutorial-1-opening-a-window/
Advantages: this translation is more vivid. After compiling with Cmake, you don’t need to configure VS2017 yourself. Even the shaders are integrated into it. The first few chapters don’t need to write their own shaders, the focus is on drawing the graphics, suitable for cute new beginners.
Disadvantages: The whole structure of CMAKE is relatively large and a bit difficult to untangle after compiling.
3. Use GLFW + Glad’s Chinese tutorial
LearnOpenGL-CN:https://learnopengl-cn.github.io/
Advantages: according to the “OpenGL+VS2017 environment configuration (pro test)& lt; With necessary knowledge & gt; – CSDN blog method after configuration, write their own procedures, a graph of all the code in a. CPP, the structure is relatively simple.
Disadvantages: This translation is a bit obscure, you have to read it several times to understand. It is a little difficult to understand the shader. Comparing with OpenGL -tutorial, it will be a great gain.
4. Use the GLFW + FreeGLUT tutorial
Column: Learn the OpenGL3.3+ -CSDN blog step by step
https://blog.csdn.net/column/details/13062.html?& page=2

Vs configuration of OpenGL development environment: configuration of glfw library and glad Library

1. Go to GLFW official website to download the corresponding version of the configuration file: click the open link, no matter your system is 32-bit or 64-bit, it is recommended to download the 32-bit configuration file, as shown below:

Go to the Glad Online service to get the Glad. H configuration file and click the link to open it. Fill in the information as shown below to get the Glad. Zip file:


2. Unzip the downloaded file to get the configuration library of each version of VS. You can choose according to the version of VS you have installed. After decompression glad.zip can see two folders: include and SRC, we will include KHR and glad in folder folder to include new folder, as shown in the figure below:

Then place the lib-vc2013 folder and include folder in the same folder, as shown in the figure below:

Good to here folder finishing work, then see how to configure!!
3. Copy the glfw3.dll files from the lib-vc2013 folder to the system folders: C:\ windows\ System32 and C:\ windows\ SysWOW64.
4. Open VS2013, create a new console application, create a new demo.cpp, and add the glad.c in the SRC folder from which the glad.zip is unzips to the project, as shown in the figure below:

5. Link to contain directory and library directory, right-click Solution: Properties ->; Configure properties ->; VC++ Directory: Include the paths to the two folders from Step 2, as shown in the figure below:


6. Link libraries: opengl32.lib and glfw3.lib. Right-click Solution: Properties ->; Configure properties ->; The linker – & gt; Add a dependency, as shown in the figure below:

Here, the configuration is complete, let’s run the first example!!
7. Implement an OpenGL window: Hello Window.
The demo. CPP code:

#include <glad\glad.h>
#include <GLFW\glfw3.h>

#include <iostream>
void framebuffer_size_callback(GLFWwindow* window, int width, int height);
void processInput(GLFWwindow *window);

// settings
const unsigned int SCR_WIDTH = 800;
const unsigned int SCR_HEIGHT = 600;

int main()
{
	// glfw: initialize and configure
	// ------------------------------
	glfwInit();
	glfwWindowHint(GLFW_CONTEXT_VERSION_MAJOR, 3);
	glfwWindowHint(GLFW_CONTEXT_VERSION_MINOR, 3);
	glfwWindowHint(GLFW_OPENGL_PROFILE, GLFW_OPENGL_CORE_PROFILE);

#ifdef __APPLE__
	glfwWindowHint(GLFW_OPENGL_FORWARD_COMPAT, GL_TRUE); // uncomment this statement to fix compilation on OS X
#endif

	// glfw window creation
	// --------------------
	GLFWwindow* window = glfwCreateWindow(SCR_WIDTH, SCR_HEIGHT, "LearnOpenGL", NULL, NULL);
	if (window == NULL)
	{
		std::cout << "Failed to create GLFW window" << std::endl;
		glfwTerminate();
		return -1;
	}
	glfwMakeContextCurrent(window);
	glfwSetFramebufferSizeCallback(window, framebuffer_size_callback);

	// glad: load all OpenGL function pointers
	// ---------------------------------------
	if (!gladLoadGLLoader((GLADloadproc)glfwGetProcAddress))
	{
		std::cout << "Failed to initialize GLAD" << std::endl;
		return -1;
	}

	// render loop
	// -----------
	while (!glfwWindowShouldClose(window))
	{
		// input
		// -----
		processInput(window);

		// glfw: swap buffers and poll IO events (keys pressed/released, mouse moved etc.)
		// -------------------------------------------------------------------------------
		glfwSwapBuffers(window);
		glfwPollEvents();
	}

	// glfw: terminate, clearing all previously allocated GLFW resources.
	// ------------------------------------------------------------------
	glfwTerminate();
	return 0;
}

// process all input: query GLFW whether relevant keys are pressed/released this frame and react accordingly
// ---------------------------------------------------------------------------------------------------------
void processInput(GLFWwindow *window)
{
	if (glfwGetKey(window, GLFW_KEY_ESCAPE) == GLFW_PRESS)
		glfwSetWindowShouldClose(window, true);
}

// glfw: whenever the window size changed (by OS or user resize) this callback function executes
// ---------------------------------------------------------------------------------------------
void framebuffer_size_callback(GLFWwindow* window, int width, int height)
{
	// make sure the viewport matches the new window dimensions; note that width and 
	// height will be significantly larger than specified on retina displays.
	glViewport(0, 0, width, height);
}

Running results:

[OpenGL · error] visual studio 2019 reports an error. It is an external symbol gladloadglloader that cannot be parsed. This symbol is referenced in the function main

Errors encountered
Today before open write OpenGL rendering triangular program, found that have been submitted to the following error

when thought is a good start you don’t have links to files and library files, search on the Internet, and finally found the problem, is you don’t have the glad. C files added to the project.
The solution
Before remembering yourself to add glad.c file is passed in the source file ->; Create a new item, create a new glad.c file, and then copy the contents of the glad.c file from the other directory.

> By right-clicking the source file ->; Add an existing item ->;

Netinet / in. H Linux / in. H problem

* IPv6hdr struct * IPv6hdr struct * IPv6hdr struct * IPv6hdr struct * IPv6hdr struct * IPv6hdr struct * IPv6hdr struct * IPv6hdr struct * IPv6hdr struct
It is assumed that it directly includes <; linux/ipv6.h> Result compilation error, duplicate definition The problem is that the project uses the libnetfilter_conntrack.h connection trace header, This file contains <<; netinet/in.h> , while IPv6.h contains <; linux/in.h> Both files basically define the same thing Linux is for the kernel and Netinet is for user space, so in user space I call <; netinet/ipv6.h> This file contains Netinet. h so there is no problem.

You are not allowed to upload merges in Git push

Git add -u filename git add -u filename git rebase — continue git rebase — continue git rebase — continue git rebase — continue git rebase — continue git add -u filename Commit is not required. And then finally, code. (reference links reference 2)

the cause of the problem: in the local branch ahead remote branch commit more than one, is the bifurcate, in this case, use the git pull after updating the code to git push will have such a situation,

solution principles: use rebase, “give up” the local patches, but is saved and then add in the front of the remote branch.

base parse link
Attached is a blog post with a lot of git error parsing: click the Open link

[FAQ] after git merge, the push to Gerrit fails, indicating no new changes?

Requirement: Git branch merge
Git Merge: A branch merge is performed locally with Git Merge, and you want to push it to Gerrit to review the repository. However, when you commit it, you can say:

! [remote rejected] HEAD -> refs/for/dev (no new changes)

No new changes have been made to the system, but the changes are linear. Gerrit will not allow you to submit a review if you don’t have a new commit. If you don’t have a new commit, Gerrit will not allow you to submit a review.
Method 1: When git merge, add the –no-ff parameter to make it a new commit so that it can commit ~ (but the generated Gerrit change does not see the change).
Method 2: Push directly into the remote library without going through Gerrit. (Not recommended)

How to solve the problem of “unable to open source file XXXXX. H” in VS development?

There’s only one reason for the problem: you don’t include the relevant.h files in your project, whether you’re using an absolute path or a relative path.
The problem for many people may be that the path is clearly included, but still there is a “cannot open the source file”, why?

That’s because you chose the wrong build platform. For example, you built an x86 project but chose the default x64 platform when you included the path.

As shown in the figure below, the marks at 1 and 2 are clearly in conflict.

the solution is: if you are using the x86 choice of the win32 pop-up property page, put related. H or. Lib contains to engineering projects.

C / C + + cannot open the source file directory, the header file is not imported, the solution is as follows

The two methods
Configure the various dependencies
1. Project, Properties, C/C++, Additional Includes Directory: Fill in Additional Includes Directory “add. H file folder path semicolon interval multiple
2.
3
3
3
3
3
3
3
3
3
3
3> Item, Property, Linker, Input, Additional Dependency: Fill in the name of the additional dependency library. Lib space or semicolon interval multiple
Two, the use of code directly import
Copy the required xxx.h file to the compile file
Copy the required copy of the xxx.lib library to the build


Git push you are not allowed to upload merges

If you download a project from the remote branch master, you will modify the project and commit it. If someone else commits a project from the remote branch master, the change can be different. If you pull the same project, you will have a problem. You are not allowed to upload merges when you pull the code and merge it by default. You are not allowed to upload merges when you push the code. Gerrit does not allow local merge submissions by default.

Solution:
Object: you
Git rebase master git rebase master
If there is a conflict, resolve the conflict manually (enter the conflict file to resolve it) and then
Git rebase – continue
Then, in a push