[geos-devel] creating & importing geos-3.3.3 static libgeos.lib on Windows

Dave Cottlehuber dch at apache.org
Wed May 30 07:54:10 PDT 2012


I'm not sure how to include geos-3.3.3 as a static library into a
project, that will use an erlang<->C DLL interface.

According to https://github.com/libgeos/libgeos/commit/49463453fa2e871d1686c4c7d0c2efa5c280f92d
I should be using libgeos.lib to link against;

This should be sufficient, pretty-printed:

   -LD -MD -Zi -Wall

However this doesn't compile, 24 missing references such as:

    LNK2019: unresolved external symbol _GEOSCoordSeq_setY

Adding geos_c.lib fixes the compilation issue, but it appears to be
the .lib file for the actual DLLs, not the static library libgeos.lib. I'm
not sure but this looks a little like the issue noted here:

"I just tried this on windows by hand and it has some interesting
effects.  The static .lib file that is produced is full of objects that
have dllexport tags.  When it is linked into an executable, say foo.exe,
the linker produces a foo.lib import library.  Another problem on
windows is that the static library cannot have the same name as the dll
or it will clobber the import library paired with the dll.  This means
that any target property we create to specify this behavior will also
have to specify an alternative name for the archive."

Geos is built from github checkout of 3.3.3 tag using MS SDK 7.1
from the setenv command prompt, and then:

    mkdir dist build & cd build
    cmake -G "Visual Studio 10" ..
    cmake -DCMAKE_INSTALL_PREFIX=..\dist  ..
    cmake --build ..\build --target install --config Release

Which works nicely, and creates 3 .libs:

   Directory of Z:\source\libgeos\dist\lib
   05/30/2012  03:03 PM         1,608,376 geos.lib
   05/30/2012  03:03 PM           286,934 geos_c.lib
   05/30/2012  03:02 PM        17,683,582 libgeos.lib

BTW make check however does not. I can't see this fixed in svn trunk,
do you want a ticket for it?

Z:\source\libgeos\build>    cmake --build ..\build --target check
--config Release

Microsoft (R) Visual Studio Version 10.0.40219.1.
Copyright (C) Microsoft Corp. All rights reserved.

The evaluation period for Visual Studio Trial ends in 23 days.
1>------ Build started: Project: ZERO_CHECK, Configuration: Release Win32 ------
2>------ Build started: Project: check, Configuration: Release Win32 ------
2>  Building Custom Rule Z:/source/libgeos/CMakeLists.txt
2>  CMake does not need to re-run because
Z:\source\libgeos\build\CMakeFiles\generate.stamp is up-to-date.
2>  Test project Z:/source/libgeos/build
2>      Start 1: geos_unit
2>  1/4 Test #1: geos_unit ........................***Failed    0.22 sec
2>      Start 2: xmltester
2>  2/4 Test #2: xmltester ........................   Passed    4.66 sec
2>      Start 3: bug234
2>  3/4 Test #3: bug234 ...........................   Passed    0.06 sec
2>      Start 4: TestSweepLineSpeed
2>  4/4 Test #4: TestSweepLineSpeed ...............   Passed    4.49 sec
2>  75% tests passed, 1 tests failed out of 4
2>  Total Test time (real) =   9.89 sec
2>  The following tests FAILED:
2>        1 - geos_unit (Failed)
2>  Errors while running CTest
2>C:\Program Files
error MSB6006: "cmd.exe" exited with code 8.
========== Build: 1 succeeded, 1 failed, 0 up-to-date, 0 skipped ==========


More information about the geos-devel mailing list