LNK2019 errors on project that has identical properties to another one that works - c++

Using Visual Studio Community 2017
I have 4 projects:
Static library project that uses GLFW and couple other libraries
ProjectA which uses that library, compiles fine
ProjectB which also uses that library, compiles fine
ProjectC which I recently created and uses the library, does not compile
ProjectC has the same properties as ProjectB and ProjectA, nothing should be different, right?
But somehow, I get these errors when compiling ProjectC:
glfw3.lib(context.obj) : error LNK2001: unresolved external symbol
__imp___stdio_common_vsscanf
audio.lib(au.obj) : error LNK2001: unresolved external symbol
__imp__stricmp
I tried building GLFW and Audio library from their sources and replaced the project ones with newly built ones, no effect.

Once again, I somehow managed to untick "Inherit from parent or project defaults" checkbox in Additional Include Directories.
Check your checkboxes everybody!

Related

Include all source file for build

I have C++ project in my Visual Studio. Additionally I placed directory with source files in it in order to use them like library in my main project.
Everything works fine while code browsing. I can define includes of library headers and navigate to functions.
I got problem during project build. I got a lot of linking errors which tells that system can't link to functions from library.
Error LNK2019 unresolved external symbol lv_task_create referenced in function monitor_init testLVGL C:\cpp_test\testLVGL\monitor.obj 1
Error LNK2019 unresolved external symbol lv_tick_inc referenced in function "int __cdecl tick_thread(void *)" (?tick_thread##YAHPEAX#Z) testLVGL C:\cpp_test\testLVGL\testLVGL.obj 1
Error LNK2019 unresolved external symbol lv_task_handler referenced in function SDL_main testLVGL C:\cpp_test\testLVGL\testLVGL.obj 1
Looks like Visual C++ is even not trying to build library.
How to tell Visual C++ to include all library files located in subdirectory in order to build and link to project?
Visual Studio does not include all the files in a directory on its own. You need to explicitly include them (you dont have to do this if you add a file within the Solution Explorer or within Visual Studio). Else it wont be listed to the compiler.
To include them, go to the solution explorer and select "Show all files". This will show you all the files in the directory. Then you can see the unlisted files marked with a red icon. Right click it and hit "Include in project" and the red icon will disappear. After this, the file will be listed as one of the project's file.

SCIP and Visual Studi: error LNK2019

I want to solve the n-queens problem using SCIP (version 3.2.1) in Visual Studio 2010 (version 10.0.40219.1).
Source files can be found here: http://scip.zib.de/download/files/Queens.tgz
I did not write any code myself, but just included queens.hpp, scip_exceptions.hpp, queens.cpp and queens_main.cpp in my VS project.
In the project properties I did the following:
C/C++ -> General -> Additional Include Directories -> C:\scipoptsuite-3.2.1\scip-3.2.1\src\.
When building, I get errors like:
LNK2019: unresolved external symbol SCIPaddCons referenced in function "public: __thiscall cipexamples::QueensSolver::QueensSolver(unsigned int)"
I understand that I will have to link SCIP libraries to my project? But I do not know which ones and where to find them?
You need to compile the SCIP Optimization Suite first to obtain the libscipopt that you need to link to your project. It will contain everything necessary to work with SCIP.
Alternatively, you may also just use the precompiled dlls from the webpage:
http://scip.zib.de/#download

Visual Studio 15 __imp___iob, __imp___pctype, __imp___mb_cur_max

I am trying to use a library compiled with mingw in visual studio. However, I get the following linker errors:
error LNK2001: unresolved external symbol __imp___iob
error LNK2019: unresolved external symbol __imp___pctype referenced in function
error LNK2019: unresolved external symbol __imp____mb_cur_max referenced in function
error LNK2001: unresolved external symbol _fprintf
I was able to fix the _fprintf error by linking against legacy_stdio_definitions.lib as per this post : unresolved external symbol __imp__fprintf and __imp____iob_func, SDL2.
However, I have no idea how to fix the other three unresolved externals. How can I fix this? The libraries work perfectly under Visual Studio 2013.
Edit:
Okay here is an update. I moved libmsvcrt.a from the mingw lib folder into Visual Studio, and I added that to the linker settings. Now it seems to work correctly.
The libraries were compiled against an old version of the CRT. The unresolved symbols you get are internal symbols of the CRT that are present in the compiled library. You have to recompile the library against the VS2015 CRT (the Universal CRT). But I'm not sure if MinGW supports this.
If you can't do that, you have to continue to use the VS2013 compiler. (You can use the VS2015 IDE, by setting the toolset to vs2013 in the project options. But you'll still be limited to the C++ features the 2013 compiler supports.)
I encountered the same problem (library compiled with static CRT instead of CRT in DLL) and I managed to make it work by changing the two following parameters in Project Properties:
Linker > Input > Ignore specific default libraries: libc.lib
C/C++ > Code Generation > Runtime Library: Multi-threaded Debug (/MTd)
If that's not enough, there's more at following page: https://social.msdn.microsoft.com/Forums/en-US/841e5723-bce4-4340-b7b3-027dcdf90f00/

_initp_misc_cfltcvt_tab and _FPinit when switching to /MDd

I switched my Visual C++ 2012 project from Multi-threaded Debug (/MTd) to Multi-threaded Debug DLL (/MDd). The project is a mixture of C++ .vcxproj and Intel Fortran (.vfproj) projects. After all is rebuild I get the errors below.
In CRT source code I see the offending symbols are defined in crt0dat.c if CRTDLL symbol is not defined. How do I make sure I get crt0dat with CRTDLL when compiling main application?
Any other suggestions how do I troubleshoot this?
50>cmain.obj : error LNK2019: unresolved external symbol _initp_misc_cfltcvt_tab referenced in function wWinMain
50>cmain.obj : error LNK2001: unresolved external symbol _FPinit
50>C:\spm\git\clones\SPM80_dll\MSBuild\x64\dll_debug\SPM_dll_debug_x64.exe : fatal error LNK1120: 2 unresolved externals
I believe /MDd builds require msvcrtd.lib. This should be something that automatically gets linked into your project; it might be that it's ignored through a project setting. Open the Project Settings for the C++ project and look under Linker->Input. There are settings there for Ignore All Default Libraries and Ignore Specific Default Libraries. See if there's anything there that might cause the linker to ignore msvcrtd.lib.
BTW, your code will also need the appropriate DLL to run, which for VS 2012 would be msvcr110d.dll. This should already installed on your machine when you installed VS 2012, but it will have to be distributed with the executable if you move it to another computer.

visual studio 2010 express linking file in different projects

in visual studio 2010 express edition. i have a project (a static library) called prj1.
prj1 has codes to create an object obj1.
in another project prj2 which is a dynamic library i have code which intantiates the object by "new obj1" (the code of obj1 is in prj1).
now when i try to build prj2 i get linking errors:
1> when i try to right click on prj2->properties->frameworkk and references if i add prj1 as new reference i get a lot of link errors like MSVCRTD.lib(MSVCR100D.dll) : error LNK2005:
2> if i do not do step1 above and right click on the solution->properties->project dependencies and then choose prj1 to depend on the prj2. then i get just get a link error which complains that : error LNK2019: unresolved external symbol obj1... unresolved externals.
It would be very kind if someone can help me resolve this issue.
Thanks
Seems that your options that choose runtime library differ. One project for example links to "multi-threaded debug DLL" and other project to "multi threaded debug". When you try to link the projects to each other then you get multiply defined runtime library symbols.
Your static library must be found/added to your library directories, and dependency list, too.