I am currently working on converting some of my applications to C++, and for that i have decided to use openGL, as ive got some experience with it from other platforms.
But getting this to compile in x64 seems to be quite a lot of hassle. To check if my linking stuff is working i am just trying to compile this tutorial:
http://www.opengl-tutorial.org/beginners-tutorials/tutorial-1-opening-a-window/
But as you can see, i failed miserably. I have downloaded and installed:
freeglut
GLM
GLFW
GLEW
The issue clearly seems to lay within GLFW. I am using Visual express c++ 2010.
I installed GLFW like this:
GLFW.dll (System32)
glfw.h (C:\Program Files\Microsoft SDKs\Windows\v7.1\Include\gl)
GLFW.lib (C:\Program Files\Microsoft SDKs\Windows\v7.1\Lib\x64)
GLFWDLL.lib (C:\Program Files\Microsoft SDKs\Windows\v7.1\Lib\x64)
My linker:
kernel32.lib;glu32.lib;glew32.lib;GLFW.lib;GLFWDLL.lib;opengl32.lib;user32.lib;gdi32.lib;winspool.lib;comdlg32.lib;advapi32.lib;shell32.lib;ole32.lib;oleaut32.lib;uuid.lib;odbc32.lib;odbccp32.lib;%(AdditionalDependencies)
Output:
1>------ Build started: Project: Spacecraft, Configuration: Debug x64 ------
1> Main.cpp
1>Main.obj : error LNK2019: unresolved external symbol __imp_glfwGetWindowParam referenced in function main
1>Main.obj : error LNK2019: unresolved external symbol __imp_glfwGetKey referenced in function main
1>Main.obj : error LNK2019: unresolved external symbol __imp_glfwSwapBuffers referenced in function main
1>Main.obj : error LNK2019: unresolved external symbol __imp_glfwEnable referenced in function main
1>Main.obj : error LNK2019: unresolved external symbol __imp_glfwSetWindowTitle referenced in function main
1>Main.obj : error LNK2019: unresolved external symbol __imp_glfwTerminate referenced in function main
1>Main.obj : error LNK2019: unresolved external symbol __imp_glfwOpenWindow referenced in function main
1>Main.obj : error LNK2019: unresolved external symbol __imp_glfwOpenWindowHint referenced in function main
1>Main.obj : error LNK2019: unresolved external symbol __imp_glfwInit referenced in function main
1>c:\users\leif andreas\documents\visual studio 2010\Projects\Spacecraft\x64\Debug\Spacecraft.exe : fatal error LNK1120: 9 unresolved externals
========== Build: 0 succeeded, 1 failed, 0 up-to-date, 0 skipped ==========
And finally, my includes:
// Include standard headers
#include <stdio.h>
#include <stdlib.h>
// Include GLEW
#include <gl/glew.h>
#include <gl/glut.h>
// Include GLFW
#include <gl/glfw.h>
// Include GLM
#include <glm/glm.hpp>
using namespace glm;
Related
I am trying to use the detours library in a visual studio empty windows project. I cloned the repository (https://github.com/microsoft/Detours), I added the include directory into Project Properties / C/C++ / Additional Include Directories, and I added the lib.X86 directory into Project Properties / Linker / Additional Library Directories. I get no errors visible on the file, but when I build I get
1>Source.cpp
1>Source.obj : error LNK2019: unresolved external symbol _DetourTransactionBegin#0 referenced in function _main
1>Source.obj : error LNK2019: unresolved external symbol _DetourTransactionCommit#0 referenced in function _main
1>Source.obj : error LNK2019: unresolved external symbol _DetourUpdateThread#4 referenced in function _main
1>Source.obj : error LNK2019: unresolved external symbol _DetourAttach#8 referenced in function _main
1>Source.obj : error LNK2019: unresolved external symbol _DetourDetach#8 referenced in function _main
1>Source.obj : error LNK2019: unresolved external symbol _DetourRestoreAfterWith#0 referenced in function _main
1>C:\Users\colel\source\repos\Project3\Debug\Project3.exe : fatal error LNK1120: 6 unresolved externals
1>Done building project "Project3.vcxproj" -- FAILED.
========== Build: 0 succeeded, 1 failed, 0 up-to-date, 0 skipped =========
Which looks like the library wasn't included correctly. How do I properly include the detours library into a visual studio project and what am I doing wrong?
You need to add the specific .lib file, which I'm guessing is "detours.lib" (or similar) to the "Additional Dependencies" line.
Properties->Linker->Input->Additional Dependencies.
I'm trying to run a program with GLFW in C++. I'm using visual studios 2019 on a windows 10 computer. I put the .h's and the .lib's in the proper folders and linked to them in the project settings. I'm running a minimal GLFW program I got off the internet. When I run it I get the following error:
1>------ Build started: Project: Riemannian, Configuration: Debug Win32 ------
1>Main.cpp
1>Main.obj : error LNK2019: unresolved external symbol __imp__glClear#4 referenced in function _main
1>Main.obj : error LNK2019: unresolved external symbol _glfwInit referenced in function _main
1>Main.obj : error LNK2019: unresolved external symbol _glfwTerminate referenced in function _main
1>Main.obj : error LNK2019: unresolved external symbol _glfwCreateWindow referenced in function _main
1>Main.obj : error LNK2019: unresolved external symbol _glfwWindowShouldClose referenced in function _main
1>Main.obj : error LNK2019: unresolved external symbol _glfwPollEvents referenced in function _main
1>Main.obj : error LNK2019: unresolved external symbol _glfwMakeContextCurrent referenced in function _main
1>Main.obj : error LNK2019: unresolved external symbol _glfwSwapBuffers referenced in function _main
1>C:\Users\Aaron\source\repos\Riemannian\Debug\Riemannian.exe : fatal error LNK1120: 8 unresolved externals
1>Done building project "Riemannian.vcxproj" -- FAILED.
========== Build: 0 succeeded, 1 failed, 0 up-to-date, 0 skipped ==========
I tried adding glfw3.dll to system32, but that didn't change anything. (side note, GLFW came with a file glfw3dll.lib. Is that just a .lib file that serves the same purpose as glfw3.dll?) Next I tried linking to opengl32.lib in my project settings. This got rid of the first error, the one with the __imp__ prefix. After that there were only 7 unresolved external symbols. My project type is "Application (.exe)" if that's relevant. I'm out of ideas and tired of googling, does anyone know what to do?
On a broader note, I have wasted so many hours trying to get libraries to work in Python, Java, and C++. I am incredibly frustrated and I wish someone could just explain to me how libraries work once and for all so that next time I have a problem I won't be completely lost.
If all this setup is too complicated, you can also just take the Glitter project as a base. It takes care of all the boilerplate and just lets you get on with writing OpenGL. As a bonus, it is based on the cross-platform CMake build tool so your project should be easy to port to other operating systems.
I am trying to connect a database with the c++ program using OCILIB interface.
my program is:-
#include "ocilib.h"
int main(int argc, char *args[])
{
OCI_Connection *cn;
if (!OCI_Initialize(NULL, NULL, OCI_ENV_DEFAULT))
cout << "connection failed";
cn = OCI_ConnectionCreate("db", "usr", "pwd", OCI_SESSION_DEFAULT);
if (cn != NULL)
{
cout <<OCI_GetVersionServer(cn);
cout <<"Server major version : %i\n"<< OCI_GetServerMajorVersion(cn);
cout <<"Server minor version : %i\n"<<OCI_GetServerMinorVersion(cn);
cout <<"Server revision version : %i\n"<< OCI_GetServerRevisionVersion(cn);
cout <<"Connection version : %i\n"<< OCI_GetVersionConnection(cn);
OCI_ConnectionFree(cn);
}
OCI_Cleanup();
}
this code running in MSVisualstudio2015, I downloaded all OCI packages and set according to my environment..
i put linker path and additional include header files in project properties.
but when i building the application it shows.
1>------ Build started: Project: Testdatabase, Configuration: Debug x64 ------
1> Testing.cpp
1>Testing.obj : error LNK2019: unresolved external symbol OCI_Initialize
referenced in function main
1>Testing.obj : error LNK2019: unresolved external symbol OCI_Cleanup
referenced in function main
1>Testing.obj : error LNK2019: unresolved external symbol
OCI_ConnectionCreate referenced in function main
1>Testing.obj : error LNK2019: unresolved external symbol
OCI_ConnectionFree referenced in function main
1>Testing.obj : error LNK2019: unresolved external symbol
OCI_GetVersionServer referenced in function main
1>Testing.obj : error LNK2019: unresolved external symbol
OCI_GetServerMajorVersion referenced in function main
1>Testing.obj : error LNK2019: unresolved external symbol
OCI_GetServerMinorVersion referenced in function main
1>Testing.obj : error LNK2019: unresolved external symbol
OCI_GetServerRevisionVersion referenced in function main
1>Testing.obj : error LNK2019: unresolved external symbol
OCI_GetVersionConnection referenced in function main
1>c:\XXXXX\XXXXXX\documents\visual studio
2015\Projects\Testdatabase\x64\Debug\Testdatabase.exe : fatal error
LNK1120: 9 unresolved externals
========== Build: 0 succeeded, 1 failed, 0 up-to-date, 0 skipped ==========
I read some documentations about this problem , but i am not able to solve this problem , give me any solution..
You need to copy ociliba.dll from the ocilib archive (under lib32|64 folder) to the folder where your executable is generated.
I am writing a BCI game application in VC++ and require to implement Common Spatial Pattern Filtering (CSP) for feature extraction. Due to the hefty coding involved, I prefer to use an existing CSP Matlab function that I have. I followed the steps as given in here. However, I am getting the following Link error message:
1>------ Build started: Project: Test4, Configuration: Debug Win32 ------
1>test.obj : error LNK2019: unresolved external symbol _mxGetScalar referenced in function _main
1>test.obj : error LNK2019: unresolved external symbol _mxDestroyArray referenced in function _main
1>test.obj : error LNK2019: unresolved external symbol _mxCreateDoubleScalar referenced in function _main
1>test.obj : error LNK2019: unresolved external symbol _engEvalString referenced in function _main
1>test.obj : error LNK2019: unresolved external symbol _engOpen referenced in function _main
1>test.obj : error LNK2019: unresolved external symbol _engClose referenced in function _main
1>test.obj : error LNK2019: unresolved external symbol _engGetVariable referenced in function _main
1>test.obj : error LNK2019: unresolved external symbol _engPutVariable referenced in function _main
1>test.obj : error LNK2019: unresolved external symbol _engOutputBuffer referenced in function _main
1>D:\Test4\Debug\Test4.exe : fatal error LNK1120: 9 unresolved externals
========== Build: 0 succeeded, 1 failed, 0 up-to-date, 0 skipped ==========
Could anyone please help me fix the problem? Any comments would be appreciated. Thanks in advance.
As I said in the referred post, you have to keep the platforms consistent:
The platforms of MATLAB and VC++ compile platform must be the same, i.e. Win32/x86 VC++ compile platform can only use x86 MATLAB and x64 VC++ compile platform can only use x64 MATLAB.
You're using MATLAB x64, thus you have to build your VC project in x64 too.
As my hunt for a cross-platform framework/library went in progress, GLFW was mentioned many times. So, I decided to try it out. Now, it seems as though I can't even init a window. :-/
#include
#include
#include
int main(int argc, char *argv[])
{
int running = GL_TRUE;
srand(time(NULL));
if (!glfwInit())
exit(EXIT_FAILURE);
if (!glfwOpenWindow(300, 300, 0, 0, 0, 0, 0, 0, GLFW_WINDOW))
{
glfwTerminate();
exit(EXIT_FAILURE);
}
while (running)
{
glClear(GL_COLOR_BUFFER_BIT);
glClearColor(rand() % 255 + 1, rand() % 255 + 1, rand() % 255 + 1, 0);
glfwSwapBuffers();
running = !glfwGetKey(GLFW_KEY_ESC) && glfwGetWindowParam(GLFW_OPENED);
}
glfwTerminate();
exit(EXIT_SUCCESS);
}
I typed this in MVC++ 2010, linked the header, and 2 lib files (and it had 1 DLL file, so I threw that into the SysWOW64 folder), and I get these errors:
1>------ Build started: Project: glfwTest, Configuration: Debug Win32 ------
1> test.cpp
1>c:\users\andrew\documents\visual studio 2010\projects\glfwtest\glfwtest\test.cpp(8): warning C4244: 'argument' : conversion from 'time_t' to 'unsigned int', possible loss of data
1>c:\users\andrew\documents\visual studio 2010\projects\glfwtest\glfwtest\test.cpp(22): warning C4244: 'argument' : conversion from 'int' to 'GLclampf', possible loss of data
1>c:\users\andrew\documents\visual studio 2010\projects\glfwtest\glfwtest\test.cpp(22): warning C4244: 'argument' : conversion from 'int' to 'GLclampf', possible loss of data
1>c:\users\andrew\documents\visual studio 2010\projects\glfwtest\glfwtest\test.cpp(22): warning C4244: 'argument' : conversion from 'int' to 'GLclampf', possible loss of data
1>test.obj : error LNK2019: unresolved external symbol __imp__glClearColor#16 referenced in function _main
1>GLFW.lib(win32_window.obj) : error LNK2001: unresolved external symbol __imp__glClearColor#16
1>test.obj : error LNK2019: unresolved external symbol __imp__glClear#4 referenced in function _main
1>GLFW.lib(window.obj) : error LNK2001: unresolved external symbol __imp__glClear#4
1>GLFW.lib(win32_window.obj) : error LNK2001: unresolved external symbol __imp__glClear#4
1>GLFW.lib(win32_window.obj) : error LNK2019: unresolved external symbol __imp__wglGetProcAddress#4 referenced in function _initWGLExtensions
1>GLFW.lib(win32_glext.obj) : error LNK2001: unresolved external symbol __imp__wglGetProcAddress#4
1>GLFW.lib(win32_window.obj) : error LNK2019: unresolved external symbol __imp__wglMakeCurrent#8 referenced in function _createWindow
1>GLFW.lib(win32_window.obj) : error LNK2019: unresolved external symbol __imp__wglCreateContext#4 referenced in function _createContext
1>GLFW.lib(win32_window.obj) : error LNK2019: unresolved external symbol __imp__wglDeleteContext#4 referenced in function _destroyWindow
1>GLFW.lib(win32_window.obj) : error LNK2019: unresolved external symbol __imp__glGetFloatv#8 referenced in function __glfwPlatformSetWindowSize
1>GLFW.lib(win32_window.obj) : error LNK2019: unresolved external symbol __imp__glGetIntegerv#8 referenced in function __glfwPlatformSetWindowSize
1>GLFW.lib(glext.obj) : error LNK2001: unresolved external symbol __imp__glGetIntegerv#8
1>GLFW.lib(glext.obj) : error LNK2019: unresolved external symbol __imp__glGetString#4 referenced in function __glfwParseGLVersion
1>c:\users\andrew\documents\visual studio 2010\Projects\glfwTest\Debug\glfwTest.exe : fatal error LNK1120: 9 unresolved externals
========== Build: 0 succeeded, 1 failed, 0 up-to-date, 0 skipped ==========
I understand the first few with the random colors, but the ones after that make no sense to me. Any idea what's wrong with this?
I'm pretty sure that I have linked the libs correctly. I place them into the
C:\Program Files (x86)\Microsoft Visual Studio 10.0\VC\lib directory
and even linked them to my
C:\SDK\GLFW\glfw-2.7.bin.WIN32\lib-msvc100\debug directory.
The GLFW package was a .zip file, so I just extracted it to my default SDK folder (for all my APIs and other stuff). So the C:\SDK\GLFW is my default for GLFW.
You need to link to opengl32.lib.
For that, as pictured below, go to Project Setting and then Linker > input > Additional Dependencies and add opengl32.lib there (use ; to separate different libs).
Note that you don't actually need to have opengl32.lib file anywhere. Visual Studio knows where to find it.
Edit: I should note that you don't need to do anything except adding opengl32.lib. That other stuff is irrelevant. Additionally, if both are present, try swapping the order, which matters in some cases.