compiling for windows
fdch opened this issue · 25 comments
Hi Dan,
I am trying to compile for Windows.
I managed to get all 3 libs (SDL2, tinyxml2, and liblo) but I am now stuck on undefined references. I attach the config and console log.
Best,
f
It can't link liblo. How are you installing the dependencies? Manually building them or installing precompiled libs to the system? I would highly recommend using the Msys2 packages, if they exist for any of the required libs.
Also, you might need to provide the linker with the specific lib file to link to as well as the -L location.
I did compile them but maybe I'm adding the wrong flags on the configure command.
I think my point is to avoid having to build as many things manually as possible and also to avoid having to manually feed compiler flags to configure/make. If the libs are built and installed to standard locations, configure will find them for you and set the build flags.
Yes, that's reasonable. So, i successfully installed these:
pacman -S mingw-w64-x86_64-SDL2
pacman -S mingw-w64-x86_64-tinyxml2
And the problem with liblo is that I have to make -i
since it fails with this error:
test_bidirectional_tcp.c: In function 'main':
test_bidirectional_tcp.c:79:26: error: implicit declaration of function '_beginthreadex'; did you mean 'sendthread'? [-Werror=implicit-function-declaration]
HANDLE thr = (HANDLE)_beginthreadex(NULL, 0, &sendthread, s, 0, NULL);
^~~~~~~~~~~~~~
sendthread
test_bidirectional_tcp.c:79:18: error: cast to pointer from integer of different size [-Werror=int-to-pointer-cast]
HANDLE thr = (HANDLE)_beginthreadex(NULL, 0, &sendthread, s, 0, NULL);
^
cc1.exe: all warnings being treated as errors
which I think it's just a "test" file, and after ignoring it it seems to compile correctly, but I will let you know again as soon as I try make joyosc again
I recall that liblo has a configure flag to disable building the tests. Looking at another project where I build liblo manually to link to it for a macOS app, I see that I'm using:
./configure --disable-debug --disable-dependency-tracking --disable-tests --disable-network-tests --disable-tools --disable-examples
EDIT: That bidirectional test probably isn't compatible with Windows.
oh, that might be useful! I'll try that asap
Once you have a list of steps for building on Windows, we can add them to the joyosc readme. I never tried it, but I did try to make it possible at least and autotools can help.
One thing to note is that compiled .exes may not be portable unless the linked .dlls are also included. I'm not 100% certain about that and Christof might be good to ask.
Ok, I am now compiling joyosc. I only had to make install
liblo so that your build system could find it. I then did
./autogen.sh
./configure
And no problems. After make
, however, I got a few warnings and this error:
make[3]: Entering directory '/z/Desktop/joyosc/src/joyosc'
g++ -DHAVE_CONFIG_H -I. -I../../src -Dmain=SDL_main -IC:/Users/camarahalac.1/Desktop/msys2/mingw64/include/SDL2 -IC:/Users/camarahalac.1/Desktop/msys2/mingw64/include -I../../lib/lopack/src -IC:/Users/camarahalac.1/Desktop/msys2/mingw64/include -I../../lib/tinyobject/src -I../../lib/cpphelpers -g -O2 -MT main.o -MD -MP -MF .deps/main.Tpo -c -o main.o main.cpp
mv -f .deps/main.Tpo .deps/main.Po
g++ -DHAVE_CONFIG_H -I. -I../../src -Dmain=SDL_main -IC:/Users/camarahalac.1/Desktop/msys2/mingw64/include/SDL2 -IC:/Users/camarahalac.1/Desktop/msys2/mingw64/include -I../../lib/lopack/src -IC:/Users/camarahalac.1/Desktop/msys2/mingw64/include -I../../lib/tinyobject/src -I../../lib/cpphelpers -g -O2 -MT App.o -MD -MP -MF .deps/App.Tpo -c -o App.o App.cpp
App.cpp: In member function 'void App::run()':
App.cpp:64:9: error: 'SIGQUIT' was not declared in this scope
signal(SIGQUIT, signalExit); // quit
^~~~~~~
App.cpp:64:9: note: suggested alternative: 'SDL_QUIT'
signal(SIGQUIT, signalExit); // quit
^~~~~~~
SDL_QUIT
make[3]: *** [Makefile:499: App.o] Error 1
make[3]: Leaving directory '/z/Desktop/joyosc/src/joyosc'
make[2]: *** [Makefile:384: all-recursive] Error 1
make[2]: Leaving directory '/z/Desktop/joyosc/src'
make[1]: *** [Makefile:323: all] Error 2
make[1]: Leaving directory '/z/Desktop/joyosc/src'
make: *** [Makefile:460: all-recursive] Error 1
According to this, we can avoid using it on Windows.
Change line 64 in src/joyosc/App.cpp:
// set signal handling
signal(SIGTERM, signalExit); // terminate
#ifdef SIGQUIT
signal(SIGQUIT, signalExit); // quit
#endif
signal(SIGINT, signalExit); // interrupt
That solved it. However, now I have:
In file included from Config.cpp:26:
../../lib/cpphelpers/Path.h: In static member function 'static std::__cxx11::string Path::currentDir()':
../../lib/cpphelpers/Path.h:43:5: error: 'replace' was not declared in this scope
replace(path.begin(), path.end(), "/", "\\"); // fix any unixy paths...
^~~~~~~
../../lib/cpphelpers/Path.h:43:5: note: suggested alternative: 'rename'
replace(path.begin(), path.end(), "/", "\\"); // fix any unixy paths...
^~~~~~~
rename
make[3]: *** [Makefile:499: Config.o] Error 1
Comment that line out for now. I will look for a fix for it in the meantime.
Actually, just add "std::" before "replace(" ie.
std::replace(path.begin(), path.end(), "/", "\\"); // fix any unixy paths...
commenting the line out made a successful compile, btw! and I got joyosc running ;) I will add what you wrote now.
Err no, I meant:
path.replace(path.begin(), path.end(), "/", "\\"); // fix any unixy paths...
yeap, path.replace(
... did the trick
And it's got my PS4 controller data coming in! Congrats!!!! This is amazing, many thanks for helping me through this.
Here are the steps (mind the minor edits to App.cpp and Path.h)
Using a MSYS2 terminal with MINGw64
Install the following dependencies:
pacman -S mingw-w64-x86_64-SDL2
pacman -S mingw-w64-x86_64-tinyxml2
liblo
does not have a msys2 package, so you need to download the source from http://liblo.sourceforge.net and then:
cd liblo-0.30
./autogen.sh
./configure --disable-debug --disable-dependency-tracking --disable-tests --disable-network-tests --disable-tools --disable-examples
make
make install
Finally, you can compile joyosc
with:
cd joyosc
./autogen.sh
./configure
make
make install
Thanks. I added them to the readme. I pushed all the relevant changes for Windows so far. Test out joyosc and let me know if it's working. If so, I will push out a 0.4.5 bug fix release.
Also, most autotools source file zips or tarballs you download will have a pre-generated configure script, so you don't need to manually run the bootstrap script, ie. autogen.sh. It shouldn't be necessary for liblo, for instance, unless you clone a project from a git repo where it shouldn't have the configure script and/or the generated script s very old and you want to make an update.
Thanks! Good to know.
And thanks for the mention on the readme :)
So, the final question is how to make this portable. I assume joyosc
only runs on a MSYS2 terminal, and so if I want to share the binary with my students, they need to download and install that, as well as have joyosc.exe
. Do the other linked libs need to be distributed as well, I guess in the same directory as joyosc.exe
?
forgot to mention, I had joyosc
working with a PS4 controller and your pd
example. It seemed to get every button but I will have a deeper look once I get it working on another computer
forgot to mention, I had joyosc working with a PS4 controller and your pd example. It seemed to get every button but I will have a deeper look once I get it working on another computer
Play around with it a bit and let your students try it. They are always good at finding problems.
I will close this as compiling now works.