v8 release mode linker error with winsock - visual-c++

This subject became a side subject after I accepted an answer for my last question, so I will put it here as a separate topic for neatness, and I believe this will make it more useful for others.
I am working on MS visual studio 2005.
I am building a project using v8 in release mode, and am receiving a linker error that is related to winsock even though the winsock libraries are already in my additional dependencies.
My additional dependencies list is the same for both release and debug mode. It works perfectly in debug mode, and I am getting the linker errors only in release mode.
here is my additional dependencies string:
Ws2_32.lib wininet.lib rasapi32.lib iphlpapi.lib Psapi.lib winmm.lib wsock32.lib msvcrt.lib $(SolutionDir)\external_libs\debug\v8.lib $(SolutionDir)external_libs\release\v8_base.lib $(SolutionDir)external_libs\release\v8_snapshot.lib
Thanks a lot for any possible help.
Update:
I reduced the dependencies to:
Ws2_32.lib Psapi.lib winmm.lib msvcrt.lib $(SolutionDir)\external_libs\release\v8.lib $(SolutionDir)external_libs\release\v8_base.lib
and still get unresolved externals:
1>v8_base.lib(platform-win32.obj) : error LNK2001: unresolved external symbol __imp__freeaddrinfo#4
1>v8_base.lib(platform-win32.obj) : error LNK2001: unresolved external symbol __imp__getaddrinfo#16
1>v8_base.lib(platform-win32.obj) : error LNK2001: unresolved external symbol __set_abort_behavior

You have paths to both debug and release folders in your dependency list. Try replacing those with $(Configuration).

Related

How to link Bcrypt.lib to VC++ DLL project

Trying to compile a VC++ DLL I get some error messages related to Visual Studio cannot resolve external symbols, errors LNK2001, LNK1120.
In my case the symbol it cannot be resolved is: __imp__BCryptGenRandom#16
and the error message is:
error LNK2001: unresolved external symbol __imp__BCryptGenRandom#16
I have googled and found that it is said to link BCrypt.lib so I have linked it at "properties->linker->input->additional dependency"
Also at ""properties->linker->all options->additional library directoris" I have added below one where BCrypt.lib is for x86:
C:\Program Files (x86)\Windows Kits\10\Lib\10.0.19041.0\um\x86
And finally at "properties->linker->General->Use library dependencies inputs" I have set "Yes".
But none of these methods work.

Weird linking error

My application is giving me a linking error when I try to build it.
Error 5 error LNK2001: unresolved external symbol "int __cdecl _AfxInitManaged(void)" (?_AfxInitManaged##YAHXZ) mfcs80ud.lib
I am building the application using Visual studio 2005. I am also linking against WINDDK for Server 2003 and Windows 6.1 SDK if this helps.
I Googled around and noticed people saying that its a precompiled header issue and it should be fixed by setting the /Yc switch in the stdafx.cpp Create/Use Precompiled header property. but that did not fix it for me and I'm not sure how to fix this.
Can someone help please.
I had same problem with Visual Studio 2010.
error LNK2001: unresolved external symbol "int __cdecl _AfxInitManaged
It turned out that was from my mistake to include another stdafx.cpp in other project.
Including more than one stdafx.cpp will produce this symptom.
Seems it solved it self once I restarted my machine.. not sure what was causing it in the first place, even restarting VS and cleaning the solution a gazillion times did not work.
Using Visual Studio 2005 to build a .NET 2003 solution, I encountered the described LNK2001 error. The project did not have a stdafx.cpp file. I added a copy of stdafx.cpp to the project and it built successfully.

SFML linker problems on eclipse VC++

I am trying to use the SFML library for audio in my project.
I am developing in eclipse juno for c++ and am using SFML v1.6.
I added sfml-audio-d.lib, sfml-main-d.lib, and sfml-system-d.lib into
C/C++ General > paths and symbols>libraries
I also defined a macro named SFML_DYNAMIC into
C/C++ Build>Settings>C++ Compiler>Preprocessor 'Defines /D' section
I added the directory that contains all the dlls into the PATH environment variable.
In my code I make use of sf::SoundBuffer, but when I try to build the project I get the following linker error:
Chunk.obj : error LNK2001: unresolved external symbol "private: static class sf::SoundBuffer * Chunk::breakBlockSound" (?breakBlockSound#Chunk##0PAVSoundBuffer#sf##A)
MyProject.exe : fatal error LNK1120: 1 unresolved externals
Had to rebuild the project in VS2010 before using it. Works now.

Library linker errors driving me mad

It's me again. I'm back with an all new project and an all new problem.
I am trying to implement something for Growl. Either using a static or shared library (both are provided). I included the necessary header and linked to the library. (2 ways actually, once through the project properties and the other through a pragma statement). However, im still receiving the following linker errors:
error LNK2001: unresolved external symbol "__declspec(dllimport) public: __thiscall Growl::Growl(enum Growl_Protocol,char const * const,char const * const,char const * * const,int)" (__imp_??0Growl##QAE#W4Growl_Protocol##QBD1QAPBDH#Z)
error LNK2001: unresolved external symbol "__declspec(dllimport) public: __thiscall Growl::~Growl(void)" (__imp_??1Growl##QAE#XZ)
fatal error LNK1120: 2 unresolved externals
The line of code that is causing these linker errors is this line:
const char *n[2] = { "username" , "password" };
Growl *growl = new Growl(GROWL_TCP,NULL, "Appname", (const char **const)n,2);
The header file is being included at the top of the file and I am linking with the following line:
#include "..\\..\\..\\libs\\Growl\\growl++.hpp"
#pragma comment(lib, "..\\..\\..\\libs\\Growl\\libgrowl-static++.lib")
The header source can be found here:
https://github.com/psinnott/gntp-send/blob/master/headers/growl%2B%2B.hpp
I retrieved the pre-built binaries from the following page:
https://github.com/psinnott/gntp-send/wiki/Windows
Some extra info: I do have my Project Propeties character set to use Multi-Byte Character Set, im under the assumption this shouldn't affect anything. This is also a Win32 Console application.
Where am I going wrong?
Update:
Found this via google:
http://groups.google.com/group/growl-for-windows/browse_thread/thread/6c48a62454d062f1
Followed the instructions:
Added the libgrowlstatic.lib (alongside libgrowlstatic++.lib)
Added the pre-processor definitions, GROWL_STATIC and GROWL_CPP_STATIC
Got lots of error including:
LINK : warning LNK4098: defaultlib 'MSVCRTD' conflicts with use of other libs; use /NODEFAULTLIB:library
LINK : warning LNK4098: defaultlib 'LIBCMT' conflicts with use of other libs; use /NODEFAULTLIB:library
fatal error LNK1169: one or more multiply defined symbols found
So I added the following line to Project properties, Linker, Command Line:
/NODEFAULTLIB:MSVCRTD /NODEFAULTLIB:LIBCMT
Now im getting alot more errors including some of the following:
libgrowl-static.lib(tcp.obj) : error LNK2019: unresolved external symbol _atoi referenced in function _growl_tcp_parse_hostname
libgrowl-static.lib(tcp.obj) : error LNK2019: unresolved external symbol _strchr referenced in function _growl_tcp_parse_hostname
libgrowl-static.lib(growl-static.obj) : error LNK2019: unresolved external symbol _fseek referenced in function _growl_tcp_register
libgrowl-static.lib(growl-static.obj) : error LNK2019: unresolved external symbol _fopen referenced in function _growl_tcp_register
libgrowl-static.lib(growl-static.obj) : error LNK2019: unresolved external symbol _strcpy referenced in function _growl_udp_notify
Been at this for several hours and can't seem to figure it out. 10+ views and no replies?
I swear im not being lazy. I looked into one of the answers provided about libraries but didn't have much luck. Nothing explained why this is acting the way it is. Please help!
#pragma comment(lib, "..\\..\\..\\libs\\Growl\\libgrowl-static++.lib")
There is a clear mismatch between the #pragma and the way your code is getting compiled. The name of the library strongly suggests this is a static link library, the "static" in the name makes that clear. The error messages however talk about __declspec(dllimport), a directive that's used when you compile code that #includes a header that assumes the code lives in a DLL instead of a static link library.
The other errors you are getting bear this out as well. The Project + Properties, C/C++, Code Generation, Runtime Library setting matters. You are using the /MD setting, a setting that's appropriate when you work with DLLs. The library no doubt was compiled with /MT, a setting appropriate when you create a monolithic EXE that doesn't use DLLs. You are trying to link two chunks of code that were built with conflicting settings, the linker falls over when trying to deal with this. It explicitly says so in an error message.
You'll need to either dig up the DLL version of the .lib or use /MT consistently in the rest of your code. There's usually a #define that tells the .h file which version of the .lib you intend to link.
This is working for me. It assumes you want to use the static libraries and not the dll.
Properties -> Configuration -> Properties -> VC++ Directories
Add directory of unzipped sdk to include and library directories
Properties -> Configuration -> Properties -> C/C++ -> Preprocessor
Add GROWL_STATIC and GROWL_CPP_STATIC to preprocessor definitions
Properties -> Configuration -> Properties -> C/C++ -> Code generation
Change runtime library to multi threaded ( /MT or /MTd )
Properties -> Configuration -> Properties -> Linker -> Input
Add ws2_32.lib , libgrowl-static.lib and libgrowl-static++.lib to additional dependencies

is it possible to link a c++/cli dll with a static vc++ lib

I got the c++/cli dll to link to a vc++ dll, but when trying it with the static version of the vc++ lib there are a bunch of linker errors. I want to use static so I dont have to copy all of the other vc++ dll files into my main c# project, which uses the c++/cli dll.
The vc++ library has the following properties:
*built in vs2008
*Static library
*uses MFC in a static library
*No common language runtime support
the c++/cli library has these properties:
*built in vs2010
*Dynamic Library
*Use of MFC in a shared DLL
*Common Language Runtime Support
*linker->input contains the vc++ lib file
I tried linking the vc++ lib it after building it in vs2010 but that didn't help.
So I get like 90 LNK2005 errors like these from nafxcwd.lib:
1>nafxcwd.lib(dlgprop.obj) : error LNK2005: "public: struct _PROPSHEETPAGEA & __thiscall CPropertyPage::GetPSP(void)" (?GetPSP#CPropertyPage##QAEAAU_PROPSHEETPAGEA##XZ) already defined in mfc100d.lib(mfc100d.dll)
then like 30 or so of these:
1>libcmtd.lib(sprintf.obj) : error LNK2005: _sprintf already defined in msvcrtd.lib(MSVCR100D.dll)
then three LNK4098 warnings:
LINK : warning LNK4098: defaultlib 'msvcrtd.lib' conflicts with use of other libs; use /NODEFAULTLIB:library
1>LINK : warning LNK4098: defaultlib 'nafxcwd.lib' conflicts with use of other libs; use /NODEFAULTLIB:library
1>LINK : warning LNK4098: defaultlib 'libcmtd.lib' conflicts with use of other libs; use /NODEFAULTLIB:library
then I get this last error:
libcmtd.lib(crt0.obj) : error LNK2019: unresolved external symbol main referenced in function __tmainCRTStartup
I looked up the LNK4098 warning on msdn and the solution was to add the conflicting libraries to the IgnoreSpecific Default libraries entry in the linker input settings, but this did not help.
Thanks,
alex
You can't link (C++) libraries build with different version of the VS compiler (sometimes it may accidentally seem to work but you'll usually get hard to diagnose crashes later on). Additionally, your errors seem to be typical of selecting different CRT configurations (single/multi-threaded, debug/release etc).

Resources