Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP

Loading…

Windows #2

Open
wants to merge 12 commits into from

1 participant

@dch
dch commented

Notes in README.md state how to build libgeos correctly with CMake. Using NMake directly will result in
a different directory structure that requires different rebar.config. Direct NMake appears to be deprecated by the libgeos project.

Test suite is still missing.

dch added some commits
@dch dch rebar: resolve deprecated rebar.config & enable Windows NIF compilation
- current rebar master branch deprecates a number of settings, let's fix them now
- include Windows-specific compilation steps
0f4bee6
@dch dch admin: update gitignore for windows and rebar 8d179c4
@dch dch Windows: use unsigned vars within for loop
c_src/erlgeom.c(259) : warning C4018: '<' : signed/unsigned mismatch
4225d19
@dch dch Windows: hacking a build script
TODO: move bit by bit all of this into rebar.config
8f35ec6
@dch dch add Windows-compatible rebar.cmd 9f69c4c
@dch dch link against geos C API only in rebar.config 5b5a10f
@dch dch updated rebar.cmd with MSVC compatibility d837442
@dch dch minor improvements to build.cmd script
- this functionality should be fully rebarified
- still missing prove etap tests
e3d1eef
@dch dch Update README.md with steps used to build geos-3.3.4 consistently
There is a significant difference in output of libraries and header files depending on
whether CMake or NMake was used to build. I recommend CMake as that's the direction
the geos project team are taking.
f4a6d18
@dch dch build cleanly with basho/rebar tag 2.0.0
- moved dch's windows custom src/rebar_port_compiler.erl into rebar.config
- this allows building erlgeom with basho rebar
acdb60d
@dch dch build.cmd did not have correct path to erlgeom-{VSN}/priv so DLLs wer…
…e not loaded
b757520
@dch dch fix code wrap 6e23220
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Commits on May 25, 2012
  1. @dch

    rebar: resolve deprecated rebar.config & enable Windows NIF compilation

    dch authored
    - current rebar master branch deprecates a number of settings, let's fix them now
    - include Windows-specific compilation steps
  2. @dch
  3. @dch

    Windows: use unsigned vars within for loop

    dch authored
    c_src/erlgeom.c(259) : warning C4018: '<' : signed/unsigned mismatch
  4. @dch

    Windows: hacking a build script

    dch authored
    TODO: move bit by bit all of this into rebar.config
Commits on May 29, 2012
  1. @dch

    add Windows-compatible rebar.cmd

    dch authored
Commits on Jun 6, 2012
  1. @dch
  2. @dch
  3. @dch

    minor improvements to build.cmd script

    dch authored
    - this functionality should be fully rebarified
    - still missing prove etap tests
  4. @dch

    Update README.md with steps used to build geos-3.3.4 consistently

    dch authored
    There is a significant difference in output of libraries and header files depending on
    whether CMake or NMake was used to build. I recommend CMake as that's the direction
    the geos project team are taking.
Commits on Jun 8, 2012
  1. @dch

    build cleanly with basho/rebar tag 2.0.0

    dch authored
    - moved dch's windows custom src/rebar_port_compiler.erl into rebar.config
    - this allows building erlgeom with basho rebar
  2. @dch
  3. @dch

    fix code wrap

    dch authored
This page is out of date. Refresh to see the latest.
View
6 .gitignore
@@ -1,4 +1,10 @@
*.beam
*.o
*.so
+*.dll
+*.exp
+*.lib
+*.pdb
erl_crash.dump
+
+deps/
View
33 README.md
@@ -1,4 +1,4 @@
-Build it with:
+# Building on Unix/Linux:
make
@@ -27,3 +27,34 @@ more examples.
5> erlgeom:disjoint(Geom1, Geom3).
true
6>
+
+# Building on Windows
+
+First you will need to build Geos-3.3.4 from source, including the missing
+integer type headers.
+
+## Set up your environment as follows;
+
+- install MSVC10 SDK 7.1
+- install Erlang/OTP R15B01
+- install 7zip
+- install cmake
+- run `setenv.cmd /x86 /release`
+
+ wget http://download.osgeo.org/geos/geos-3.3.4.tar.bz2
+ 7z x -y geos-*.bz2
+ 7z x -y -ogeos geos-*.tar
+
+- finally, build geos:
+
+ cd geos
+ setenv.cmd /x86 /release
+ path=%path%;c:\mozilla-build\7zip;c:\opt\cmake\bin;c:\erlang\bin;c:\openssl\bin;
+ mkdir dist build & cd build
+ cmake -G "NMake Makefiles" ..
+ cmake -DCMAKE_INSTALL_PREFIX=..\dist -DBUILD_SHARED_LIBS=OFF ..
+ cmake --build ..\build --target install --config Release
+
+- copy this dist folder as erlgeom/deps/geos
+- alter build.cmd as required to point to your erlang installation
+- run `build.cmd` and complete tests
View
35 build.cmd
@@ -0,0 +1,35 @@
+setlocal
+::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::
+set temp=c:\tmp
+set ERL_PATH=c:\erlang
+path=%path%;c:\mozilla-build\7zip;c:\opt\cmake\bin;%ERL_PATH%\bin;c:\openssl\bin;
+set GEOAPP=erlgeom-0.1.0
+
+::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::
+:: clean up existing erlgeom release bundle
+if exist %GEOAPP% rd /s/q %GEOAPP%
+del /f/s/q priv\* ebin\*.beam c_src\*.o* rel\*
+mkdir %GEOAPP%\priv %GEOAPP%\ebin %GEOAPP%\src
+
+::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::
+call rebar.cmd -vv compile
+
+::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::
+:: build erlgeom release bundle
+xcopy priv\*.dll rel\%GEOAPP%\priv\ /y /f
+xcopy deps\geos\bin\geos_c.dll rel\%GEOAPP%\priv\ /y /f
+xcopy ebin\* rel\%GEOAPP%\ebin\ /y /f
+xcopy src\* rel\%GEOAPP%\src\ /y /f
+
+::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::
+:: update erlgeom in current erlang release
+robocopy rel\%GEOAPP% %ERL_PATH%\lib\%GEOAPP% -mir
+path=%path%;%ERL_PATH%\lib\%GEOAPP%\priv;
+start /max werl
+:::::::::::::::::::::::::::
+endlocal
+:: l(erlgeom). Geom1 = erlgeom:to_geom({'Point',[5,5]}), Geom2 = erlgeom:to_geom({'LineString', [[1,1],[14,14]]}), erlgeom:disjoint(Geom1, Geom2), Geom3 = erlgeom:to_geom({'Point', [2.5,65.7]}), erlgeom:disjoint(Geom1, Geom3).
+echo l(erlgeom).
+echo Geom1 = erlgeom:to_geom({'Point',[5,5]}), Geom2 = erlgeom:to_geom({'LineString', [[1,1],[14,14]]}),
+echo erlgeom:disjoint(Geom1, Geom2), Geom3 = erlgeom:to_geom({'Point', [2.5,65.7]}),
+echo erlgeom:disjoint(Geom1, Geom3).
View
2  c_src/erlgeom.c
@@ -250,7 +250,7 @@ eterm_to_geom(ErlNifEnv *env, const ERL_NIF_TERM *eterm)
ERL_NIF_TERM
GEOSCoordSequence_to_eterm_list(ErlNifEnv *env,
const GEOSCoordSequence *coords_seq, unsigned int len) {
- int i = 0;
+ unsigned int i = 0;
double coordx, coordy;
ERL_NIF_TERM *coords_list;
ERL_NIF_TERM coords, coords_list_eterm;
View
BIN  rebar.cmd
Binary file not shown
View
173 rebar.config
@@ -1,11 +1,170 @@
-{erl_opts, [debug_info, warn_unused_vars, warn_shadow_vars, warn_unused_import]}.
+%% -*- mode: erlang;erlang-indent-level: 4;indent-tabs-mode: nil -*-
+%% ex: ts=4 sw=4 ft=erlang et
-{port_sources, ["c_src/*.c"]}.
+{erl_opts, [debug_info]}.
+{require_otp_vsn, "R14|R15"}.
-{so_name, "erlgeom.so"}.
+%% == Core ==
-{port_envs, [
- % Link the GEOS C binding
- %{".*", "CFLAGS", "$CFLAGS -g -Wall"},
- {".*", "LDFLAGS", "$LDFLAGS -lgeos_c"}
+%% Additional library directories to add to the code path
+%% TODO use git and deps for this in future
+{lib_dirs, ["deps/geos/lib"]}.
+
+%% == Erlang Compiler ==
+
+%% == Port Compiler ==
+
+%% Port compilation environment variables. See rebar_port_compiler.erl for
+%% more info. Default is `[]'
+% rebar: {port_env, [{"CFLAGS", "$CFLAGS -Ifoo"},
+% {"freebsd", "LDFLAGS", "$LDFLAGS -lfoo"}]}.
+%
+%
+% erlgeom: {port_envs, [
+% % Link the GEOS C binding
+% %{".*", "CFLAGS", "$CFLAGS -g -Wall"},
+% {".*", "LDFLAGS", "$LDFLAGS -lgeos_c"}
+%]}.
+{port_env, [
+ {"unix", "DRV_LDFLAGS", "$LDFLAGS -lgeos_c"},
+ %% add MS Visual C++ support to rebar on Windows
+ {"win32", "CC", "cl.exe"},
+ {"win32", "CXX", "cl.exe"},
+ {"win32", "LINKER", "link.exe"},
+ %% DRV_* and EXE_* Templates are identical
+ {"win32", "DRV_CXX_TEMPLATE",
+ "$CXX /c $CXXFLAGS $DRV_CFLAGS $PORT_IN_FILES /Fo$PORT_OUT_FILE"},
+ {"win32", "DRV_CC_TEMPLATE",
+ "$CC /c $CFLAGS $DRV_CFLAGS $PORT_IN_FILES /Fo$PORT_OUT_FILE"},
+ {"win32", "DRV_LINK_TEMPLATE",
+ "$LINKER $PORT_IN_FILES $LDFLAGS $DRV_LDFLAGS /OUT:$PORT_OUT_FILE"},
+ %% DRV_* and EXE_* Templates are identical
+ {"win32", "EXE_CXX_TEMPLATE",
+ "$CXX /c $CXXFLAGS $EXE_CFLAGS $PORT_IN_FILES /Fo$PORT_OUT_FILE"},
+ {"win32", "EXE_CC_TEMPLATE",
+ "$CC /c $CFLAGS $EXE_CFLAGS $PORT_IN_FILES /Fo$PORT_OUT_FILE"},
+ {"win32", "EXE_LINK_TEMPLATE",
+ "$LINKER $PORT_IN_FILES $LDFLAGS $EXE_LDFLAGS /OUT:$PORT_OUT_FILE"},
+ %% ERL_CFLAGS are ok as -I even though strictly it should be /I
+ {"win32", "ERL_LDFLAGS", " /LIBPATH:$ERL_EI_LIBDIR erl_interface.lib ei.lib"},
+ {"win32", "DRV_CFLAGS", "/Zi /Wall $ERL_CFLAGS"},
+ {"win32", "DRV_LDFLAGS", "/DLL $ERL_LDFLAGS"},
+ %% geos-specific flags
+ {"win32", "DRV_LDFLAGS", "$DRV_LDFLAGS /LIBPATH:deps/geos/lib geos_c.lib"},
+ {"win32", "DRV_CFLAGS", "$DRV_CFLAGS /Ideps/geos/include"}
]}.
+
+%% port_specs
+%% List of filenames or wildcards to be compiled. May also contain a tuple
+%% consisting of a regular expression to be applied against the system
+%% architecture as a filter.
+%{port_specs, [{"priv/so_name.so", ["c_src/*.c"]},
+% {"linux", "priv/hello_linux", ["c_src/hello_linux.c"]},
+% {"linux", "priv/hello_linux", ["c_src/*.c"], [{env, []}]}}.
+% {port_sources, ["c_src/*.c"]}.
+{port_specs, [
+ {"unix", "priv/erlgeom.so", ["c_src/*.c"]},
+ {"win32", "priv/erlgeom.dll", ["c_src/*.c"]}]}.
+%
+%%% == EUnit ==
+%
+%%% Options for eunit:test()
+%{eunit_opts, []}.
+%
+%%% Additional compile options for eunit. erl_opts from above is also used
+%{eunit_compile_opts, []}.
+%
+%%% Same as erl_first_files, but used only when running 'eunit'
+%{eunit_first_files, []}.
+%
+%%% Whether to enable coverage reporting. Default is `false'
+%{cover_enabled, false}.
+%
+%%% Whether to print coverage report to console. Default is `false'
+%{cover_print_enabled, false}.
+%
+%%% == Common Test ==
+%
+%%% Override the default "test" directory in which SUITEs are located
+%{ct_dir, "itest"}.
+%
+%%% Option to pass extra parameters when launching Common Test
+%{ct_extra_params, "-boot start_sasl -s myapp"}.
+%
+%%% == Cleanup ==
+%
+%%% Which files to cleanup
+%{clean_files, ["file", "file2"]}.
+%
+%%% == Reltool ==
+%
+%%% Target directory for the release
+{target, "erlgeom-0.1.0"}.
+%
+%%% == OTP Applications ==
+%
+%%% Binaries to link into the erlang path?
+%{app_bin, []}.
+%
+%%% Enable validation of the OTP app module list. Default is 'true'
+%{validate_app_modules, true}.
+%
+%%% == Dependencies ==
+%
+%%% Where to put any downloaded dependencies. Default is "deps"
+{deps_dir, "deps"}.
+%
+%%% What dependencies we have, dependencies can be of 3 forms, an application
+%%% name as an atom, eg. mochiweb, a name and a version (from the .app file), or
+%%% an application name, a version and the SCM details on how to fetch it (SCM
+%%% type, location and revision). Rebar currently supports git, hg, bzr and svn.
+%{deps, [application_name,
+% {application_name, "1.0.*"},
+% {application_name, "1.0.*",
+% {git, "git://github.com/basho/rebar.git", {branch, "master"}}}]}.
+%
+%%% == Subdirectories ==
+%
+%%% Subdirectories?
+%{sub_dirs, ["dir1", "dir2"]}.
+%
+%%% == Plugins ==
+%
+%%% Plugins you wish to include.
+%%% These can include any module on the code path, including deps.
+%%% Alternatively, plugins can be placed as source files in the plugin_dir, in
+%%% which case they will be compiled and loaded dynamically at runtime.
+%{plugins, [plugin1, plugin2]}.
+%
+%%% Override the directory in which plugin sources can be found.
+%%% Defaults to ./plugins
+%{plugin_dir, "some_other_directory"}.
+%
+%
+%%% == Pre/Post Command Hooks ==
+%
+%{pre_hooks, [{clean, "./prepare_package_files.sh"},
+% {"linux", compile, "c_src/build_linux.sh"},
+% {compile, "escript generate_headers"},
+% {compile, "escript check_headers"}]}.
+%
+%{post_hooks, [{clean, "touch file1.out"},
+% {"freebsd", compile, "c_src/freebsd_tweaks.sh"},
+% {eunit, "touch file2.out"},
+% {compile, "touch postcompile.out"}]}.
+%
+%%% == xref ==
+%
+%{xref_warnings, false}.
+%
+%%% xref checks to run
+%{xref_checks, [exports_not_used, undefined_function_calls]}.
+%
+%%% Optional custom xref queries (xref manual has details) specified as
+%%% {xref_queries, [{query_string(), expected_query_result()},...]}
+%%% The following for example removes all references to ejabberd:*_msg/4
+%%% functions from undefined external function calls as those are in a
+%%% generated module
+%{xref_queries,
+% [{"(XC - UC) || (XU - X - B"
+% " - (\"ejabberd_logger\":\".*_msg\"/\"4\"))",[]}]}.
Something went wrong with that request. Please try again.