BinaryBuilder.jl mingw problem

I know the solution when using make:

FLAGS=()
if [[ "${target}" == *-mingw* ]]; then
    # This is needed in order to build the shared library on Windows when we get
    #   libtool: warning: undefined symbols not allowed in x86_64-w64-mingw32 shared libraries; building static only
    FLAGS+=(LDFLAGS="-no-undefined")
fi
./configure --prefix=${prefix} --build=${MACHTYPE} --host=${target}
make -j ${nprocs} "${FLAGS[@]}"
make install

My build script is simpler:

$CC $CFLAGS $LDFLAGS *.c rcv/*.c -o $libdir/librtk.${dlext} -I.

How can I use -no-undefined linker flag in my simple build script? I would like to avoid using make.

I tried with makefile:

.PHONY : clean

CFLAGS = -DWIN32 -DWIN_DLL -DENAGLO -DENAGAL -DENAQZS -DENACMP -DENAIRN -DTRACE -DNFREQ=5 -DNEXOBS=3 -DSVR_REUSEADDR -I. -fpic -Wall -O3 -ansi -pedantic -Wno-unused-but-set-variable -g
LDFLAGS = -lm -lpthread -shared

SOURCES = $(shell echo *.c rcv/*.c)
HEADERS = $(shell echo *.h)
OBJECTS = $(SOURCES:.c=.o)


TARGET = $(libdir)/librtk.${dlext}

all: $(TARGET)

clean:
    rm -f $(OBJECTS) $(TARGET)

$(TARGET) : $(OBJECTS)
    $(CC) $(CFLAGS) $(OBJECTS) -o $@ $(LDFLAGS)

but it doesn’t help:

sandbox:${WORKSPACE}/srcdir/RTKLIB/src # FLAGS=()
sandbox:${WORKSPACE}/srcdir/RTKLIB/src # FLAGS+=(LDFLAGS="-no-undefined")
sandbox:${WORKSPACE}/srcdir/RTKLIB/src # make -j ${nprocs} "${FLAGS[@]}"
cc -DWIN32 -DWIN_DLL -DENAGLO -DENAGAL -DENAQZS -DENACMP -DENAIRN -DTRACE -DNFREQ=5 -DNEXOBS=3 -DSVR_REUSEADDR -I. -fpic -Wall -O3 -ansi -pedantic -Wno-unused-but-set-variable -g convgpx.o convkml.o convrnx.o datum.o download.o ephemeris.o geoid.o gis.o ionex.o lambda.o options.o pntpos.o postpos.o ppp.o ppp_ar.o preceph.o rcvraw.o rinex.o rtcm.o rtcm2.o rtcm3.o rtcm3e.o rtkcmn.o rtkpos.o rtksvr.o sbas.o solution.o stream.o streamsvr.o tides.o tle.o rcv/binex.o rcv/crescent.o rcv/javad.o rcv/novatel.o rcv/nvs.o rcv/rt17.o rcv/septentrio.o rcv/skytraq.o rcv/ss2.o rcv/ublox.o -o /workspace/destdir/bin/librtk.dll -no-undefined 
x86_64-w64-mingw32-gcc: error: unrecognized command line option ‘-no-undefined’
make: *** [makefile:19: /workspace/destdir/bin/librtk.dll] Error 1

I guess it is because I don’t have any configure script.

That’s a linker flag, you can pass flags to the linker with -Wl,..., e.g. -Wl,-no-undefined

1 Like

Thanks. I think I already tried it. I will try again and report the output. Cross-compiling is hard even with the best tools.

Here is the output:

cc -DWIN32 -DWIN_DLL -DENAGLO -DENAGAL -DENAQZS -DENACMP -DENAIRN -DTRACE -DNFREQ=5 -DNEXOBS=3 -DSVR_REUSEADDR -I. -fpic -Wall -O3 -ansi -pedantic -Wno-unused-but-set-variable -g convgpx.o convkml.o convrnx.o datum.o download.o ephemeris.o geoid.o gis.o ionex.o lambda.o options.o pntpos.o postpos.o ppp.o ppp_ar.o preceph.o rcvraw.o rinex.o rtcm.o rtcm2.o rtcm3.o rtcm3e.o rtkcmn.o rtkpos.o rtksvr.o sbas.o solution.o stream.o streamsvr.o tides.o tle.o rcv/binex.o rcv/crescent.o rcv/javad.o rcv/novatel.o rcv/nvs.o rcv/rt17.o rcv/septentrio.o rcv/skytraq.o rcv/ss2.o rcv/ublox.o -o /workspace/destdir/bin/librtk.dll -lm -lpthread -shared -Wl,-no-undefined
rtkcmn.o: In function `tickget':
/workspace/srcdir/RTKLIB/src/rtkcmn.c:1851: undefined reference to `__imp_timeGetTime'
/workspace/srcdir/RTKLIB/src/rtkcmn.c:1851: undefined reference to `__imp_timeGetTime'
/workspace/srcdir/RTKLIB/src/rtkcmn.c:1851: undefined reference to `__imp_timeGetTime'
stream.o: In function `discontcp':
/workspace/srcdir/RTKLIB/src/stream.c:1148: undefined reference to `__imp_closesocket'
stream.o: In function `setsock':
/workspace/srcdir/RTKLIB/src/stream.c:999: undefined reference to `__imp_setsockopt'
stream.o: In function `errsock':
/workspace/srcdir/RTKLIB/src/stream.c:983: undefined reference to `__imp_WSAGetLastError'
/workspace/srcdir/RTKLIB/src/stream.c:983: undefined reference to `__imp_WSAGetLastError'
stream.o: In function `setsock':
/workspace/srcdir/RTKLIB/src/stream.c:1003: undefined reference to `__imp_closesocket'
stream.o: In function `errsock':
/workspace/srcdir/RTKLIB/src/stream.c:983: undefined reference to `__imp_WSAGetLastError'
stream.o: In function `gentcp':
/workspace/srcdir/RTKLIB/src/stream.c:1096: undefined reference to `__imp_socket'
/workspace/srcdir/RTKLIB/src/stream.c:1108: undefined reference to `__imp_htons'
/workspace/srcdir/RTKLIB/src/stream.c:1127: undefined reference to `__imp_gethostbyname'
/workspace/srcdir/RTKLIB/src/stream.c:1114: undefined reference to `__imp_setsockopt'
/workspace/srcdir/RTKLIB/src/stream.c:1117: undefined reference to `__imp_bind'
/workspace/srcdir/RTKLIB/src/stream.c:1124: undefined reference to `__imp_listen'
stream.o: In function `errsock':
/workspace/srcdir/RTKLIB/src/stream.c:983: undefined reference to `__imp_WSAGetLastError'
/workspace/srcdir/RTKLIB/src/stream.c:983: undefined reference to `__imp_WSAGetLastError'
stream.o: In function `gentcp':
/workspace/srcdir/RTKLIB/src/stream.c:1120: undefined reference to `__imp_closesocket'
stream.o: In function `errsock':
/workspace/srcdir/RTKLIB/src/stream.c:983: undefined reference to `__imp_WSAGetLastError'
stream.o: In function `gentcp':
/workspace/srcdir/RTKLIB/src/stream.c:1130: undefined reference to `__imp_closesocket'
stream.o: In function `genudp':
/workspace/srcdir/RTKLIB/src/stream.c:2062: undefined reference to `__imp_socket'
/workspace/srcdir/RTKLIB/src/stream.c:2066: undefined reference to `__imp_setsockopt'
/workspace/srcdir/RTKLIB/src/stream.c:2073: undefined reference to `__imp_htons'
/workspace/srcdir/RTKLIB/src/stream.c:2095: undefined reference to `__imp_gethostbyname'
stream.o: In function `errsock':
/workspace/srcdir/RTKLIB/src/stream.c:983: undefined reference to `__imp_WSAGetLastError'
stream.o: In function `genudp':
/workspace/srcdir/RTKLIB/src/stream.c:2076: undefined reference to `__imp_htonl'
/workspace/srcdir/RTKLIB/src/stream.c:2080: undefined reference to `__imp_bind'
stream.o: In function `errsock':
/workspace/srcdir/RTKLIB/src/stream.c:983: undefined reference to `__imp_WSAGetLastError'
stream.o: In function `genudp':
/workspace/srcdir/RTKLIB/src/stream.c:2097: undefined reference to `__imp_closesocket'
stream.o: In function `errsock':
/workspace/srcdir/RTKLIB/src/stream.c:983: undefined reference to `__imp_WSAGetLastError'
/workspace/srcdir/RTKLIB/src/stream.c:983: undefined reference to `__imp_WSAGetLastError'
stream.o: In function `accept_nb':
/workspace/srcdir/RTKLIB/src/stream.c:1025: undefined reference to `__imp_select'
/workspace/srcdir/RTKLIB/src/stream.c:1027: undefined reference to `__imp_accept'
stream.o: In function `send_nb':
/workspace/srcdir/RTKLIB/src/stream.c:1080: undefined reference to `__imp_select'
/workspace/srcdir/RTKLIB/src/stream.c:1082: undefined reference to `__imp_send'
stream.o: In function `recv_nb':
/workspace/srcdir/RTKLIB/src/stream.c:1067: undefined reference to `__imp_select'
/workspace/srcdir/RTKLIB/src/stream.c:1069: undefined reference to `__imp_recv'
stream.o: In function `readudpsvr':
/workspace/srcdir/RTKLIB/src/stream.c:2140: undefined reference to `__imp_select'
/workspace/srcdir/RTKLIB/src/stream.c:2142: undefined reference to `__imp_recvfrom'
stream.o: In function `gentcp':
/workspace/srcdir/RTKLIB/src/stream.c:1096: undefined reference to `__imp_socket'
/workspace/srcdir/RTKLIB/src/stream.c:1108: undefined reference to `__imp_htons'
/workspace/srcdir/RTKLIB/src/stream.c:1114: undefined reference to `__imp_setsockopt'
/workspace/srcdir/RTKLIB/src/stream.c:1117: undefined reference to `__imp_bind'
/workspace/srcdir/RTKLIB/src/stream.c:1124: undefined reference to `__imp_listen'
stream.o: In function `errsock':
/workspace/srcdir/RTKLIB/src/stream.c:983: undefined reference to `__imp_WSAGetLastError'
/workspace/srcdir/RTKLIB/src/stream.c:983: undefined reference to `__imp_WSAGetLastError'
stream.o: In function `gentcp':
/workspace/srcdir/RTKLIB/src/stream.c:1120: undefined reference to `__imp_closesocket'
stream.o: In function `discontcp':
/workspace/srcdir/RTKLIB/src/stream.c:1148: undefined reference to `__imp_closesocket'
stream.o: In function `connect_nb':
/workspace/srcdir/RTKLIB/src/stream.c:1036: undefined reference to `__imp_ioctlsocket'
/workspace/srcdir/RTKLIB/src/stream.c:1037: undefined reference to `__imp_connect'
stream.o: In function `errsock':
/workspace/srcdir/RTKLIB/src/stream.c:983: undefined reference to `__imp_WSAGetLastError'
stream.o: In function `consock':
/workspace/srcdir/RTKLIB/src/stream.c:1374: undefined reference to `__imp_closesocket'
stream.o: In function `errsock':
/workspace/srcdir/RTKLIB/src/stream.c:983: undefined reference to `__imp_WSAGetLastError'
stream.o: In function `send_nb':
/workspace/srcdir/RTKLIB/src/stream.c:1080: undefined reference to `__imp_select'
/workspace/srcdir/RTKLIB/src/stream.c:1082: undefined reference to `__imp_send'
stream.o: In function `discontcp':
/workspace/srcdir/RTKLIB/src/stream.c:1148: undefined reference to `__imp_closesocket'
stream.o: In function `connect_nb':
/workspace/srcdir/RTKLIB/src/stream.c:1036: undefined reference to `__imp_ioctlsocket'
/workspace/srcdir/RTKLIB/src/stream.c:1037: undefined reference to `__imp_connect'
stream.o: In function `errsock':
/workspace/srcdir/RTKLIB/src/stream.c:983: undefined reference to `__imp_WSAGetLastError'
stream.o: In function `consock':
/workspace/srcdir/RTKLIB/src/stream.c:1374: undefined reference to `__imp_closesocket'
stream.o: In function `errsock':
/workspace/srcdir/RTKLIB/src/stream.c:983: undefined reference to `__imp_WSAGetLastError'
stream.o: In function `accsock':
/workspace/srcdir/RTKLIB/src/stream.c:1243: undefined reference to `__imp_inet_ntoa'
stream.o: In function `errsock':
/workspace/srcdir/RTKLIB/src/stream.c:983: undefined reference to `__imp_WSAGetLastError'
stream.o: In function `accsock':
/workspace/srcdir/RTKLIB/src/stream.c:1234: undefined reference to `__imp_closesocket'
stream.o: In function `errsock':
/workspace/srcdir/RTKLIB/src/stream.c:983: undefined reference to `__imp_WSAGetLastError'
stream.o: In function `discontcp':
/workspace/srcdir/RTKLIB/src/stream.c:1148: undefined reference to `__imp_closesocket'
stream.o: In function `send_nb':
/workspace/srcdir/RTKLIB/src/stream.c:1080: undefined reference to `__imp_select'
/workspace/srcdir/RTKLIB/src/stream.c:1082: undefined reference to `__imp_send'
stream.o: In function `discontcp':
/workspace/srcdir/RTKLIB/src/stream.c:1148: undefined reference to `__imp_closesocket'
/workspace/srcdir/RTKLIB/src/stream.c:1148: undefined reference to `__imp_closesocket'
stream.o: In function `send_nb':
/workspace/srcdir/RTKLIB/src/stream.c:1080: undefined reference to `__imp_select'
/workspace/srcdir/RTKLIB/src/stream.c:1082: undefined reference to `__imp_send'
/workspace/srcdir/RTKLIB/src/stream.c:1082: undefined reference to `__imp_send'
/workspace/srcdir/RTKLIB/src/stream.c:1080: undefined reference to `__imp_select'
/workspace/srcdir/RTKLIB/src/stream.c:1082: undefined reference to `__imp_send'
stream.o: In function `errsock':
/workspace/srcdir/RTKLIB/src/stream.c:983: undefined reference to `__imp_WSAGetLastError'
stream.o: In function `discontcp':
/workspace/srcdir/RTKLIB/src/stream.c:1148: undefined reference to `__imp_closesocket'
/workspace/srcdir/RTKLIB/src/stream.c:1148: undefined reference to `__imp_closesocket'
stream.o: In function `connect_nb':
/workspace/srcdir/RTKLIB/src/stream.c:1036: undefined reference to `__imp_ioctlsocket'
/workspace/srcdir/RTKLIB/src/stream.c:1037: undefined reference to `__imp_connect'
stream.o: In function `errsock':
/workspace/srcdir/RTKLIB/src/stream.c:983: undefined reference to `__imp_WSAGetLastError'
stream.o: In function `consock':
/workspace/srcdir/RTKLIB/src/stream.c:1374: undefined reference to `__imp_closesocket'
stream.o: In function `errsock':
/workspace/srcdir/RTKLIB/src/stream.c:983: undefined reference to `__imp_WSAGetLastError'
stream.o: In function `discontcp':
/workspace/srcdir/RTKLIB/src/stream.c:1148: undefined reference to `__imp_closesocket'
/workspace/srcdir/RTKLIB/src/stream.c:1148: undefined reference to `__imp_closesocket'
stream.o: In function `strinitcom':
/workspace/srcdir/RTKLIB/src/stream.c:2582: undefined reference to `__imp_WSAStartup'
stream.o: In function `closetcpcli':
/workspace/srcdir/RTKLIB/src/stream.c:1415: undefined reference to `__imp_closesocket'
stream.o: In function `closeudpcli':
/workspace/srcdir/RTKLIB/src/stream.c:2186: undefined reference to `__imp_closesocket'
stream.o: In function `closetcpsvr':
/workspace/srcdir/RTKLIB/src/stream.c:1182: undefined reference to `__imp_closesocket'
/workspace/srcdir/RTKLIB/src/stream.c:1182: undefined reference to `__imp_closesocket'
/workspace/srcdir/RTKLIB/src/stream.c:1182: undefined reference to `__imp_closesocket'
stream.o:/workspace/srcdir/RTKLIB/src/stream.c:1415: more undefined references to `__imp_closesocket' follow
stream.o: In function `errsock':
/workspace/srcdir/RTKLIB/src/stream.c:983: undefined reference to `__imp_WSAGetLastError'
stream.o: In function `discontcp':
/workspace/srcdir/RTKLIB/src/stream.c:1148: undefined reference to `__imp_closesocket'
stream.o: In function `errsock':
/workspace/srcdir/RTKLIB/src/stream.c:983: undefined reference to `__imp_WSAGetLastError'
stream.o: In function `discontcp':
/workspace/srcdir/RTKLIB/src/stream.c:1148: undefined reference to `__imp_closesocket'
stream.o: In function `writeudpcli':
/workspace/srcdir/RTKLIB/src/stream.c:2194: undefined reference to `__imp_sendto'
stream.o: In function `errsock':
/workspace/srcdir/RTKLIB/src/stream.c:983: undefined reference to `__imp_WSAGetLastError'
stream.o: In function `discontcp':
/workspace/srcdir/RTKLIB/src/stream.c:1148: undefined reference to `__imp_closesocket'
collect2: error: ld returned 1 exit status
make: *** [Makefile:20: /workspace/destdir/bin/librtk.dll] Error 1

Linux and freebsd builds fine, but windows and apple doesn’t.

That’s a different error. You need to link Windows libraries which define those functions. I don’t know what’s the problem you’re having for macOS

Thanks, maybe this macosx is also similar problem:

sandbox:${WORKSPACE}/srcdir/RTKLIB/src # make -j ${nprocs}
gcc -DENAGLO -DENAGAL -DENAQZS -DENACMP -DENAIRN -DTRACE -DNFREQ=5 -DNEXOBS=3 -DSVR_REUSEADDR -I. -fpic -Wall -O3 -ansi -pedantic -Wno-unused-but-set-variable -g convgpx.o convkml.o convrnx.o datum.o download.o ephemeris.o geoid.o gis.o ionex.o lambda.o options.o pntpos.o postpos.o ppp.o ppp_ar.o preceph.o rcvraw.o rinex.o rtcm.o rtcm2.o rtcm3.o rtcm3e.o rtkcmn.o rtkpos.o rtksvr.o sbas.o solution.o stream.o streamsvr.o tides.o tle.o rcv/binex.o rcv/crescent.o rcv/javad.o rcv/novatel.o rcv/nvs.o rcv/rt17.o rcv/septentrio.o rcv/skytraq.o rcv/ss2.o rcv/ublox.o -o /workspace/destdir/lib/librtk.dylib -lm -lpthread -shared 
Undefined symbols for architecture x86_64:
  "_settime", referenced from:
      _procpos in postpos.o
  "_settspan", referenced from:
      _execses in postpos.o
      _postpos in postpos.o
  "_showmsg", referenced from:
      _showstat in convrnx.o
      _open_strfile in convrnx.o
      _scan_file in convrnx.o
      _convrnx_s.constprop.6 in convrnx.o
      _convrnx in convrnx.o
      _test_local in download.o
      _dl_exec in download.o
      ...
ld: symbol(s) not found for architecture x86_64
collect2: error: ld returned 1 exit status
make: *** [Makefile:20: /workspace/destdir/lib/librtk.dylib] Error 1

Thanks. Here is the working solution for Windows build:

CFLAGS = -DWIN32 -DWIN_DLL -DENAGLO -DENAGAL -DENAQZS -DENACMP -DENAIRN -DTRACE -DNFREQ=5 -DNEXOBS=3 -DSVR_REUSEADDR -I. -fpic -Wall -O3 -ansi -pedantic -Wno-unused-but-set-variable -g
LDFLAGS = -lwinmm -lws2_32 -lrtm -lrtutils -lm -lpthread -shared -Wl,-no-undefined

Now I should find a similar solution to Apple’s problem above.