I am getting the following error.
error LNK2001: unresolved external symbol __localtime64_s
On searching on the internet i found that there is a library WINMM.LIB which is needed to be included. So i added this library in the project options.
But,it still does not help.
Can somebody help in this?
The _s suffix indicates that its actually probably one of the "safe" apis added to Visual Studio 2005 or 2008. There are two leading _'s - the first indicates the function decoration - an extern "C" function using the __cdecl calling convention. The next '_' inidcates that the functions is an OEM (Microsoft in this case) extension to the c-runtime library.
Specifically it seems to be a worker function invoked from 'Program Files\Visual Studio\VS\include\time.inl' when the safe 'localtime' function is called.
So, at a guess I would say that you are not linking in the c-runtime libraries correctly into your application. Are you using any options like "exclude default libraries" or are excluding any specific libraries in your projects settings?
Related
I have researched more into the problem and posted a more detailed question with my findings here: Rust, how to use global variable from DLL? C++ equivalent requires __declspec(dllimport)
Original question:
Summary:
When linking my project with MSVC 2019's link.exe, I am getting errors such as unresolved external symbol jl_module_type. These symbols are defined in a file julia.lib, which I have verified using dumpbin /exports julia.lib. This file is passed as an argument to link.exe, and yet, it still complains about unresolved symbols. It looks like all the symbols that failed to be linked are variables rather than functions.
More information:
julia.lib has been renamed from libjulia.dll.a, and it corresponds to another file libjulia.dll. They were built with Cygwin/MinGW, but AFAIK this should not affect things. The actual project this is being used in is written in Rust, so link.exe is being invoked automatically by Rust's cargo tool. It is configured to build my project as a DLL.
dllmain.cpp(16): warning C4447: 'main' signature found without threading mode
l. Consider using 'int main(Platform::Array<Platform::String^>^ args)'.
Above is a warning I got from building a Windows Store App DLL project. I didn't change anything in that default dllmain.cpp file except for including my own version of pch.
The documentation for this warning (along with many VS2012 errors/warnings) is nowhere to be found on MSDN and here is the only relevant link I can find:
http://social.msdn.microsoft.com/Forums/en-US/vssetup/thread/6daa9587-fe54-4e84-a8b9-0e5c52c2f6e8/
and the op there didn't get an answer.
If anyone knows what it means and how to fix it, it would be great!
As far as I can tell, you can safely ignore the warning. The compiler cribs when it sees a Win32-style DllMain being compiled using the /ZW flag (Consume Windows Runtime Extensions). However, the function gets called as you'd normally expect.
Alternatively, you can work around the warning by compiling dllmain.cpp without /ZW. You might need to adjust the PCH settings for this to properly work. This is the path taken by the DLL (Windows Store apps) C++/CX project template in Visual Studio.
Incidentally, the reason you do not get the warning when you're trying to build a Windows Runtime Component project (which builds everything using /ZW) is that a Windows Runtime Component doesn't declare a DllMain. This is not to say that it can't; it just picks up the dummy DllMain that the CRT defines (which basically turns off per-thread initialization and reports success).
I have a tlb files that contains some function declaration that I need to use.
If I use
#import "type_library.tlb"
I can correclty reference the function from my code:
tlb_namespace::required_function();
But when I compile the project the linker says that tlb_namespace::required_function is an unresolved external symbol.
How can I succesfully build this kind of project?
EDIT:
I have used the same type library in a Dummy VBA access project. I have added the reference to the type library and I have noticed that some of the function contained in the type library are correctly called. But some of them are not. VBA says It can't locate their entry point in the related dll.
Can this explain the unresolved external symbol when building c++ app?
I have also noticed that the failing function are declared in the tlb like this:
UPPER_function_name
but in the dll are declared like this:
Upper_function_name
Can this be the issue?
Is it possible to solve this kind of error directly modifying the binary tlb file or dll?
Use IDE to view TLB information.
Use this help : How to: View Type Library Information
At IDE : View-> Object Browser, click "..." Edit Custom Component Set, browse your TLB file and Add to view information.
Confirm namespace used for.
use the namespace to resolve the linker error:
example:
#import "<>" raw_interfaces_only
using namespace <>
this will resolve the problem
By default, Visual Studio compiles a project to use the Multi Threaded DLL, found in the Visual Studio runtime. I want to compile my program using only /MT instead of /MD. Granted, that most systems already have this installed, and it's also available as a re-distributable.
When I change /MD to /MT, I get an error:
MSVCRTD.lib(MSVCR100D.dll) : error LNK2005: _free already defined in LIBCMT.lib(free.obj)
And four or five similar errors.
To try and fix this I removed LIBCMT.LIB from the default libraries.
I then get the error:
libcpmt.lib(_tolower.obj) : error LNK2019: unresolved external symbol __calloc_crt referenced in function __Getctype
Removing MSVCRTD.lib from the default list leads to similar errors?
It should be noted that:
-This is an OpenGL project, using the glfw library.
-I am using the SOIL image library by lonesock for texture loading.
Without any further precise information, I would say your first problem is that you're somehow mixing release and debug versions of libraries. MSVCRTD.lib is the debug version of MSVCRT.lib.
Either you have some debug settings hanging around in your own projects, or you're linking against debug versions of libraries you're using.
Never ever mix debug and release versions. If you're lucky you get an error like this. In some rare situations all magically seems to work until it doesn't.
I needed help making sense out of the following LNK error which i am getting.
SwitchFunctions error LNK2019: unresolved external symbol "__declspec(dllimport) ??$?8DU?$char_traits#D#std##V?$allocator#D#1##std##YA_NABV?$basic_string#DU?$char_traits#D#std##V?$allocator#D#2##0#PBD#Z" (__imp_??$?8DU?$char_traits#D#std##V?$allocator#D#1##std##YA_NABV?$basic_string#DU?$char_traits#D#std##V?$allocator#D#2##0#PBD#Z) referenced in function "??$find#Viterator#?$vector#V?$basic_string#DU?$char_traits#D#std##V?$allocator#D#2##std##V?$allocator#V?$basic_string#DU?$char_traits#D#std##V?$allocator#D#2##std###2##std##PBD#std##YA?AViterator#?$vector#V?$basic_string#DU?$char_traits#D#std##V?$allocator#D#2##std##V?$allocator#V?$basic_string#DU?$char_traits#D#std##V?$allocator#D#2##std###2##0#V120#0ABQBD#Z" (??$find#Viterator#?$vector#V?$basic_string#DU?$char_traits#D#std##V?$allocator#D#2##std##V?$allocator#V?$basic_string#DU?$char_traits#D#std##V?$allocator#D#2##std###2##std##PBD#std##YA?AViterator#?$vector#V?$basic_string#DU?$char_traits#D#std##V?$allocator#D#2##std##V?$allocator#V?$basic_string#DU?$char_traits#D#std##V?$allocator#D#2##std###2##0#V120#0ABQBD#Z)
Have you checked whether you have included all necessary dlls or lib files in your project settings?
Such an error usually indicate that you have used a function which definition is found, but implementation is not. Usually in the case of external libraries, the implementation is inside a dll or a static lib. Failure to provide the dll or the static lib will cause the linking to fail.
Which version of Visual Studio are you using? This might be relevant for VS2005:
Link error using a CString derived class from a DLL