I'm obtaining this link error and I cannot find the solution. Can you maybe put me in the right direction where to search for it?
I get: error LNK2019: unresolved external symbol _imp_pthread_mutex_lock referenced in function "private: bool __thiscall... here comes the whole name of my function with parameters.
pthread_mutex_lock and pthread_mutex_unlock are used in this function (not as arguments).
Including "pthread.h" doesn't change anything.
I used pthread-win32 available from sourceware.org/pthreads-win32.
I've been facing this issue for couple hours now and was finally able to fix it by adding the 'lib', 'include' and 'bin' folder content provided with the download, in the appropriate folders in Visual Studio dependency installation folder.
Mine is in
"C:\Program Files (x86)\Microsoft Visual
Studio\2017\Community\VC\Tools\MSVC\14.10.25017"
Then i added the library dependency 'pthreadVC2.lib;' in
Project -> Properties -> Linker -> Input -> Additional Dependancies
And voila! pthreads started to work.
The pthread library is for POSIX systems (Linux, BSD, Mac OS). You indicated that you're on Visual Studio in Windows - if you are looking to do multithreading on Windows, see this page.
Better yet, if you can use more recent tools, C++11 offers built-in threading functionality.
You need to add
-lpthread
or
-lthread
to your compiler command line (depending on OS and compiler)
UPDATE: #nos correctly points out that this seems to be a MS linker error. You shouldn't be using pthreads in Visual Studio. Windows Threading API is very different.
Related
I am new to SCIP and I encounter this problem when I tried to build the branch-and-price framework I obtained from this link.
For your reference, I use MS Visual Studio 2019. I have downloaded and installed the precompiled packages. Then, I conducted the following steps in the property of the project I built in VS 2019.
C/C++ -> General -> Additional Include Directories -> C:\Program Files\SCIPOptSuite 8.0.1\include
Linker -> Input -> C:\Program Files\SCIPOptSuite 8.0.1\lib\libsoplex.lib
Then, I build the program, and many errors (LNK2001) appear, e.g. , unresolved external symbol _imp_SCIPaddCoefLinear, etc.
I have tried to put another library in the Linker, i.e.,
Linker -> Input -> C:\Program Files\SCIPOptSuite 8.0.1\lib\libscip.lib
But, the program raises another error saying the libscip.dll is not found and I am suggested to re-install the package to fix the problem.
I have also tried to reinstall the package, but I still do not have libscip.dll in the folder of SCIPOptSuite 8.0.1.
Do you have any suggestions for properly installing and using the SCIP framework in MS Visual Studio?
Thank you in advance.
Obtained from #Richard Critten:
"...error saying the libscip.dll is not found ..." the directory containing libscip.dll need to be on the PATH or libscip.dll needs to be in the same directory as the executable.
Some back story: I am trying to get the bolt-lmm software to compile on a Windows machine, because it would be a nice addition to the research group I am in. The developers of the software have only made a linux static executeable, but made the source code available. I am used to programming in R or python, and this is my first ever encounter with C++.
I have solved a fair bit of problems, but for some reason I have not been able to get visual studio to link properly with Nlopt-2.4.2.
I downloaded it
and followed the steps given there on how to install it.
I can tell I have done the same to link the Nlopt library to the project as is described in How to add additional libraries to Visual Studio project?
I still get errors like:
Error LNK2019 unresolved external symbol __imp__nlopt_create referenced in function "public: __thiscall nlopt::opt::opt(enum nlopt::algorithm,unsigned int)" (??0opt#nlopt##QAE#W4algorithm#1#I#Z) boltCompiler C:\Users\au483192\source\repos\boltCompiled\boltCompiler\NonlinearOptMulti.obj 1
(there are a total of 12 of this type of error, and an error link 1120, which just tells me there are 12 unresolved eternals.)
I hope this is enough information to provide a hint of what is going wrong.
I did some more digging, and it seems the linker needed more than just the folder for the .lib file.
This post sums it up:
Linking a static library to my project on Visual Studio 2010
Essentially you just need to tell the linker the placement of the lib and the actual name of the .lib file.
Hopefully this will help others who forgot/did not know that added library names manually could be needed for some libraries.
TL;DR:
open configuration properties for the project > linker > general
Then add the path to the .lib file in the "addition library directories" line
Then (still in configuration properties) go to linker > input
add the .lib file name to the "addition dependencies" line, e.g. libnlopt-0.lib (don't forget to separate with ";")
I'm developing a VoIP application (C++/CX) targeting the Universal Windows Platform. At some point, the app needs to query an LDAP server who is keeping a phonebook directory.
As I couldn't find an equivalent of the System.DirectoryServices framework for the UWP, I tried to compile the libraries myself with no success so far. The thing is every OpenLDAP doc on how to build the project for Windows seems to be really outdated. But looking into the sources, I see they provide sample solutions up until Visual Studio vc15, so it is definitely not abandoned.
I tried to build both projects (lber and ldap) and run into many dependency problems. I needed to build Cyrus SASL libraries and OpenSSL, then put all the include paths into the project and link the enerated library objects until I successfully got both libs (olber32_a_debug.lib & oldap32_a_debug.lib) to build.
Finally, I tried to include them into my app project. Still running into some linker issues regarding cyrus.
Linker Issues LNK2019
unresolved external symbol __imp__sasl_version referenced in function _ldap_int_sasl_init [oldap32_a_debug.lib(cyrus.obj)]
unresolved external symbol __imp__sasl_dispose referenced in function _ldap_int_sasl_close [oldap32_a_debug.lib(cyrus.obj)]
unresolved external symbol __imp__sasl_errstring referenced in function _ldap_int_sasl_bind [oldap32_a_debug.lib(cyrus.obj)]
So my question is, have someone compiled OpenLDAP libraries for UWP succesfully? Is there a more recent documentation on how to do so that I'm missing? Any hint/advice on the topic will be greatly appreciated. Many thanks.
I've installed MS-MPIv5 from Microsoft and also the debugger for msmpi. In proejct properties in VS2012, I've changed C/C++ -> Additional include libraries adding "$(MSMPI_INC); $(MSMPI_INC)\x64" and also Linker -> All options->Additional Dependencies adding "msmpi.lib;", but VS is still giving me al lot of linker errors such as
error LNK2019: unresolved external symbol _MPI_Barrier#4
unresolved external symbol _MPI_Bcast#20
and so on, with all the mpi functions or type of variables. Is there something I forgot to change or add?
I haven't used 2012, but if it's similar to the older versions of VS then this detailed link may help. In general make sure to do these 3 things:
Add the "Additional Include Directories"
Add the "Additional Library Directories"
Add the "Additional Dependencies" (msimpi.lib)
It sounds like you may be missing the 2nd step?
Try $(MSMPI_INC)x64 (no \)
In my PC
MSMPI_INC=C:\Program Files (x86)\Microsoft SDKs\MPI\Include\
I want to build Xerces 3.1.1 with ICU using Visual c++ express 2010.
I've downloaded ICU source and built it like it says in the readme.
Now i need to build Xerces with the ICU binaries i just built.
The build instructions for version 3.1.1 in Xerces's site state that "You can also select whether the Xerces-C++ library should use ICU for transcoding" but they don't say exactly how. I looked at all the build options and the only thing i found (maybe i missed something?) that may be related is the pre processor macro list, i saw the following definition - XERCES_USE_TRANSCODER_WINDOWS.
I thought that maybe i need to change it to XERCES_USE_TRANSCODER_ICU. It's just a guess, so first i looked in the Xerces code and i saw XERCES_USE_TRANSCODER_ICU does appear (for example, they check if it's defined before including ICU headers).
So I've changed XERCES_USE_TRANSCODER_WINDOWS to XERCES_USE_TRANSCODER_ICU, added ICU include directory to the include directory path and all ICU .lib files to the linker dependencies and tried to build it like that. I get unresolved external errors:
PlatformUtils.obj : error LNK2019: unresolved external symbol "public: __thiscall xercesc_3_1::ICUTransService::ICUTransService(class xercesc_3_1::MemoryManager *)" (??0ICUTransService#xercesc_3_1##QAE#PAVMemoryManager#1##Z) referenced in function "private: static class xercesc_3_1::XMLTransService * __cdecl xercesc_3_1::XMLPlatformUtils::makeTransService(void)" (?makeTransService#XMLPlatformUtils#xercesc_3_1##CAPAVXMLTransService#2#XZ)
1>C:\cpp_lib\xerces-c-3.1.1\projects\Win32\VC10\xerces-all\XercesLib...........\Build\Win32\VC10\Debug\xerces-c_3_1D.dll : fatal error LNK1120: 1 unresolved externals
The Xerces site provide more specific instructions for building Xerces 2.8 with ICU (it won't work on version 3 because it's done through a script that isn't provided with version 3). I tried that also (although i need to use the latest version) and it also didn't work well. No .dll or .lib files were created.
Thanks.
Because I had the same problem and this is one of the first Google hits looking for it, I will give an answer although it's been some time now since you asked the question.
These are the steps to build Xerces-c in Visual Studio (worked in VS10 for me) with ICU:
Download and build ICU as described.
Open the xerces-all.sln solution file with VS.
Select the ICU Debug/Release build configuration - it sets XERCES_USE_TRANSCODER_ICU for you.
Add the include and library paths for ICU to the porperties of the XercesLib project, add the icu libs in the additional linker dependencies of that project.
Build and be happy - no need to exclude WIN32TransService.cpp