Visual Studio 2019: LNK2019: unresolved external symbol error in Release mode - visual-studio

I have a visual studio solution with 3 projects. 2 are DLL. The DLL library from one project is linked to the other via linker. The program runs in Debug mode. But in release mode, it shows LNK2019: unresolved external symbol error. This means the linking is not functioning properly. I rechecked the linker input files and the project dependencies if done properly.

Related

Use Nlopt Library in a Fortran project with Visual Studio on Windows

I have been using the NLopt library in my Fortran projects and I have no problem running it under Linux system. Now I just started using the Visual studio on Windows to write my Fortran programs. However, I am having some difficulties to use the NLopt library on Windows. I am using Visual Studio 2013 and Intel Parallel Studio XE 17 on my computer.
Here are what I have done and the problems that I have encountered:
I downloaded the Windows version (64 bit) of NLopt library from its website. Then I use the developer command prompt for VS to execute lib /def:libnlopt-0.def \MACHINE:x64 and it creates a .lib and .exp file under the same folder.
I created a Fortran project in Visual Studio with and use the code that was been working under Linux. In Visual Studio, I added the path to the .lib and .exp to "Additional Include Directories" and "Additional Library Directories" to the project property. I also added "libnlopt-0.lib" and "libnlopt-0.exp" to "Additional Dependencies".
When I compile the project, it fails with the errors:
1>mod_nlopt.obj : error LNK2019: unresolved external symbol NLO_CREATE referenced in function MOD_NLOPT_mp_SUB_NLOPT
1>mod_nlopt.obj : error LNK2019: unresolved external symbol NLO_SET_FTOL_ABS referenced in function MOD_NLOPT_mp_SUB_NLOPT
1>mod_nlopt.obj : error LNK2019: unresolved external symbol NLO_SET_FTOL_REL referenced in function MOD_NLOPT_mp_SUB_NLOPT
1>mod_nlopt.obj : error LNK2019: unresolved external symbol NLO_SET_XTOL_ABS referenced in function MOD_NLOPT_mp_SUB_NLOPT
1>mod_nlopt.obj : error LNK2019: unresolved external symbol NLO_SET_XTOL_REL referenced in function MOD_NLOPT_mp_SUB_NLOPT
1>mod_nlopt.obj : error LNK2019: unresolved external symbol NLO_SET_LOWER_BOUNDS referenced in function MOD_NLOPT_mp_SUB_NLOPT
1>mod_nlopt.obj : error LNK2019: unresolved external symbol NLO_SET_UPPER_BOUNDS referenced in function MOD_NLOPT_mp_SUB_NLOPT
1>mod_nlopt.obj : error LNK2019: unresolved external symbol NLO_SET_MAX_OBJECTIVE referenced in function MOD_NLOPT_mp_SUB_NLOPT
1>mod_nlopt.obj : error LNK2019: unresolved external symbol NLO_ADD_INEQUALITY_CONSTRAINT referenced in function MOD_NLOPT_mp_SUB_NLOPT
1>mod_nlopt.obj : error LNK2019: unresolved external symbol NLO_OPTIMIZE referenced in function MOD_NLOPT_mp_SUB_NLOPT
1>mod_nlopt.obj : error LNK2019: unresolved external symbol NLO_DESTROY referenced in function MOD_NLOPT_mp_SUB_NLOPT
Then I followed the suggestions [here] (http://nlopt-discuss.ab-initio.mit.narkive.com/M3vzZMYA/nlopt-linked-to-intel-fortran-compiler-for-windows) and added /names:lowercase to the command line and now it compiles fine but with one warning:
libnlopt-0.exp : warning LNK4070: /OUT:libnlopt-0.dll directive in .EXP differs from output filename 'x64\Release\baseline.exe'; ignoring directive
Although it compiles fine, I still cannot run my compiled code. When I run it, my computer tells me that This APP cannot run on your PC. To find a version for your PC, check with the software published. Then the command window shows Access denied and then the program stops.
I really do not know what I can do next to make my code work. I know there are many people use NLopt in Windows.
I just figured out the solution. For the second step above, I should only put "libnlopt-0.lib", but not "libnlopt-0.exp" to "Additional Dependencies" in Visual Studio project property. After that, I copied "libnlopt-0.dll" to the working directory of my program. Then my program can run without any problem!

Linking tesseract and opencv in Visual Studio 2013 on x64 bit machine

I'm trying to run a program based on tesseract and opencv on Visual Studio 2013. I have a x64 bit machine and the problem is when I run it under Win32 I got only opencv linking errors, however under x64 I got tesseract linking errors.
Here are some errors screenshots :
Tesseract Errors :
error LNK2001: unresolved external symbol pixDestroy
error LNK2001: unresolved external symbol pixReadTesseract
error LNK1120: 7 unresolved externals
Opencv Errors :
error LNK2001: unresolved external symbol _cvLoadImage
error LNK2001: unresolved external symbol _cvCreateImage
error LNK2001: unresolved external symbol _cvSaveImage
error LNK2001: unresolved external symbol _cvReleaseImage
error LNK1120: 4 unresolved externals
Thank you guys :-)
Your problem appears to be that you have 32bit build of Tesseract and 64bit build of OpenCV, and trying to use them both in the same program. That will not work -- you either need all 64bit libraries for a 64bit application, or all 32bit libraries for a 32bit application.
If you want to stick with OpenCV 3.1 (since the standard distribution package doesn't seem to contain 32bit binaries), then you have to go and build one of the libraries yourself. The older versions still had them.
Another option is to download this nuget package along with the associated redistributables package. Since the files are just ZIP files with a different extension, it is possible to extract all the headers, import libraries and DLLs manually.

Visual Studio Errors

I have a problem with visual studio. I get these two errors every time I try to compile any project.
Any help how I could resolve this or should I just re-install it ?
error LNK2019: unresolved external symbol WinMain#16 referenced in
function__tmainCRTStartup
error LNK1120: 1 unresolved externals
I think you need to do some changed in your setting like this:
Project properties -> C/C++ -> Linker -> System -> SubSystem: Console
(/SUBSYSTEM:CONSOLE)

Can't Install MSVCP100.dll

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)

Problems with freeglut glew in Visual Studio 2010

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

Resources