Cross-compiling etpub source


(Flames) #1
i386-mingw32msvc-g++: unrecognized option `-rdynamic'
build/release/game/game/g_http_client.os:g_http_client.c:(.text+0x99): undefined reference to `_send@16'
build/release/game/game/g_http_client.os:g_http_client.c:(.text+0xa5): undefined reference to `_WSAGetLastError@0'
build/release/game/game/g_http_client.os:g_http_client.c:(.text+0xe9): undefined reference to `_closesocket@4'
build/release/game/game/g_http_client.os:g_http_client.c:(.text+0x4ed): undefined reference to `_socket@12'
build/release/game/game/g_http_client.os:g_http_client.c:(.text+0x509): undefined reference to `_inet_addr@4'
build/release/game/game/g_http_client.os:g_http_client.c:(.text+0x52c): undefined reference to `_htons@4'
build/release/game/game/g_http_client.os:g_http_client.c:(.text+0x56d): undefined reference to `_setsockopt@20'
build/release/game/game/g_http_client.os:g_http_client.c:(.text+0x583): undefined reference to `_ioctlsocket@12'
build/release/game/game/g_http_client.os:g_http_client.c:(.text+0x5b0): undefined reference to `_connect@12'
build/release/game/game/g_http_client.os:g_http_client.c:(.text+0x5bb): undefined reference to `_WSAGetLastError@0'
build/release/game/game/g_http_client.os:g_http_client.c:(.text+0x5fe): undefined reference to `_closesocket@4'
build/release/game/game/g_http_client.os:g_http_client.c:(.text+0x627): undefined reference to `_ioctlsocket@12'
build/release/game/game/g_http_client.os:g_http_client.c:(.text+0x677): undefined reference to `_ntohs@4'
build/release/game/game/g_http_client.os:g_http_client.c:(.text+0x688): undefined reference to `_inet_ntoa@4'
build/release/game/game/g_http_client.os:g_http_client.c:(.text+0x6a6): undefined reference to `_WSAGetLastError@0'
build/release/game/game/g_http_client.os:g_http_client.c:(.text+0x78c): undefined reference to `_gethostbyname@4'
build/release/game/game/g_http_client.os:g_http_client.c:(.text+0x7a6): undefined reference to `_inet_ntoa@4'
build/release/game/game/g_http_client.os:g_http_client.c:(.text+0x884): undefined reference to `_gethostbyname@4'
build/release/game/game/g_http_client.os:g_http_client.c:(.text+0x89b): undefined reference to `_WSAGetLastError@0'
build/release/game/game/g_http_client.os:g_http_client.c:(.text+0x8b6): undefined reference to `_WSAGetLastError@0'
build/release/game/game/g_http_client.os:g_http_client.c:(.text+0x991): undefined reference to `_gethostbyname@4'
build/release/game/game/g_http_client.os:g_http_client.c:(.text+0x9ab): undefined reference to `_inet_ntoa@4'
build/release/game/game/g_http_client.os:g_http_client.c:(.text+0xae1): undefined reference to `_gethostbyname@4'
build/release/game/game/g_http_client.os:g_http_client.c:(.text+0xb34): undefined reference to `_WSAGetLastError@0'
build/release/game/game/g_http_client.os:g_http_client.c:(.text+0xb4f): undefined reference to `_WSAGetLastError@0'
collect2: ld returned 1 exit status
scons: *** [build/release/game/libqagame.so] Error 1
scons: building terminated because of errors.

This is how the cross compiling ends after scons CC=i386-mingw32msvc-gcc CXX=i386-mingw32msvc-g++ BUILD=release

With scons CC=gcc CXX=g++ BUILD=release it works perfectly

http://linespeed.net/repos/etpub/trunk/src/ is the source code

Any1 know how to fix this?

Or is there perhaps an alternative to compile the code using wine and mingw?


(Elite) #2

Try this:
http://etkinvasion.com/etkmod/viewtopic.php?t=287

It’s an updated SConstruct file. Just replace it with the one in the src directory (overwrite the old one with this one) and we will go from there. Post down what, if any, errors you get afterwards and I’ll help you out some more.

Also, search for the -rdynamic flag, and remove it if it still gives you problems (in the SConstruct file).

However, when you use the updated version of SConstruct, as I mentioned above and provided a link for, this should take care of the rdynamic problem anyhow, becuase the linux compilation options are the only one’s it is using, and you allready said the linux compilation works fine (which, it should). Only remove the rdynamic flag as a last option, becuase you shouldn’t need to.

============

Note on thie side:
I would recommend using a version of ETPub as a base that is in the branches folder, the trunk is always going to be unstable, because that is where the main development is being done. If you can get everything to work right, great, but you are likely going to encounter bugs with the code at the very least (at runtime).


(Flames) #3

The whole output is just the same, accept the -rdynamic errors which are gone.

I get the same error if i compile branch 0.7.x, but it compiles fine in branch 0.6.x, because in there, the files g_http_client.c and g_http_client.h arent introduced yet. It looks like s/t in that code is making it impossible to cross compile


(Elite) #4

Ok, so now you have the new updated SConstruct file I provided in the link right?

For some reason the c++ compiler is being used, and that is what gives you all the errors.

Try this command for linux (example on cgame):

scons -c
scons CC=gcc CXX=g++ BUILD=release DEDICATED=0 TARGET_GAME=0 TARGET_CGAME=1 TARGET_UI=0 COPYBINS=1 

Try this command for windows cross compile (example on cgame, just change the -586 to w/e ur compiler is):

scons -c
scons CC=i586-mingw32msvc-gcc CXX=i586-mingw32msvc-g++ BUILD=release DEDICATED=0 TARGET_GAME=0 TARGET_CGAME=1 TARGET_UI=0 COPYBINS=1 

==============

Take a look at this post too, not sure if it helps you any, and these versions of the script I made may be dated, I’ll dig up a newer version if it interested you:
http://www.splashdamage.com/forums/viewtopic.php?t=15599&highlight=


(Flames) #5

although the file is being created, it ends up with some big error

Install file: "build-mingw/release/cgame/libcgame.so" as "cgame_mp_x86.dll"
copy_bins(["copybins"], ["cgame_mp_x86.dll"])
cp /home/harald/Documents/Enemy-Territory/etpub-source/trunk/src/cgame_mp_x86.dll /home/harald/Documents/Enemy-Territory/etpub-source/trunk/bin/cgame_mp_x86.dll
cp: cannot create regular file `/home/harald/Documents/Enemy-Territory/etpub-source/trunk/bin/cgame_mp_x86.dll': No such file or directory
/home/harald/Documents/Enemy-Territory/etpub-source/trunk/src/scons_utils.py:37: DeprecationWarning: raising a string exception is deprecated
  raise 'command failed'
scons: *** [copybins] Exception
Traceback (most recent call last):
  File "/usr/lib/python2.5/site-packages/SCons/Taskmaster.py", line 194, in execute
    self.targets[0].build()
  File "/usr/lib/python2.5/site-packages/SCons/Node/__init__.py", line 301, in build
    apply(executor, (self, exitstatfunc), kw)
  File "/usr/lib/python2.5/site-packages/SCons/Executor.py", line 129, in __call__
    self.do_execute(target, exitstatfunc, kw)
  File "/usr/lib/python2.5/site-packages/SCons/Executor.py", line 122, in do_execute
    kw)
  File "/usr/lib/python2.5/site-packages/SCons/Action.py", line 331, in __call__
    stat = self.execute(target, source, env)
  File "/usr/lib/python2.5/site-packages/SCons/Action.py", line 660, in execute
    result = self.execfunction(target=target, source=rsources, env=env)
  File "/home/harald/Documents/Enemy-Territory/etpub-source/trunk/src/SConstruct", line 358, in copy_bins
    self.SimpleCommand( 'cp ' + i.abspath + ' ' + j )
  File "/home/harald/Documents/Enemy-Territory/etpub-source/trunk/src/scons_utils.py", line 37, in SimpleCommand
    raise 'command failed'
command failed
scons: building terminated because of errors.

EDIT: this error doesnt occur if i remove COPYBINS=1


(Flames) #6

Thx for the help. I got what I wanted, and that is to be able to create the windows client files. Building the server file doesnt work, and i guess it wont work because of the source code itsself.

Btw is it possible to make the mac client files and bundle them?


(Discovery) #7

Do note that files compiled on windows with MS Visual C usually are smaller and faster than crosscompiled files.


(kamikazee) #8

I believe Bani once claimed that GNU’s -OS switch actually manages to do the opposite. Take a look at the ETPro binaries to be sure. (That is, when there isn’t a similar switch used when compiling in Windows, of course.)

I got not source right now, it should be on this board somewhere.


(Flames) #9

you got to strip your files ey

but euhm, the mac bundles…


(kamikazee) #10

Stripping only rendered VC binaries unusable in the cases I tested them. Must have to do with some switches then.


(Elite) #11

EDIT: this error doesnt occur if i remove COPYBINS=1

hehe, forgot to mention you need to create a folder, in the same directory as the “src” folder, and call it “bin”. Then, the files have a place to goto and there will be no error.

cp /home/harald/Documents/Enemy-Territory/etpub-source/trunk/src/cgame_mp_x86.dll /home/harald/Documents/Enemy-Territory/etpub-source/trunk/bin/cgame_mp_x86.dll
cp: cannot create regular file `/home/harald/Documents/Enemy-Territory/etpub-source/trunk/bin/cgame_mp_x86.dll': No such file or directory 

Just to further clarify, notice in the path it looks for the “bin” folder, just create it and you are set. No biggie, just your files aren’t stripped is all.


(Sauron|EFG) #12

Looks to me like you’re not linking with ws2_32.lib.


(Flames) #13

I tried copying libws2_32.a to /usr/lib, but it still didnt work, so i guess that aint it


(Elite) #14

Is that with just the trunk? I know for sure the 6.x.x and 7.x.x series will all work, not sure about the 8.x.x cause I haven’t tried it myself, and it’s been awhile since I looked at their repository, but that should be stable by now…


(Sauron|EFG) #15

Well, the error messages indicate that you’re not linking with the correct library, and I doubt that copying the file to /usr/lib is enough. (I’m not familiar with scons or the SConscript files though.)


(kamikazee) #16

/usr/lib is used when compiling/running regular Linux apps. I believe you need to place this library file in one of the MinGW folders.


(Flames) #17

Its also in there


(Elite) #18

remove, reinstall

Make sure u do flex, bison, binutils, gcc, and then after all that mingw. Will probably save you some headaches.

If you are missing some packages that I listed, try installing them see if it helps, if it dont then i seriosuyl suggest re-installing all those packages, in that order.


(Mr.Mxyzptlk) #19

oh for the luv of god, just link with libwsock32.a which should already be a part of any mingw install. and if you get more undefined symbols during linking and they’re system libraries, find out which win32 (mingw) libs you need to link against.