Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Can't build network library on Windows #17

Closed
edwinb opened this issue May 20, 2020 · 11 comments
Closed

Can't build network library on Windows #17

edwinb opened this issue May 20, 2020 · 11 comments
Labels
Installation Issue Problem compiling or running Idris

Comments

@edwinb
Copy link
Collaborator

edwinb commented May 20, 2020

Issue by zenntenn
Saturday Aug 10, 2019 at 17:07 GMT
Originally opened as edwinb/Idris2-boot#78


Using Idris 1.3.2, and msys64, on Windows 10.

I was able to resolve the issues in https://github.com/edwinb/Idris2/issues/41, but now I'm getting stuck on the make network step, after completing make idris2, make prelude and make base.

C:\Users\joshua.hillerup\Source\Idris\Idris2>make network
make -C libs/prelude IDRIS2=../../idris2
make[1]: Entering directory '/c/Users/joshua.hillerup/Source/Idris/Idris2/libs/prelude'
../../idris2 --build prelude.ipkg
make[1]: Leaving directory '/c/Users/joshua.hillerup/Source/Idris/Idris2/libs/prelude'
make -C libs/network IDRIS2=../../idris2
make[1]: Entering directory '/c/Users/joshua.hillerup/Source/Idris/Idris2/libs/network'
cc    -c -o idris_net.o idris_net.c
cc -o idris_net.so  -shared idris_net.o -lws2_32
creating 'build' directory
../../idris2 --build network.ipkg
1/3: Building Network.Socket.Data (Network/Socket/Data.idr)
2/3: Building Network.Socket.Raw (Network/Socket/Raw.idr)
3/3: Building Network.Socket (Network/Socket.idr)
make[1]: Leaving directory '/c/Users/joshua.hillerup/Source/Idris/Idris2/libs/network'
make -C libs/network test IDRIS2=../../idris2
make[1]: Entering directory '/c/Users/joshua.hillerup/Source/Idris/Idris2/libs/network'
cp idris_net.so libidris_net.so # to make C linker happy
cc -o network-tests -L. -I. test.c -lidris_net
test.c:3:10: fatal error: netinet/in.h: No such file or directory
    3 | #include <netinet/in.h>
      |          ^~~~~~~~~~~~~~
compilation terminated.
make[1]: *** [Makefile:52: test] Error 1
make[1]: Leaving directory '/c/Users/joshua.hillerup/Source/Idris/Idris2/libs/network'
make: *** [Makefile:31: network] Error 2

Note: I do have netinet\in.h in my path, it's the first path entry even just to be sure.

Also, I added the -lws2_32 switch myself. Without it it fails earlier, with this error:

C:\Users\joshua.hillerup\Source\Idris\Idris2>make network
make -C libs/prelude IDRIS2=../../idris2
make[1]: Entering directory '/c/Users/joshua.hillerup/Source/Idris/Idris2/libs/prelude'
../../idris2 --build prelude.ipkg
make[1]: Leaving directory '/c/Users/joshua.hillerup/Source/Idris/Idris2/libs/prelude'
make -C libs/network IDRIS2=../../idris2
make[1]: Entering directory '/c/Users/joshua.hillerup/Source/Idris/Idris2/libs/network'
cc    -c -o idris_net.o idris_net.c
cc -o idris_net.so  -shared idris_net.o
idris_net.o:idris_net.c:(.text+0xb): undefined reference to `__imp_WSACleanup'
idris_net.o:idris_net.c:(.text+0x39): undefined reference to `__imp_WSAStartup'
idris_net.o:idris_net.c:(.text+0xa5): undefined reference to `__imp_htonl'
idris_net.o:idris_net.c:(.text+0x121): undefined reference to `__imp_ntohl'
idris_net.o:idris_net.c:(.text+0x1cf): undefined reference to `__imp_socket'
idris_net.o:idris_net.c:(.text+0x25b): undefined reference to `__imp_getaddrinfo'
idris_net.o:idris_net.c:(.text+0x27c): undefined reference to `__imp_getaddrinfo'
idris_net.o:idris_net.c:(.text+0x2ed): undefined reference to `__imp_bind'
idris_net.o:idris_net.c:(.text+0x337): undefined reference to `__imp_getsockname'
idris_net.o:idris_net.c:(.text+0x380): undefined reference to `__imp_getsockname'
idris_net.o:idris_net.c:(.text+0x3b9): undefined reference to `__imp_ntohs'
idris_net.o:idris_net.c:(.text+0x3d4): undefined reference to `__imp_ntohs'
idris_net.o:idris_net.c:(.text+0x44f): undefined reference to `__imp_connect'
idris_net.o:idris_net.c:(.text+0x468): undefined reference to `__imp_freeaddrinfo'
idris_net.o:idris_net.c:(.text+0x47f): undefined reference to `__imp_freeaddrinfo'
idris_net.o:idris_net.c:(.text+0x4f6): undefined reference to `__imp_inet_ntop'
idris_net.o:idris_net.c:(.text+0x52a): undefined reference to `__imp_ntohs'
idris_net.o:idris_net.c:(.text+0x585): undefined reference to `__imp_accept'
idris_net.o:idris_net.c:(.text+0x5ca): undefined reference to `__imp_send'
idris_net.o:idris_net.c:(.text+0x657): undefined reference to `__imp_send'
idris_net.o:idris_net.c:(.text+0x6dd): undefined reference to `__imp_recv'
idris_net.o:idris_net.c:(.text+0x74c): undefined reference to `__imp_recv'
idris_net.o:idris_net.c:(.text+0x87e): undefined reference to `__imp_sendto'
idris_net.o:idris_net.c:(.text+0x891): undefined reference to `__imp_freeaddrinfo'
idris_net.o:idris_net.c:(.text+0x933): undefined reference to `__imp_sendto'
idris_net.o:idris_net.c:(.text+0xa12): undefined reference to `__imp_recvfrom'
idris_net.o:idris_net.c:(.text+0xb0e): undefined reference to `__imp_recvfrom'
idris_net.o:idris_net.c:(.text+0xbea): undefined reference to `__imp_ntohs'
collect2.exe: error: ld returned 1 exit status
make[1]: *** [Makefile:39: idris_net.so] Error 1
make[1]: Leaving directory '/c/Users/joshua.hillerup/Source/Idris/Idris2/libs/network'
make: *** [Makefile:30: network] Error 2
@edwinb edwinb added the Installation Issue Problem compiling or running Idris label May 20, 2020
@edwinb
Copy link
Collaborator Author

edwinb commented May 20, 2020

Comment by abailly
Sunday Aug 11, 2019 at 07:30 GMT


@zenntenn I saw on slack you have a fix for that? Could you give me some precisions on the environment needed on windows to compile Idris2? I have a Windows VM but did not yet spend the time to configure it properly...

@edwinb
Copy link
Collaborator Author

edwinb commented May 20, 2020

Comment by melted
Sunday Aug 11, 2019 at 10:19 GMT


@zenntenn <> denotes that it looks for the include in the system include path and not the user ones. You should probably just ifdef it away on windows, like in idris_net.c.

@edwinb
Copy link
Collaborator Author

edwinb commented May 20, 2020

Comment by zenntenn
Sunday Aug 11, 2019 at 16:01 GMT


@abailly I got passed this issue, sort of, but I'm still not able to compile test.c. When skipping it I can run idris2, but when I do the install for the libraries it's failing, as well as some of the (non-network) tests are failing for reasons I don't entirely understand.

I have a branch on my repo for what I'm working on right here: https://github.com/zenntenn/Idris2/tree/MyConfigs-DontMerge It has some configs unique to my machine in there, as I don't really want to make a proper branch for PR purposes until I actually get it working on my machine.

@edwinb
Copy link
Collaborator Author

edwinb commented May 20, 2020

Comment by zenntenn
Sunday Aug 11, 2019 at 17:00 GMT


@melted adding that to test.c does move things forward a bit

#ifndef _WIN32
#include <netinet/in.h>
#include <arpa/inet.h>
#else
#include <winsock2.h>
#include <Ws2tcpip.h>
#endif

but still fails later

C:\Users\joshua.hillerup\Source\Idris\Idris2>make network
make -C libs/prelude IDRIS2=../../idris2
make[1]: Entering directory '/c/Users/joshua.hillerup/Source/Idris/Idris2/libs/prelude'
../../idris2 --build prelude.ipkg
make[1]: Leaving directory '/c/Users/joshua.hillerup/Source/Idris/Idris2/libs/prelude'
make -C libs/network IDRIS2=../../idris2
make[1]: Entering directory '/c/Users/joshua.hillerup/Source/Idris/Idris2/libs/network'
cc    -c -o idris_net.o idris_net.c
cc -o idris_net.so  -shared idris_net.o -lws2_32
directory 'build' exists
../../idris2 --build network.ipkg
make[1]: Leaving directory '/c/Users/joshua.hillerup/Source/Idris/Idris2/libs/network'
make -C libs/network test IDRIS2=../../idris2
make[1]: Entering directory '/c/Users/joshua.hillerup/Source/Idris/Idris2/libs/network'
directory 'build' exists
../../idris2 --build network.ipkg
cp idris_net.so libidris_net.so # to make C linker happy
cc -o network-tests -L. -I. test.c -lidris_net
test.c: In function 'test_sockaddr_port_returns_random_port_when_bind_port_is_0':
test.c:23:3: warning: implicit declaration of function 'close'; did you mean 'fclose'? [-Wimplicit-function-declaration]
   23 |   close(sock);
      |   ^~~~~
      |   fclose
C:/msys64/mingw64/bin/../lib/gcc/x86_64-w64-mingw32/9.1.0/../../../../x86_64-w64-mingw32/bin/ld.exe: cannot find -lidris_net
collect2.exe: error: ld returned 1 exit status
make[1]: *** [Makefile:52: test] Error 1
make[1]: Leaving directory '/c/Users/joshua.hillerup/Source/Idris/Idris2/libs/network'
make: *** [Makefile:32: network] Error 2

@edwinb
Copy link
Collaborator Author

edwinb commented May 20, 2020

Comment by arabelladonna
Thursday Apr 02, 2020 at 23:44 GMT


Using this as a guide, I tried running make idris2 in MSYS2's MinGW64 terminal today and it is failing during linking due to idris_net.c. Is there something else that I'm supposed to be doing to get Idris 2 built at all?

@edwinb
Copy link
Collaborator Author

edwinb commented May 20, 2020

Comment by abailly
Friday Apr 03, 2020 at 06:40 GMT


@arabelladonna I now have access to a windows machine, I will give it a try this week-end and see if I can fix that. Do you have the same error than the one reported by @zenntenn ?

@edwinb
Copy link
Collaborator Author

edwinb commented May 20, 2020

Comment by arabelladonna
Friday Apr 03, 2020 at 18:26 GMT


Sorry for the late response. Here's the exact output:

$ make idris2
Using Idris 1 version: 1.3.2
Building Idris 2 version: 0.1.0-59503712f
idris --build idris2.ipkg
Entering directory `.\src'
Leaving directory `.\src'
make -C dist
make[1]: Entering directory '/d/code/github/idris2/dist'
make -C rts
make[2]: Entering directory '/d/code/github/idris2/dist/rts'
make[2]: Nothing to be done for 'build'.
make[2]: Leaving directory '/d/code/github/idris2/dist/rts'
clang   idris2.c -o idris2 -I rts -L rts -lidris_rts -lgmp -lm
D:\Applications\msys64\mingw64\bin\ld: D:\Applications\msys64\tmp\idris2-06e9d9.o:idris2.c:(.text+0x811cbb): undefined reference to `__imp_listen'
D:\Applications\msys64\mingw64\bin\ld: rts/libidris_rts.a(idris_net.o):idris_net.c:(.text$buf_htonl[buf_htonl]+0x1c): undefined reference to `__imp_htonl'
D:\Applications\msys64\mingw64\bin\ld: rts/libidris_rts.a(idris_net.o):idris_net.c:(.text$buf_ntohl[buf_ntohl]+0x1c): undefined reference to `__imp_ntohl'
D:\Applications\msys64\mingw64\bin\ld: rts/libidris_rts.a(idris_net.o):idris_net.c:(.text$idrnet_socket[idrnet_socket]+0x24): undefined reference to `__imp_WSAStartup'
D:\Applications\msys64\mingw64\bin\ld: rts/libidris_rts.a(idris_net.o):idris_net.c:(.text$idrnet_socket[idrnet_socket]+0x56): undefined reference to `__imp_socket'
D:\Applications\msys64\mingw64\bin\ld: rts/libidris_rts.a(idris_net.o):idris_net.c:(.text$idrnet_getaddrinfo[idrnet_getaddrinfo]+0x69): undefined reference to `__imp_getaddrinfo'
D:\Applications\msys64\mingw64\bin\ld: rts/libidris_rts.a(idris_net.o):idris_net.c:(.text$idrnet_bind[idrnet_bind]+0x72): undefined reference to `__imp_getaddrinfo'
D:\Applications\msys64\mingw64\bin\ld: rts/libidris_rts.a(idris_net.o):idris_net.c:(.text$idrnet_bind[idrnet_bind]+0x93): undefined reference to `__imp_bind'
D:\Applications\msys64\mingw64\bin\ld: rts/libidris_rts.a(idris_net.o):idris_net.c:(.text$idrnet_connect[idrnet_connect]+0x72): undefined reference to `__imp_getaddrinfo'
D:\Applications\msys64\mingw64\bin\ld: rts/libidris_rts.a(idris_net.o):idris_net.c:(.text$idrnet_connect[idrnet_connect]+0x91): undefined reference to `__imp_connect'
D:\Applications\msys64\mingw64\bin\ld: rts/libidris_rts.a(idris_net.o):idris_net.c:(.text$idrnet_connect[idrnet_connect]+0xa5): undefined reference to `__imp_freeaddrinfo'
D:\Applications\msys64\mingw64\bin\ld: rts/libidris_rts.a(idris_net.o):idris_net.c:(.text$idrnet_sockaddr_ipv4[idrnet_sockaddr_ipv4]+0x2a): undefined reference to `__imp_inet_ntop'
D:\Applications\msys64\mingw64\bin\ld: rts/libidris_rts.a(idris_net.o):idris_net.c:(.text$idrnet_sockaddr_ipv4_port[idrnet_sockaddr_ipv4_port]+0xa): undefined reference to `__imp_ntohs'
D:\Applications\msys64\mingw64\bin\ld: rts/libidris_rts.a(idris_net.o):idris_net.c:(.text$idrnet_accept[idrnet_accept]+0x16): undefined reference to `__imp_accept'
D:\Applications\msys64\mingw64\bin\ld: rts/libidris_rts.a(idris_net.o):idris_net.c:(.text$idrnet_send[idrnet_send]+0x28): undefined reference to `__imp_send'
D:\Applications\msys64\mingw64\bin\ld: rts/libidris_rts.a(idris_net.o):idris_net.c:(.text$idrnet_send_buf[idrnet_send_buf]+0x3e): undefined reference to `__imp_htonl'
D:\Applications\msys64\mingw64\bin\ld: rts/libidris_rts.a(idris_net.o):idris_net.c:(.text$idrnet_send_buf[idrnet_send_buf]+0x6f): undefined reference to `__imp_send'
D:\Applications\msys64\mingw64\bin\ld: rts/libidris_rts.a(idris_net.o):idris_net.c:(.text$idrnet_recv[idrnet_recv]+0x48): undefined reference to `__imp_recv'
D:\Applications\msys64\mingw64\bin\ld: rts/libidris_rts.a(idris_net.o):idris_net.c:(.text$idrnet_recv_buf[idrnet_recv_buf]+0x18): undefined reference to `__imp_recv'
D:\Applications\msys64\mingw64\bin\ld: rts/libidris_rts.a(idris_net.o):idris_net.c:(.text$idrnet_recv_buf[idrnet_recv_buf]+0x34): undefined reference to `__imp_ntohl'
D:\Applications\msys64\mingw64\bin\ld: rts/libidris_rts.a(idris_net.o):idris_net.c:(.text$idrnet_sendto[idrnet_sendto]+0x76): undefined reference to `__imp_getaddrinfo'
D:\Applications\msys64\mingw64\bin\ld: rts/libidris_rts.a(idris_net.o):idris_net.c:(.text$idrnet_sendto[idrnet_sendto]+0xb1): undefined reference to `__imp_sendto'
D:\Applications\msys64\mingw64\bin\ld: rts/libidris_rts.a(idris_net.o):idris_net.c:(.text$idrnet_sendto[idrnet_sendto]+0xbe): undefined reference to `__imp_freeaddrinfo'
D:\Applications\msys64\mingw64\bin\ld: rts/libidris_rts.a(idris_net.o):idris_net.c:(.text$idrnet_sendto_buf[idrnet_sendto_buf]+0x83): undefined reference to `__imp_getaddrinfo'
D:\Applications\msys64\mingw64\bin\ld: rts/libidris_rts.a(idris_net.o):idris_net.c:(.text$idrnet_sendto_buf[idrnet_sendto_buf]+0xa2): undefined reference to `__imp_htonl'
D:\Applications\msys64\mingw64\bin\ld: rts/libidris_rts.a(idris_net.o):idris_net.c:(.text$idrnet_sendto_buf[idrnet_sendto_buf]+0xe4): undefined reference to `__imp_sendto'
D:\Applications\msys64\mingw64\bin\ld: rts/libidris_rts.a(idris_net.o):idris_net.c:(.text$idrnet_recvfrom[idrnet_recvfrom]+0xa2): undefined reference to `__imp_recvfrom'
D:\Applications\msys64\mingw64\bin\ld: rts/libidris_rts.a(idris_net.o):idris_net.c:(.text$idrnet_recvfrom_buf[idrnet_recvfrom_buf]+0x92): undefined reference to `__imp_recvfrom'
D:\Applications\msys64\mingw64\bin\ld: rts/libidris_rts.a(idris_net.o):idris_net.c:(.text$idrnet_recvfrom_buf[idrnet_recvfrom_buf]+0xb2): undefined reference to `__imp_ntohl'
D:\Applications\msys64\mingw64\bin\ld: rts/libidris_rts.a(idris_net.o):idris_net.c:(.text$idrnet_get_recvfrom_port[idrnet_get_recvfrom_port]+0x13): undefined reference to `__imp_ntohs'
D:\Applications\msys64\mingw64\bin\ld: rts/libidris_rts.a(idris_net.o):idris_net.c:(.text$clean_sockets[clean_sockets]+0x3): undefined reference to `__imp_WSACleanup'
clang: error: linker command failed with exit code 1 (use -v to see invocation)
make[1]: *** [Makefile:7: idris2] Error 1
make[1]: Leaving directory '/d/code/github/idris2/dist'
make: *** [Makefile:75: idris2-fromc] Error 2

@edwinb
Copy link
Collaborator Author

edwinb commented May 20, 2020

Comment by abailly
Sunday Apr 05, 2020 at 18:56 GMT


@arabelladonna Seems like your error is different than the one reported by @zenntenn : Linker fails while building idris2 itself from the Idris1 C RTS sources, not when trying to build the idris2 network library.

@edwinb
Copy link
Collaborator Author

edwinb commented May 20, 2020

Comment by arabelladonna
Sunday Apr 05, 2020 at 19:30 GMT


Yeah, I had said in my original post that it was failing during linking due to idris_net.c. should I open a separate issue or is it related enough to keep here?

@edwinb
Copy link
Collaborator Author

edwinb commented May 20, 2020

Comment by abailly
Sunday Apr 05, 2020 at 20:09 GMT


The thing is that's 2 different situations because there are 2 different idris_net.c : One that's part of the C RTS for Idris1 that's used to build Idris2, one that's in libs/network. The 2 libraries are built differently, I suggest you open a separate issue.

@melted
Copy link
Collaborator

melted commented May 24, 2020

Solved here.

@melted melted closed this as completed May 24, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Installation Issue Problem compiling or running Idris
Projects
None yet
Development

No branches or pull requests

2 participants