win7 64 bit compilation of omnetpp &veins with socket library

197 views
Skip to first unread message

Dimitris Kalogeras

unread,
Feb 13, 2013, 7:09:08 AM2/13/13
to omn...@googlegroups.com
Dear maintainers of Omnet and Veins,

I think I have managed to solve some problems with regard to  compilation of  omnet 4.2.2 samples and veins in windows 7 64bit.
when errors like send16@ appear.

The problem lies with the winsock library that is required to linked at the end of compilation in several examples of omnetpp ( 
i.e. socket, google-earth, TRaCI etc) and several models of veins.

Instead of linking with -lwsock32 you have to link with -lws2_32 which is the second version of winsock which I beleive is a requirement 
for x64 linking.

This change should be some how detected in the configure.in script  where winsock is detected..

OPP_CHECK_LIB(winsock, winsock.h, socket(0,0,0), , -lwsock32, wsock_ok, SYS_LIBS
="-lwsock32 $SYS_LIBS")

OPP_CHECK_LIB(winsock2, winsock.h, socket(0,0,0), , -lws2_32, wsock2_ok, SYS_LIBS
="-lws2_32 $SYS_LIBS")

(We might need differend include file also... but you might have to check this...

I also beleive that this check should be some how propagated upwards in the config options of the configure script accepting something like 
build=x86_64. Unfortunatelly my limited knowledge of m4 macros do not allow to modify this.


Cheers,
Dimitris

Electrical Engineer Ph.D.
Network Engineer
NTUA/GR-Net Network Management Center
_____________________________________
skype: aweboy
voice:  +30-210-772 1863
fax:     +30-210-772 1866
e-mail: dka...@gmail.com

Rudolf Hornig

unread,
Feb 13, 2013, 8:30:16 AM2/13/13
to omn...@googlegroups.com
Thanks for the report. Could you please detain what is the original error case and how to reproduce it? I'm willing to investigate this and put the necessary changes into the configure script.

We may move to Winsock2 (currently omnet is using winsock 1.1), but first I need to understand the scope of the problem.

Thanks, Rudolf

Rudolf Hornig

unread,
Feb 13, 2013, 8:32:50 AM2/13/13
to omn...@googlegroups.com


(We might need differend include file also... but you might have to check this...
Yes, winsock2.h is needed. 

I also beleive that this check should be some how propagated upwards in the config options of the configure script accepting something like 
build=x86_64. Unfortunatelly my limited knowledge of m4 macros do not allow to modify this.

On windows OMNET is always built as a 32bit process, so there is no sucj architecture as x86_64 on windows.

Dimitris Kalogeras

unread,
Feb 13, 2013, 8:59:15 AM2/13/13
to omn...@googlegroups.com
Hi *,

Inside the omnet/samples/socket directory when I try make.. and after compiling the sources.. linking
breaks with the following errors:

g++ -Wl,--enable-auto-import -shared-libgcc -L/usr/bin -L/usr/lib -Wl,-rpath,c:/
Users/dkalo/src/omnetpp-4.2.2/lib -Wl,-rpath,. -o out/gcc-debug//sockets.exe  ou
t/gcc-debug//Cloud.o out/gcc-debug//ExtHttpClient.o out/gcc-debug//ExtTelnetClie
nt.o out/gcc-debug//HttpClient.o out/gcc-debug//HttpServer.o out/gcc-debug//Queu
eBase.o out/gcc-debug//SocketRTScheduler.o out/gcc-debug//TelnetClient.o out/gcc
-debug//TelnetServer.o out/gcc-debug//HttpMsg_m.o out/gcc-debug//NetPkt_m.o out/
gcc-debug//TelnetPkt_m.o  -Wl,--no-as-needed -Wl,--whole-archive  -Wl,--no-whole
-archive -L"c:/Users/dkalo/src/omnetpp-4.2.2/lib/gcc" -L"c:/Users/dkalo/src/omne
tpp-4.2.2/lib" -loppmaind -u _tkenv_lib -Wl,--no-as-needed -lopptkenvd -loppenvi
rd -lopplayoutd -u _cmdenv_lib -Wl,--no-as-needed -loppcmdenvd -loppenvird  -lop
psimd -lstdc++
out/gcc-debug//SocketRTScheduler.o: In function `ZN18cSocketRTScheduler13setupLi
stenerEv':
c:\Users\dkalo\src\omnetpp-4.2.2\samples\sockets/SocketRTScheduler.cc:61: undefi
ned reference to `socket@12'
c:\Users\dkalo\src\omnetpp-4.2.2\samples\sockets/SocketRTScheduler.cc:68: undefi
ned reference to `htons@4'
c:\Users\dkalo\src\omnetpp-4.2.2\samples\sockets/SocketRTScheduler.cc:69: undefi
ned reference to `bind@12'
c:\Users\dkalo\src\omnetpp-4.2.2\samples\sockets/SocketRTScheduler.cc:72: undefi
ned reference to `listen@8'
out/gcc-debug//SocketRTScheduler.o: In function `ZN18cSocketRTScheduler18receive
WithTimeoutEl':
c:\Users\dkalo\src\omnetpp-4.2.2\samples\sockets/SocketRTScheduler.cc:118: undef
ined reference to `select@20'
c:\Users\dkalo\src\omnetpp-4.2.2\samples\sockets/SocketRTScheduler.cc:121: undef
ined reference to `__WSAFDIsSet@8'
c:\Users\dkalo\src\omnetpp-4.2.2\samples\sockets/SocketRTScheduler.cc:128: undef
ined reference to `recv@16'
c:\Users\dkalo\src\omnetpp-4.2.2\samples\sockets/SocketRTScheduler.cc:132: undef
ined reference to `closesocket@4'
c:\Users\dkalo\src\omnetpp-4.2.2\samples\sockets/SocketRTScheduler.cc:138: undef
ined reference to `shutdown@8'
c:\Users\dkalo\src\omnetpp-4.2.2\samples\sockets/SocketRTScheduler.cc:140: undef
ined reference to `closesocket@4'
c:\Users\dkalo\src\omnetpp-4.2.2\samples\sockets/SocketRTScheduler.cc:159: undef
ined reference to `__WSAFDIsSet@8'
c:\Users\dkalo\src\omnetpp-4.2.2\samples\sockets/SocketRTScheduler.cc:164: undef
ined reference to `accept@12'
out/gcc-debug//SocketRTScheduler.o: In function `ZN18cSocketRTScheduler9sendByte
sEPKcj':
c:\Users\dkalo\src\omnetpp-4.2.2\samples\sockets/SocketRTScheduler.cc:246: undef
ined reference to `send@16'
out/gcc-debug//SocketRTScheduler.o: In function `Z10sock_errnov':
c:/Users/dkalo/src/omnetpp-4.2.2/include/platdep/sockets.h:54: undefined referen
ce to `WSAGetLastError@0'
out/gcc-debug//SocketRTScheduler.o: In function `Z17initsocketliboncev':
c:/Users/dkalo/src/omnetpp-4.2.2/include/platdep/sockets.h:72: undefined referen

Instead when I use the additional LIBS variable in the Makefile as
LIBS= -lws2_32  

linking complets and the produced executable is ok.

As far as the winsock2.h is concerned this is defined (but never included IMHO)
in the include/patdep/socket.h as follows :

#ifdef _WIN32
//
// Winsock version
//

// include <winsock.h> or <winsock2.h> (mutually exclusive) if neither has been
#if !defined(_WINSOCKAPI_) && !defined(_WINSOCK2API_)
# ifndef WANT_WINSOCK2
#  include <winsock.h>
# else
#  include <winsock2.h>
# endif
#endif


Cheers,
Dimitris

Rudolf Hornig

unread,
Feb 13, 2013, 9:32:08 AM2/13/13
to omn...@googlegroups.com
Hmm, this should not happen normally. This issue has nothing to do with winsock version, rather winsock was not detected at all on your system!

Check that the linker command line: it does NOT contain a -lwsock32 option , but it should. The MINGW compiler distributed with omnet contains the necessary library and header file so it should be always detected (unless some files have been corrupted)

Check the end of your Makefile.inc. It looks like this on my machine:

SYSLIBS = -lwsock32 -lstdc++
My guess is that your's does not contain this. You should check the integrity of mingw/lib/libwsock32.a and mingw/include/winsock.h

Also check the output of ./configure and look for the winsock detection line. 
This issues seems to be specific to your installation.

Rudolf
Message has been deleted

Dimitris Kalogeras

unread,
Feb 14, 2013, 7:55:58 AM2/14/13
to omn...@googlegroups.com
Hi,

I tried a clean download, extraction and  configuration and make and there is no reference iof SYSLIBS = -lwinsock -lstdc in any of Maekfile.* ..

So I guess you have something custom in your installation.

Can you verify this ?

Cheers,
Dimitris

Rudolf Hornig

unread,
Feb 14, 2013, 8:49:26 AM2/14/13
to omn...@googlegroups.com
I have already checked this in a bare windows virtual machine. Please check:

Config.log and search for 'winsock'. You should see something like this:

configure:4910: checking for winsock with CFLAGS="" LIBS="-lwsock32"
configure:4934: g++ -o conftest.exe     -Wl,--enable-auto-import -shared-libgcc -L/usr/bin -L/usr/lib -Wl,-rpath,$(OMNETPP_LIB_DIR) -Wl,-rpath,. conftest.cpp -lwsock32 >&5
configure:4940: $? = 0
configure:4946: result: yes

Also go to omnetpproot/mingw/lib and
$ md5sum libwsock32.a

it should return:
928cda9cae36e542ac79c0b6d2b57e0e *libwsock32.a

if not, then you have a faulty installation.

BTW certain WINRAR versions and the built-in windows unzip utility should not be used as they are unreliable!
Rudolf
Reply all
Reply to author
Forward
0 new messages