Hard Light Productions Forums

Modding, Mission Design, and Coding => FS2 Open Coding - The Source Code Project (SCP) => Topic started by: PIe on March 12, 2017, 03:13:27 pm

Title: Trouble building wxLauncher
Post by: PIe on March 12, 2017, 03:13:27 pm
When I try to build wxLauncher in Eclipse, it compiles fine but linking fails with a bunch of undefined references.
I know Eclipse isn't officially supported, but I can't and don't want to use Visual Studio.
I installed wxWidgets 3.1.0 and built it with "mingw32-make -f makefile.gcc", and the WXWIN environment variable set to the root directory.  CMake is set to build a binary zip.
Here is what shows up during linking:  http://pastebin.com/aNu48JQd
Has anyone else had this problem on Windows and/or Eclipse, and how did you fix it?
Title: Re: Trouble building wxLauncher
Post by: niffiwan on March 12, 2017, 04:43:00 pm
I haven't used Eclipse on Windows, but I did have a heap of similar issue building with with MSVC/cmake/etc, I can't remember the precise details but I had to fiddle around with library settings in cmake before it started building & linking correctly.
Title: Re: Trouble building wxLauncher
Post by: PIe on March 12, 2017, 06:41:50 pm
Do you remember whether you had to go into advanced settings?  Whenever I change one of the non-advanced library paths, it pops up an error when I configure.
Title: Re: Trouble building wxLauncher
Post by: niffiwan on March 12, 2017, 11:31:16 pm
I think I did go into the advanced settings; but I don't recall if that was really necessary. Sorry! Not very helpful, I'll see if I can have a look at my saved cmake config & get back to you.
Title: Re: Trouble building wxLauncher
Post by: PIe on March 13, 2017, 10:32:30 pm
Any luck niffiwan?
Title: Re: Trouble building wxLauncher
Post by: Iss Mneur on March 14, 2017, 09:00:09 am
Without seeing your compile options, it looks like you either are building release but have selected a debug wxWidgets.

Based on this you also may not be linking the CRT (or are liking a mismatch debug/release version)
Code: [Select]
C:\wxWidgets-3.1.0\build\msw/../../src/msw/dlmsw.cpp:65: undefined reference to `GetFileVersionInfoSizeW'
C:\wxWidgets-3.1.0\build\msw/../../src/msw/dlmsw.cpp:69: undefined reference to `GetFileVersionInfoW'
C:\wxWidgets-3.1.0\build\msw/../../src/msw/dlmsw.cpp:73: undefined reference to `VerQueryValueW'

Having said that, I haven't tried building wxWidgets with anything other than VisualC on Windows so I have no idea what other incompatibilities you may run into.  In particular make sure that cmake has not detected you as being linux (IS_WIN32 vs IS_LINUX).  Please pastebin your CMakeCache.txt.
Title: Re: Trouble building wxLauncher
Post by: PIe on March 14, 2017, 12:16:05 pm
CMakeCache.txt at http://pastebin.com/sZiqFZ76.
I don't have either IS_WIN32 or IS_LINUX.
I've tried building with wxWidgets release and with wxWidgets_CONFIGURATION to mswu, but got the same results.
Title: Re: Trouble building wxLauncher
Post by: PIe on March 14, 2017, 05:27:32 pm
I made sure I was using wxWidgets release and mswu configuration.  Then I tried including C:\Program Files (x86)\Windows Kits\10\Include\10.0.14393.0\um from inside Eclipse and adding an environment variable, but it still failed.  Maybe this path needs to be set inside CMake, but I don't know where.
Title: Re: Trouble building wxLauncher
Post by: PIe on March 15, 2017, 01:59:58 pm
I found this thread https://forums.wxwidgets.org/viewtopic.php?t=42617#p172992 where the solution was to add libshlwapi.a and libversion.a (MinGW equivalents to Windows SDK files) to the linker input files.  I assume this means CMakeLists.txt, and I'm now trying to figure out how to do that.
Title: Re: Trouble building wxLauncher
Post by: Iss Mneur on March 15, 2017, 07:02:27 pm
I found this thread https://forums.wxwidgets.org/viewtopic.php?t=42617#p172992 where the solution was to add libshlwapi.a and libversion.a (MinGW equivalents to Windows SDK files) to the linker input files.  I assume this means CMakeLists.txt, and I'm now trying to figure out how to do that.
This line would be what you are looking for: https://github.com/scp-fs2open/wxLauncher/blob/master/CMakeLists.txt#L394
Title: Re: Trouble building wxLauncher
Post by: PIe on March 15, 2017, 10:54:18 pm
I added C:\Program Files\mingw-w64\x86_64-6.3.0-posix-seh-rt_v5-rev1\mingw64\x86_64-w64-mingw32\lib as an environment variable and edited CMakeLists.txt as follows:
Code: [Select]
find_library(SHLWAPI libshlwapi.a)
find_library(MINCORE libversion.a)

target_link_libraries(wxlauncher ${wxWidgets_LIBRARIES} ${SDL2_LIBRARIES} ${SHLWAPI} ${MINCORE})
This made two new variables in the CMake gui called SHLWAPI and MINCORE, which I manually set to C:\\Program\ Files\\mingw-w64\\x86_64-6.3.0-posix-seh-rt_v5-rev1\\mingw64\\x86_64-w64-mingw32\\lib\\libshlwapi.a and C:\\Program\ Files\\mingw-w64\\x86_64-6.3.0-posix-seh-rt_v5-rev1\\mingw64\\x86_64-w64-mingw32\\lib\\libversion.a respectively.
The Windows library errors are gone but I still have the reference problems with wxWidgets.
Title: Re: Trouble building wxLauncher
Post by: Iss Mneur on March 15, 2017, 11:28:06 pm
Reference problems?

Please paste an updated output
Title: Re: Trouble building wxLauncher
Post by: PIe on March 15, 2017, 11:30:44 pm
I had to link the libraries in the correct order, so I replaced
Code: [Select]
target_link_libraries(wxlauncher ${wxWidgets_LIBRARIES} ${SDL2_LIBRARIES} ${SHLWAPI} ${MINCORE})with
Code: [Select]
target_link_libraries(wxlauncher ${wxWidgets_LIBRARIES} ${MINCORE})
target_link_libraries(wxlauncher ${wxWidgets_LIBRARIES} ${SHLWAPI})
target_link_libraries(wxlauncher ${SDL2_LIBRARIES} ${MINCORE})
target_link_libraries(wxlauncher ${SDL2_LIBRARIES} ${SHLWAPI})
target_link_libraries(wxlauncher ${wxWidgets_LIBRARIES} ${SDL2_LIBRARIES})
It now builds properly, but doesn't run.
Title: Re: Trouble building wxLauncher
Post by: Iss Mneur on March 15, 2017, 11:36:51 pm
No exceptions? No log? Nothing on the console?  No Dr Watson?
Title: Re: Trouble building wxLauncher
Post by: PIe on March 15, 2017, 11:55:10 pm
Both double-clicking and running from command prompt produce the attached popup box, with no output on the console.  Also, DrWatson doesn't show up.
Edit:  I think I built a 64-bit wxL, which would conflict with my existing 32-bit installation.

[attachment stolen by Russian hackers]
Title: Re: Trouble building wxLauncher
Post by: PIe on March 16, 2017, 12:23:10 am
I built the Install target and it works, except for actually launching FSO.  I get an error about creating a registry key.  Also, I have to click through some errors and it looks a little weird, but everything except playing the game seems to work
Thanks so much Iss.  I really appreciate it.

[attachment stolen by Russian hackers]
Title: Re: Trouble building wxLauncher
Post by: m!m on March 16, 2017, 05:35:35 am
The second error is caused by a bug in wxWidgets and an invalid mod.ini file. If you update to wxWidgets 3.1 it should be fixed. The second issue would probably be fixed by using a nightly build of FSO. The previous versions depended on some weird registry hacking which probably doesn't work with MinGW.
Title: Re: Trouble building wxLauncher
Post by: PIe on March 16, 2017, 10:39:50 am
The second error is caused by a bug in wxWidgets and an invalid mod.ini file. If you update to wxWidgets 3.1 it should be fixed. The second issue would probably be fixed by using a nightly build of FSO. The previous versions depended on some weird registry hacking which probably doesn't work with MinGW.
I tried removing all my mods and I'm already using 3.1, but the error is still there.  Using a nightly did make it playable, thanks.