Linking DLL in Visual Studio 2010 C++ - visual-studio-2010

I am trying to use the M4RI package for C++. I downloaded the source for M4RI and ran the packaged VS project. It created m4ri.dll (no .lib files).
Now I want to "add" this dll file to a different VS2010 C++ project so I can use the M4RI library.
I already #include m4ri.h, but still get linking errors. How do I add this reference to the VS project?
Thanks in advance.

My solution:
I am not familiar with the differences between C and C++, but this seems to be the issue. To get the M4RI library to build, I had to explicitly tell it to compile with C++ (Properties->C/C++->Advanced->Compile As: "Compile as C++")
I'm not sure if this caused my problem, or if it is unrelated.
To be able to use the library, I had to modify "m4ri.h" to remove the #ifdef __cplusplus sections. As soon as those precompiler directives were removed, I was able to link to M4RI easily.
I would appreciate if someone could explain why this fixed the problem.
Thanks!

Linking errors can come from many things. Are your link errors related to m4ri? With dlls, you usually get a an export lib which should be included in your project.

Related

Compile VxWorks project in Visual Studio

I have a VxWorks project that compiles under Toronado on my Win7 machine. I am trying to convert the same project to compile in my Visual Studio 2010. I don't need it to complete to where it creates a .o/out file but at least get through all the defines/includes and etc. so I can use Visual Studio's IDE for definition jumping and etc..
I'm at a point where I'm getting a 'undeclared identifier' for "_interrupt" which is included in several include files from the ..\tornado\target\config\ folder.
I'd appreciate any suggestions
Thanks
I would like to comment on this but don't have enough points.
I do the same thing using eclipse instead of visual studio, I don't do anything special to make it work.
It sounds like you are trying to do the link even though you don't want to. Make sure when you create your project you set it up to create a library not an executable, it should do the compile then but no linking.

Using Gloox with Visual Studio 2010

I am trying to use the gloox library (C++) to create a Windows XMPP application. It seems simple enough, except I don't know how to import gloox into Visual Studio 2010 so I can include it in my application project.
I've looked at the instructions provided in the read-me (shown below), but when I try to compile the library, I get this error:
Cannot open source file: 'src\tlsgnutlsserver.cpp': No such file or directory
Instructions provided in the read-me file:
Building gloox on MSVC++
use the included project file or create your own
adjust include + library paths if necessary
to receive any debug output you should use the LogSink facilities (this is not win32-specific)
build
Does anyone have experience using Gloox with VS10? If yes, can you please help me out? Thanks!
I assume you're using the official 1.0 tarball? I had the same problem (missing source file) and had to acquire the source from SVN instead. I used the 1.0 branch.
I encountered a few other build problems, namely
the release build configuration was set to build an Application (.exe) instead of Dynamic library (.dll) (Project->Properties->General->Configuration Type)
I needed to add DLL_EXPORT to the preprocessor definitions (Project->Properties->Configuration Properties->C/C++ ->Properties->Preprocessor)
src\atomicrefcount.cpp needed to be added to the project's source files. (Project->Add Existing Item)
This worked for me in express editions of both VC++ 2010 and VC++ 2008.
Hopefully it helps you as well.

Finding required external symbols

I am currently facing a linking error on Visual Studios C++ 2010. I know exactly that I forgot to link some .lib files against the project and it turned out to be true.
However, the problem is my project depends on another project (that I did not do) that provides header files and .lib files that have different names. And I am having a hard finding the specific lib files.
In this case, how can I find the right .lib file for the symbols I am using?
Does this help? (dumpbin /SYMBOLS) https://stackoverflow.com/questions/1935183/tool-to-view-functions-exported-in-static-library

How to include the math library in MS-VS 2005 compiler project settings?

I am trying to build a C code which originally is built on linux with
gcc -lm ... option, which uses the math library while linking the code. How do I use the same in project settings of a Visual Studio 2005 compiler, on Win32 environment, to link the math library. Will just saying
#include "math.h"
be enough or i need to give math library as a dependency in the VS-2005 project settings, If yes then what is the setting for that?
Basic problem is when in my windows build, I include math.h but I get a compilation error: nanf():- identifier not found
I am looking to resolve this.
thank you,
-AD
#include "math.h" works fine on VS2005.
See Floating-Point Support.

compiling against MSVCP70.dll instead of MSVCP80.dll in Visual Studio 2005

I am building a project in Visual Studio 2005 that require some libraries that were built in Visual Studio 2003. I'm getting linker errors like
msvcprt.lib(MSVCP80.dll) : error LNK2005: class std::basic_string[...]already defined in libdiguy.lib(bdiNavMesh.obj)
I believe that my program and the libraries are both compiled dynamically instead of statically. I've also tried changing the /MD and /MDd options because that seemed to be the solution to similar errors. My best guess at the moment is that it needs to link against MSVCP70.dll instead of MSVCP80.dll to resolve these errors. Is there a way I can compile against the older dll to see if that will fix it?
Thank you!
As far as I know you have two options: either get a VS2005 version of the libraries, or keep using the VS2003 headers and libraries. The first is in my opinion the better option because you will not benefit from fixes MS made in headers and libs. But it may be difficult or even impossible. The latter can be done by changing the VS2005 directories to the corresponding VS2003 ones. I think that you also have to ignore all default libraries and explicitly specify the ones from VS2003.
Hope this helps.
Cheers,
Sebastiaan

Resources