GSoC 2014 Ideas

Lubomir I. Ivanov neolit123 at
Wed Feb 26 11:10:36 UTC 2014

On 26 February 2014 20:51, Alberto Corona <albcoron at> wrote:
> Hey Lubomir, I've tried building subsurface natively on Windows but ran into
> quite a few problems when following the INSTALL instructions. What method do
> you got about doing so to build successfully? The major issue I ran into was
> due to the suggested build instructions for libdivecomputer for Windows.

building natively on windows is quite troublesome indeed and i think
i'm the only persons who does that.
there are issues on many levels that are not really covered in the
INSTALL section as it will essentially turn into a bit of a rant.

i would suggest that you try cross build from linux at first, as
probably your package manager will help you install all dependencies.

still, if you want to attempt this, attached is the (ugly) build
script that i use to build libDC (build.txt) - place in the libDC
root, but you need to edit the libusb path in there, or disable
libusb. i think the reason for the script was that i don't have
autotool installed here.

the second attachment is a wrapper for pkgconfig if you wish to use
.pc files, because the official pkgconfig binary breaks 'make' badly
with a rogue CRLF.

rename .txt to .cmd.

-------------- next part --------------
@echo off

:: goto skip

if not exist lib md lib
cd lib
rm *.o *.dll libdivecomputer-win32.a
cd ..\src
@echo on

mv serial_posix.c serial_posix.c_
mv irda.c irda.c_

set FLAGS=
set LIBUSB=C:\dev\linux_lib\libusb\

for %%i in (*.c) do @gcc -I../include/ -I%LIBUSB% -c -DHAVE_LIBUSB -DWIN32 -D_WINDOWS -DLIBDIVECOMPUTER_EXPORTS %FLAGS% --std=c99 %%i -o ../lib/%%i.o && echo %%i

mv serial_posix.c_ serial_posix.c
mv irda.c_ irda.c

@cd ..\lib

:: rm irda_dummy.c.o

:: :skip

@echo on

@ set o_files=
for %%i in (*.o) do @set iv=!iv! %%i

@ ENDLOCAL & set o_files=%iv%

:: goto exit

gcc %o_files% -o libdivecomputer.dll -mwindows -lWs2_32 -L%LIBUSB%\libusb-1.0\ -lusb-1.0 -shared
:: if not exist libdivecomputer.dll goto error
@echo off
echo ar rcs...
for %%i in (*.o) do ar rcs libdivecomputer-win32.a %%i
rm *.o
echo DONE. objects files in ./OBJ
cd ..
goto exit

echo ERROR

-------------- next part --------------
:: pkg-config.cmd
@echo off
:: store last line with output into a variable
for /f "tokens=*" %%a in ('_pkg-config %*') do ( 
	set out=%%a
:: truncate extra CRLF from line
if "%out%" NEQ "" (
   echo %out% | tr '\r\n' ' '
set out=

More information about the subsurface mailing list