I am trying to built a .cpp file using OpenNI in Visual Studio 2012. I am using the code of the SimpleViewer sample (it is included in the OpenNI). When I try to build the .cpp file I got the error LNK2019 which it seems a problem when the compiler has to link the OpenNI library. What could be wrong?
Errors (55 in total):
> Error 1 error LNK2019: unresolved external symbol __imp__oniShutdown
> referenced in function "public: static void __cdecl
> openni::OpenNI::shutdown(void)"
> (?shutdown#OpenNI#openni##SAXXZ) C:\Develop\VisualStudioWorkspace\Projects\My
> programs\OpenNI2_test\OpenNI2_test\Viewer.obj OpenNI2_test
Error 2 error LNK2019: unresolved external symbol __imp__oniWaitForAnyStream referenced in function "public: static enum openni::Status __cdecl openni::OpenNI::waitForAnyStream(class openni::VideoStream * *,int,int *,int)" (?waitForAnyStream#OpenNI#openni##SA?AW4Status#2#PAPAVVideoStream#2#HPAHH#Z) C:\Develop\VisualStudioWorkspace\Projects\My programs\OpenNI2_test\OpenNI2_test\Viewer.obj OpenNI2_test
I followed all the steps described in the OpenNI website to compile a file in Visual Studio: I added all the VCC Directories and the Include and Lib environment variables. I also added OpenNI2.lib in the additional dependencies on the Linker section. I also copied the Redist files in the working directory (the directory where I have the .vcproj).
I ran into a similar issue. The sample projects wouldn't build because I was using OpenNI for x64 but the platform was set to Win32. Changing to x64 (in the properties dialog at the top) fixed it for me.
OpenNI 2.0 is not mature enough. Most of the libraries, open source codes, examples and wrappers still use OpenNI 1.5. The integration is not easy since OpenNI2 uses the Microsoft official drivers and OpenNI1.x uses the open source drivers. The 32bit version gives less problems than the 64bits but I ended up installing and working the OpenNI 1.5 and the Kinect non-official drivers.
The problem is related to the linking process. You may have wrong link path in the properties of your projects. There is solution, check this question
maybe it works in your case!
Related
I am trying to link pcre.lib in my metro app on visual studio 2013. I want to use the library in a .cpp file (the pcre project contains .c files).
I tried to build pcre project and use the generated lib file and the original headers. The problem is on compiling, because on each function i use from pcre library it says (the next example is for pcre_study function) :
error LNK2001: unresolved external symbol __imp_pcre_study
I want to mention that i linked the .lib file correctly and i added all the paths required. Probably the problem is when i am building the pcre project.
Can anyone help me ?
I'm trying to link a Windows executable that depends on a several static libraries (some of which I have built, some of which I have not). When I do the link, I get a flock of errors like:
LIBCMT.lib(mlock.obj) : error LNK2005: _unlock already defined in MSVCRT.lib(MSVCR100.dll)
which is the classic /MD vs. /MT problem (whether the C runtime is statically or dynamically linked). I tried the easy solution first, adding the linker flags
/nodefaultlib:libcmt /nodefaultlib:libcpmt
but that just gave different errors:
msvcprt.lib(MSVCP100.dll) : error LNK2005: "public: __cdecl std::_Locinfo::~_Locinfo(void)" (??1_Locinfo#std##QEAA#XZ) already defined in gtest.lib(gtest-all.cc.obj)
gtest.lib(gtest-all.cc.obj) : error LNK2001: unresolved external symbol "private: static int std::locale::id::_Id_cnt" (?_Id_cnt#id#locale#std##0HA)
I've gone through the libraries I'm building, and as far as I can tell I'm building them all /MD. I say "as far as I can tell" because some of them are third-party libraries that come with their own makefiles so I don't have complete control over the build process..
I don't think "depends" works on libraries (only EXEs and DLLs), is there a tool that would let me look at the various libraries I'm linking in, and see which one is bringing in libcmt when I want to be using msvcrt instead?
I have had the same problem and I used dumpbin ( http://msdn.microsoft.com/en-us/library/z66yd3h6.aspx ) with /DIRECTIVES options on the libs. It will show a number of /DEFAULTLIB sections, each one is another lib that your lib try to use. Dumpbin needs to run from the Visual Studio command promt.
dumpbin /DIRECTIVES liblua52.lib
I had 100+ libs with all the solution configurations and platforms so I made a python 2.7 script (crtdisplay.py) to do it for me. It can be found on my bitbucket repository at https://bitbucket.org/vimarina/ctrlcv/src/57b7ddca15b5c7fefddcf20ffcea0633223a4bd6/crtdisplay . Put it in the root directory of your libs. Not much error checking in that code so do not be surprised if it fails :). I used Visual Studio 2010 so might fail on other versions of Visual Studio.
crtdisplay.py > info.txt
I'm having trouble to compile VTK 5.10.1 example code in Visual Studio 2010 on Windows 7 64 bit SP1.
First of all, I installed VTK using this tutorial.
No errors occured while installing VTK and the example executables like cone.exe located at C:\VTK5.10.1_cmake\bin\Release are running just fine.
In Visual Studio 2010 I started a new Win32 console application and tested the first example code from this site.
I edited the projekt properties (additional include directories, additional Library directories and additional dependencies).
The linker errors looked like that:
vtktest.obj : error LNK2019: unresolved external symbol ""public: void __thiscall vtkRenderer::AddActor(class vtkProp *)" (?AddActor#vtkRenderer##QAEXPAVvtkProp###Z)" referenced in function "_main".
Most of the the other people with the same error forgot to add the libs to the additional dependencies.
However I added all libs in the C:\VTK5.10.1_bin\lib\vtk-5.10 directory and the opengl32 library. I tried to seperate the libs by a space, a semicolon and a new line.
Then, I read that people are using the shared libraries. I'm not really familiar with dlls. I reinstalled VTK
with shared libraries options turned on and copied the resulting dlls to the System32 directory.
Now, the errors looks slightly different:
vtktest.obj : error LNK2019: unresolved external symbol ""__declspec(dllimport) public: void __thiscall vtkRenderer::AddActor(class vtkProp *)" (__imp_?AddActor#vtkRenderer##QAEXPAVvtkProp###Z)" referenced in function "_main".
Any help would be appriciated!
Nevermind, forgot to change the platform to x64 :/
I'm using CMake to build a Qt based application of mine on Windows with Visual Studio 2010 Express. When configuring with cmake I get the following error:
System runtime library file does not exists:
'MSVC10_REDIST_DIR-NOTFOUND/x86/Microsoft.VC100.CRT/msvcp100.dll
System runtime library file does not exists:
'MSVC10_REDIST_DIR-NOTFOUND/x86/Microsoft.VC100.CRT/msvcr100.dll
Then when I try to compile, I'm getting this error (both trying in Visual Studio, and with msbuild):
MSVCRT.lib(crtexew.obj) : error LNK2019: unresolved external symbol _WinMain#16 referenced in function ___tmainCRTStartup
C:\Users\Kurtis\sandbox\UDJ-Desktop-Client\build\src\Release\UDJ.exe : fatal error LNK1120: 1 unresolved externals
I determined that Microsoft Visual C++ 2010 Express doesn't come with the redistributable that I need. So I went to Microsoft's website to download the redistributable (both for x86 and x64). However, after installing it, I'm still getting the above configure and compile errors. Does anyone know what I'm doing wrong, or how to fix my problem?
_WinMain#16 is the entry point of a Windows GUI application, so either it's missing from your source code, or you're not writing a GUI application, in which case your linker flags are incorrect.
Since you're using qt, make sure you have the QtMain Library being linked with your project. You can do this by adding it in your call to Find_Package like so:
find_package(Qt4 4.7.0 COMPONENTS QtMain QtCore QtGui QtSQL Phonon REQUIRED)
I've been attempting to install glew and freeglut to use with Visual Studio 2010. I followed this guide and have backtracked a few times to make sure I followed it correctly but I still get the following errors when I try and compile the example code at the end:
Error 1 error LNK2019: unresolved external symbol _imp_glutMainLoop#0 referenced in function _main c:\Users\Esteban\documents\visual studio 2010\Projects\Chapter 1 Project\Chapter 1 Project\main.obj Chapter 1 Project
Error 2 error LNK2019: unresolved external symbol _imp_glutDisplayFunc#4 referenced in function _InitWindow c:\Users\Esteban\documents\visual studio 2010\Projects\Chapter 1 Project\Chapter 1 Project\main.obj Chapter 1 Project
Error 3 error LNK2019: unresolved external symbol _imp_glutReshapeFunc#4 referenced in function _InitWindow c:\Users\Esteban\documents\visual studio 2010\Projects\Chapter 1 Project\Chapter 1 Project\main.obj Chapter 1 Project
Error 4 error LNK2019: unresolved external symbol _imp_glutInitDisplayMode#4 referenced in function _InitWindow c:\Users\Esteban\documents\visual studio 2010\Projects\Chapter 1 Project\Chapter 1 Project\main.obj Chapter 1 Project
and more just like those. I don't know if its a problem but originally I accidentally grabbed the 64bit version. I realized my mistake and overwrote the files with the 32bit versions, then cleaned and attempted the build again with the same result.
Are you sure that you have done "Step 6: Project Settings (Linker)" in linked guide correctly? It seems that the linker is unable to find symbols that are defined in those libraries (glew and glut32.lib). Also make sure that the Visual Studio knows where to find those libraries (Project->Properties->Configuration properties->VC++ Directories->Library Directories).
All the unresolved external symbols should be found in freeglut.lib. Are you sure that you are properly linking to this library?
Instead of trying to accomplish this in the you could just insert the following line of code in one of your header files:
#pragma comment(lib, "freeglut.lib")
I had this problem too. It turns out I was using the express version of visual studios, so I had to download microsoft sdk to get 64bit openGL libraries. Basically, I found this guide more helpful: http://www.cs.uregina.ca/Links/class-info/315/WWW/Lab1/GLUT/windows.html