views:

416

answers:

2

How do you specify, in Visual Studio 2010, the order in which library files should be linked?

I have a project that links against libexpat and against another library. This library (not under my control) seems to also include libexpat. The problem is that 'we' use a different version of the library (XML_UNICODE vs not). In Visual Studio 2008 things seemed to work out okay (might have been a coincidence), but in Visual Studio 2010 the wrong instance of libexpat is linked. I was thinking that if I could specify the order in which these two libraries should be linked that then I could circumvent the problem.

A: 

You could create a DLL with the third party library and link it against the static version of expat that it needs and then link your code against the version of expat you need.

However, the fact that it worked before might mean that one library has all the functionality of the other plus some extra. I don't know the details of expat. If that is the case, you need to make sure that you only have the version you want to use in your library search path. A different search directory order in the other version of the compiler could explain the change in behaviour.

janm
I thought about creating a DLL, but since the 'other' library is the hardware dongle protection library, I don't really want to do that :-)
crimson13
+1  A: 

I have found 'a' solution: if you add the libraries through #pragma comment(lib... the order of linking is the same as the order in which you type those pragma's. I'm still keeping the question open for a solution when the libraries are added through the project file instead of through pragma statements.

crimson13