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\
Related
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 cannot figure out how to get sqlite3.dll (or any dll for that matter) to work with my C++ project in Visual Studio.
The error message I get is LNK2001 unresolved external symbol sqlite3_open
Here's what I did so far:
I put the .dll in myProjectFoler/Resources/sqlite3.dll
I generated sqlite3.lib using Visual Studio Developer Command Prompt using a command lib /def:sqlite3.def
I referenced the directory with the lib in Project -> Preferences -> Linker -> General -> Additional Library directories, and then referenced the .lib in Project -> Preferences -> Linker -> Input-> Additional dependencies
I placed sqlite3.h in my project and #included it
(pretty much followed the instructions seen here)
Thank you for help
The issue is that by default the header file assumes that sqlite is linked statically, as opposed to dynamic linking to a dll.
This part of sqlite3.h is responsible for that:
#ifndef SQLITE_API
# define SQLITE_API
#endif
If you set a per-project define in project properties:
SQLITE_API=__declspec(dllimport)
this should resolve your link error.
Alternatively, you can put
#define SQLITE_API __declspec(dllimport)
right before where you #include sqlite3.h.
It's difficult to tell exactly why the problem occurred. There are lots of reasons which could cause LNK2001 error. MSDN contains good check list.
You could try to use /VERBOSE option to determine which files the linker references. Put this option in Project -> Preferences -> Linker -> Command Line -> Additional Options. Output should contains similar strings:
Searching e:\SQLite\sqlite-dll-win32-x86-3150100\sqlite3.lib:
Found _sqlite3_open
Referenced in ConsoleApplication2.obj
Loaded sqlite3.lib(sqlite3.dll)
Pay attention to the VS runtime libraries, there should be no mixup between Debug and Release libraries.
I got the precompiled "lib" and "dll" from here: http://zlib.net/zlib128-dll.zip
I am compiling my project in x64.
I added directory into "Additional Include Directories"
I added the "zdll.lib" to Linker -> Additional Dependencies.
I added the library directory to Linker -> Additional Library Directories.
I also added the Post-Build Event "xcopy ..\oem\zlib\*.dll "$(TargetDir)"
But I still get the Linker error:
: error LNK2019: unresolved external symbol inflateInit_ referenced in function
Thanks.
IS that a 32-bit dll? If so, you'll have to obtain, or build your own, 64-bit version.
The linker error happens with the lib file, if you have the right headers it'll compile, if you have the right lib, it'll link, if you have the right dll, it'll run.
I am trying to extend my knowledge of constrain programming and I want to build a simple example using google's or-tools in VS2015.
However I am constantly nagged by those linker errors. LNK2019 and LNK2001. Why is linking in VS so darn hard.
Google's or-tools comes in a perfect folder, with an include subfolder and lib subfolder with one single .lib file.
I have added Additional Library Dependencies.
Configuration Properties -> Linker -> General Additional Library Dependencies : C:\PATH\or-tools.VisualStudio2013-64b\lib
Set the Input under the Linker properties section.
Configuration Properties -> Linker -> Input Additional Dependencies : ortools.lib
Infomed VC++ where the include directory is.
Configuration Properties -> VC++ Directories : C:\PATH\or-tools.VisualStudio2013-64b
However it is still throwing link errors when building the solution. What am I missing here.
Thanks in advance.
edit:
spelling
Since the VS2013 and VS2015 compiler versions are incompatible, you have to build the lib from source. Though beware that this might entail a bit more work when linking with VS2015. Specifically I've had to manually resolve the following issues:
Change protobuf-3.0.0-beta-1 to protobuf-3.0.0-beta-2(bonus. not really necessary)
gflags 2.1.2 failed to compile due to a conflict of names around snprintf. To resolve this download the latest gflags version from GitHub and overwrite the one in %OR_TOOLS%\dependencies
Look up all VS solution files (.sln) in dependencies\sources\cbc-2.9.7 and convert to VS2015 format by simply double clicking them and following the instructions.
Add the following code to makefiles\Makefile.port
ifeq ("$(VisualStudioVersion)", "14.0")
VISUAL_STUDIO=2015
VS_RELEASE=v140
VS_COMTOOLS=140
else
...
endif
Replace Visual Studio 12 2013 with Visual Studio 14 2015
Rerun make third_party after each step.
Or you can just download the end result, linked on Windows 10 x64 VS2015 update 1. I've included the whole folder after running make third_party && make cc.
I'm new to C++, and I've been struggling for the past 2 days trying to get libcurl to work. I'm on Windows, with VS 2012, and need to use libcurl for a x64 project. I have scoured the internet and SO for a solution that will help me, but not a single one has helped. I especially tried this link, which seemed to be the closest to what I need in the easiest possible instructions, and even that failed.
The error I am getting is a linker error, one for each call to any libcurl function.
error LNK2019: unresolved external symbol curl_global_init referenced in function main
To clarify,
I have added libcurl/include to VC++ Directories -> Include Directories AND to C/C++ -> Additional Include Directories
libcurl/lib/static-debug to VC++ Library Directories
CURL_STATICLIB to C/C++ -> Preprocessor -> Preprocessor Definitions
libcurl/lib/static-debug to Linker -> Additional Library Directories
Full path to libcurl\lib\static-debug\libcurl_a_debug.lib to Linker -> Input -> Additional Dependencies.
Can someone please tell me if I'm doing anything wrong here, or if not, what on earth I can do to solve this? It's getting extremely frustrating, and I'm desperate.