naseeam
asked on
Why link error when try to build simple OpenGL project?
I'm using Visual Studio Community 2019.
I found 'OpenGL C++ Tutorial : Getting Started' on youtube. I get error when I try to link project. Maybe I'm not specifying 'Additional Dependencies' correctly in my project setting. Please see attached.
Also, attached is the link error.
Additional_dependencies.PNG
lib_in_proj_folder.PNG
link_error.PNG
I found 'OpenGL C++ Tutorial : Getting Started' on youtube. I get error when I try to link project. Maybe I'm not specifying 'Additional Dependencies' correctly in my project setting. Please see attached.
Also, attached is the link error.
Additional_dependencies.PNG
lib_in_proj_folder.PNG
link_error.PNG
Inaddidional independence include extensión: glfw3.lib;...
Remove from adicional depende glfw3
ASKER
Initially, before adding libraries to 'Additional Dependencies', I deleted everything from this field and then added libraries told by the
youtube tutorial. Does %(Additional Dependencies) need to be at the end of 'Additional Dependencies' field?
Do I need to specify path to the glfw library in visual studio?
youtube tutorial. Does %(Additional Dependencies) need to be at the end of 'Additional Dependencies' field?
Do I need to specify path to the glfw library in visual studio?
Yes, you need to include library path in VC Directories:
Include Directory
Library Directory
First for .h and sec9nd for objetos and .h.
Ignore my previous coments and ensure you are include the path en VCDirectorie
Include Directory
Library Directory
First for .h and sec9nd for objetos and .h.
Ignore my previous coments and ensure you are include the path en VCDirectorie
Conflits between c++ libs and glfw3 libs: Verify that both libraries have the same threading: Multithread / Not Multithread.
maybe you are compiling your project as multithraead and the libraries are not multithread
maybe you are compiling your project as multithraead and the libraries are not multithread
ASKER
My project only has One function, main( ). There are no threads in this function.
I downloaded 32-bit Windows binaries from: https://www.glfw.org/download.html. Is this the reason for linker warning?
Instead of binaries, downloading 'Source Package' and compiling into library will eliminate this warning?
#include <GLFW/glfw3.h>
int main(void)
{
GLFWwindow* window;
/* Initialize the library */
if (!glfwInit())
return -1;
/* Create a windowed mode window and its OpenGL context */
window = glfwCreateWindow(640, 480, "Hello World", NULL, NULL);
if (!window)
{
glfwTerminate();
return -1;
}
/* Make the window's context current */
glfwMakeContextCurrent(window);
/* Loop until the user closes the window */
while (!glfwWindowShouldClose(window))
{
/* Render here */
glClear(GL_COLOR_BUFFER_BIT);
/* Swap front and back buffers */
glfwSwapBuffers(window);
/* Poll for and process events */
glfwPollEvents();
}
glfwTerminate();
return 0;
}
I downloaded 32-bit Windows binaries from: https://www.glfw.org/download.html. Is this the reason for linker warning?
Instead of binaries, downloading 'Source Package' and compiling into library will eliminate this warning?
Your are using glfw3 for lib-vc2019. Yor visual studio is 2019? If not then change the libraries and include Directories in VCDirectories configuration to lib-yourvsversion.
The reason of the warnning is different msvcrt runtime
The reason of the warnning is different msvcrt runtime
Included Directory is then same only modify in LIbraries Dictories lib-vc2019 to lib-vc2010 if you are using vs 2010 for example
ASKER
I'm using Visual Studio Community 2019
Check
General Configuration:
Platform Toolset : visual Studio 2019 (v142)
C/C++:
Use Runtime Libraru: /MD
General Configuration:
Platform Toolset : visual Studio 2019 (v142)
C/C++:
Use Runtime Libraru: /MD
Alternative: create New project and install glfw library from Nuget Package Administrator.
Using: Runtime Library: /MD no warnings. Default is /MDd for debug y /MD for Realease (no debug simbols). Library glfw3.lib is Release no debug this is reason of warnning.
ASKER
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
remember: when you change to Release you will have to configure the inclusion directories and libraries, as well as the additional libraries again for this environment
ASKER
Expert found root cause of compiler warning. Thank you!
ASKER
https://www.glfw.org/download.html