[gecode-users] Linking to Gecode with Microsoft Visual C++

Christian Schulte cschulte at kth.se
Tue Sep 2 18:07:58 CEST 2008


Oh, two more things: it is not an issue with different versions of MSVC, we
used the same version. And most importantly, after some thinking it is quite
clear why it should not work: you link std::ostream twice, once inside the
Gecode DLLs against the optimized MSVC libs, and the second time in your
program against the debug MSVC libs. That is, in fact asking quite much.

Christian

-----Original Message-----
From: users-bounces at gecode.org [mailto:users-bounces at gecode.org] On Behalf
Of Christian Schulte
Sent: Tuesday, September 02, 2008 5:33 PM
To: 'Filip Konvička'; users at gecode.org
Cc: 'gecode users list'
Subject: Re: [gecode-users] Linking to Gecode with Microsoft Visual C++

Hi,

as an example just try one of the Gecode examples! We have digged deeper and
know a little bit more: mixing DLLs created with -MD (as we do) with other
stuff created with -MDd for debugging gets you into trouble.

The trouble can be observed when using std::ostream... (try printing a
variable). And here it is not due to inlining, etc.

Our current idea is to ship two sets of libraries, one compiled with -MD and
one with -MDd (that's not any longer an issue as we will be using
aut-linking) but both optimized.

Christian

--
Christian Schulte, www.ict.kth.se/~cschulte/


-----Original Message-----
From: users-bounces at gecode.org [mailto:users-bounces at gecode.org] On Behalf
Of Filip Konvicka
Sent: Tuesday, September 02, 2008 5:11 PM
To: users at gecode.org
Cc: gecode users list
Subject: Re: [gecode-users] Linking to Gecode with Microsoft Visual C++

Hi,

> We had a bit of trouble trying to link to the binary Gecode
> distribution from a Microsoft Visual Studio C++ project.  First of
> all, here's what you have to set up in the properties dialog of your
> "Solution":
>   * Configuration Properties, C++, General, set the Additional Include
> Directories to <Program Files>\Gecode
>   * Configuration Properties, Linker, General, set the Additional
> Library Directories to <Program Files>\Gecode\lib
>   * Configuration Properties, Linker, Input, set the Additional
> Dependencies to GecodeSupport.lib GecodeKernel.lib GecodeSearch.lib
> etc. (all the Gecode libraries that you want to link against)

I've always used Gecode like this (since 1.3.0 I think) and I never had
any problems.

> That should do the trick, except that only a release build works
> properly at the moment.  If you build your project using a Debug
> configuration instead, your program will crash with "bad alloc" errors.

That does not happen for us. We're using the same 'non-debug' Gecode
binaries for all project configurations, i.e. 'Release',
'ReleaseWithDebugInfo', 'Debug'. That includes different /MD, /MDd (and
more).

If it is not too complicated, could you post (or just mail me) a sample
project that shows the problems?

> Apparently, inlining doesn't work too well when linking against
> different libraries (i.e., linking Gecode with /MD while linking your
> program with /MDd).  So, for the time being, you will have to compile
> your program as a Release build, or compile your own version of Gecode
> with debug turned on.  We're looking into this issue, and we'll try to
> produce (optimized) libraries that can be used in a Debug build for
> the next version of Gecode.

Hm...we use Debug mode often and we're able to step into all code that
is not hidden in Gecode dlls. For 2.2.0, we build Gecode just using
"./configure --disable-examples", "make install", so no special flags.
So I guess we're very close to the official binary package.

Maybe there are some binary compatibility issues between different
versions of MSVC?

Cheers,
Filip


_______________________________________________
Gecode users mailing list
users at gecode.org
https://www.gecode.org/mailman/listinfo/gecode-users


_______________________________________________
Gecode users mailing list
users at gecode.org
https://www.gecode.org/mailman/listinfo/gecode-users





More information about the gecode-users mailing list