Ms Visual Studio 2012, "unresolved external symbol" - c++

I am trying to compile a C++ application through Microsoft Visual Studio 2012. I have linked the Boost, Jni, Acml libraries to the application.
When I click on rebuild, the compilation does not finish.
This is the first error I get:
Error 28 error LNK2019: unresolved external symbol _sgesdd referenced
in function "void __cdecl testLapackDGESDD_EASY(void)"
(?testLapackDGESDD_EASY##YAXXZ) C:\Users\DavideChicco\Documents\Visual
Studio 2012\Projects\Solution\mainConsole.obj
Do you have any idea of what this is related to?
Thanks

Your compilation seems to have finished, but the error happens during linking: the definition of the function _sgesdd called in testLapackDGESDD_EASY is not found. So
- either this function is defined in an external dll, and you need to add the lib in your solution,
- or this function is supposed to be defined in your project, and you need to implement its definition.

aha, The compiler cant't find the function "_sgesdd", I recommend you that add the lib which is supplied by the author of DLL.

Related

Unresolved external symbol symbol __imp_get_function_ptr when compiling a C++ MEX MATLAB API

I am trying to run one of the example codes from the CPP Mex Repository of Matlab R2021a in the VS2017 IDE. Specifically, I am running the phonebook.cpp one. I previously ran with no problems when compiling other solutions in VS2017 with the C Mex API following this guide. However, I get the following message when compiling phonebook.cpp:
Severity Code Description Project File Line Suppression State
Error LNK2019 unresolved external symbol __imp_get_function_ptr referenced in function "int (__cdecl*__cdecl matlab::data::detail::resolveFunction<int (__cdecl*)(int,int,bool *)>(enum matlab::data::detail::FunctionType))(int,int,bool *)" (??$resolveFunction#P6AHHHPEA_N#Z#detail#data#matlab##YAP6AHHHPEA_N#ZW4FunctionType#012##Z) test C:\Users\DuuMushishi\Documents\test.obj 1
I am not sure what library needs to be added or if the error is due to something else
I fixed the issue. Turns out I had to include in additional dependencies "libMatlabDataArray.lib" (in my case, located in C:\Program Files\MATLAB\R2021a\extern\lib\win64\microsoft)

error LNK2019 unresolved external symbol when trying to link dll

I know many people have asked about this error and trust me I've read ALL of them and followed all the steps! But I'm still getting the unresolved external symbol error.
I'm trying to use the dll of lp_solve (a linear programming package) in my c++ code in visual studio 2012.
The error message I'm getting is:
Error 80 error LNK2019: unresolved external symbol _make_lp#8 referenced in function "void __cdecl my_solve(BLAH BLAH)
The function make_lp() is from the lp_solve package and I'm calling it from my_solve() in my code. This error message pops up for each solver function I call. Seems the linker just couldn't find any of the implementation of these functions.
I've done the following
put #include "lp_lib.h" in my source code
put the .dll, .h and .lib files from the lp_solve package in the working directory and
added the path under Linker:General:Additional Library Directories.
added the lib under Linker:Input:Additional dependency
What's wrong?
Thanks for your help!
The problem I had was solved after realizing I downloaded the WIN64 package for lp_solve but my visual studio is using WIN32 as build platform (even though my machine is x86_64).
Using extern "C" may be helpful while including lp_lib.h in your .cpp as follows:
extern "C"
{
#include "lp_lib.h"
}
For more information, please check this link:
http://www.geeksforgeeks.org/extern-c-in-c/

C++: Unresolved external symbol _sprintf and _sscanf in Visual Studio 2015

For a research project, I'm writing a C++ add-on to a scientific computing language. Unfortunately the library that allows users to do this is not kept very well up-to-date.
I started the project in XCode, where it built fine. Later I had to move to a PC, so I migrated the code to Visual Studio 2015. Since doing this, I haven't been able to build due to the following errors:
LNK2001 : unresolved external symbol _sprintf
LNK2019 : unresolved external symbol _sscanf referenced in function _GetDDouble
LNK2019 : unresolved external symbol _sprintf referenced in function _CheckRunningInMainThread
An attempted fix was to add the header #define _CRT_SECURE_NO_WARNINGS. However, this a) fixed no errors and b) added the warning C4005 : '_CRT_SECURE_NO_WARNINGS': macro redefinition. I assume the library already defined this macro, anticipating this problem. Regardless, it didn't solve the problem.
How should I proceed?
Add the following library to the linker input files:
legacy_stdio_definitions.lib
VS 2015 now uses inline definitions that call internal functions for many of the stdio.h functions. If an object file (or library member) depends on one of those functions, then the legacy_stdio_definitions.lib provides an externally linkable version of the function that can be linked to.
Your other option is to recompile the unit that depends on those functions with VS 2015 (this is probably the preferred option).
I got this error compiling cycling max plugins against version 5 max sdk (pure c api). The legacy library fix didn't work for me (it should have, and if anyone had any idea why it mightn't I'd be curious), but I defined _NO_CRT_STDIO_INLINE before stdio was loaded and that did do the trick.
I recently encountered this and was able to add User32.lib to Linker > Input > Additional Dependencies.
You could also include #pragma comment (lib, "User32.lib") in your code.

OpenSSL - LNK 2019

I'm getting LNK 2019 when trying to link in the OpenSSL libraries for a project I'm working on. I compiled the OpenSSL libraries and ran the test and all of them passed. I played with openssl.exe and got it to correctly create and MD5 hash. When I try to use the functions provided by the API though, it just won't recognize them. I even used dumpbin -headers on the .lib files to make sure that the ones I was using contained the correct references for the functions I was using.
I made sure to include the correct files and paths (I also included the header which isn't pictured here).
Here are the actual files and their paths
Here's the actual errors.
error LNK2019: unresolved external symbol _EVP_MD_CTX_create referenced in function _main
error LNK2019: unresolved external symbol _EVP_DigestInit_ex referenced in function _main
error LNK2019: unresolved external symbol _OpenSSL_add_all_digests
referenced in function _main error LNK2019: unresolved external symbol
_EVP_get_digestbyname referenced in function _main error LNK1120: 4 unresolved externals
How do I fix this? Did I put the files in the right place or did I forget an include? I've spent a few days trying to fix this already, this is my last resort :/
Im using Microsoft Visual Studio 2012
This can be problem with calling conventions.
Please check the project setting regarding calling convention.
OpenSSL compiles with /Gd option that means function will be of __cdecl calling convention.
You can either change your calling convention to /Gd or prefix OpenSSL function signatures which you are using with __cdecl.
I believe that this might help. This link explains how to change calling convention.
Please confirm if this can help you.
I was building for x86 when I should have been building with x64. As the x64 option did not show up in the menu, I thought it was unavailable to me. I realized that I had to add it under the project properties and now everything works fine.
Thanks for all the help.

Can a CWinApp be placed in a DLL?

I'm updating some legacy apps to Visual Studio 10 and am in linker hell. All of these DLLs derive classes from CWinApp and use AfxGetApp() to get access to the object. When I link the DLLs I get unresolved externals that look like global static objects that would get pulled in by a normal app's main():
Shell.lib(SHELL.obj) : error LNK2001: unresolved external symbol "public: static struct CRuntimeClass const CException::classCException" (?classCException#CException##2UCRuntimeClass##B)
Shell.lib(SHELL.obj) : error LNK2001: unresolved external symbol "public: static struct CRuntimeClass const CFrameWnd::classCFrameWnd" (?classCFrameWnd#CFrameWnd##2UCRuntimeClass##B)
Shell.lib(SHELL.obj) : error LNK2001: unresolved external symbol "public: static class CRect const CFrameWnd::rectDefault" (?rectDefault#CFrameWnd##2VCRect##B)
My current combination of ignore default libraries and additional libraries (the method you can easily google to find the answer to linker hell) is: msvcprtd.lib,mfc100d.lib,mfcs100d.lib,libcmtd.lib
When I add nafxcwd.lib (the mfc library), these three external symbols resolve but I end up with a bunch of other duplicate symbols (requiring the use of /FORCE:MULTIPLE) and in end ___argc and ___argv become unresolved.
So the basic question is: Can you link a DLL containing a CWinApp in VS10? How do you setup the linker to do it?
Can you link a DLL containing a CWinApp in VS10?
When I create a new project in Visual Studio 10 and use the MFC DLL template, I found the template code itself includes a class derived from CWinApp. Of course the template compiles and links fine, so the answer to this question is a most definite yes.
I searched for definitions to those objects that your linker is complaining about and I found them in afx.h and afxwin.h, inside Visual Studio's include directory, packaged with the rest of the ATL and MFC code that is included with Visual Studio when you install it.
Are you using the express edition by chance? One of the few differences between the express edition and the pro edition of Visual Studio 2010 is that ATL and MFC applications won't compile in the express edition. You have to use the pro edition.