Gnurou / tagainijisho

A free Japanese dictionary and learning assistant
http://www.tagaini.net
GNU General Public License v3.0
363 stars 51 forks source link

Compiling with MinGW-w64 under Windows fails #71

Closed tuldok89 closed 11 years ago

tuldok89 commented 11 years ago

Ok, so I like doing things the hard way. I've tried compiling Tagaini Jisho on Windows, and it didn't finish. I guess the following issues are the last stumbling block for this app to compile smoothly under windows. Both of these issues are present in the 0.9.4 release, and in origin/master

tagainijisho\src\gui\cmakelists.txt:130

add_custom_command(OUTPUT ${CMAKE_CURRENT_BINARY_DIR}/tagainijisho_rc.obj COMMAND i486-mingw32-windres -I${CMAKE_SOURCE_DIR}/src/gui -i${CMAKE_SOURCE_DIR}/src/gui/tagainijisho.rc -o ${CMAKE_CURRENT_BINARY_DIR}/tagainijisho_rc.obj)
Linking CXX executable tagainijisho.exe
..\sqlite\libtagaini_sqlite.a(Query.cc.obj):Query.cc:(.text+0x12fd): undefined reference to `_imp___ZN7QString9fromUtf16EPKti'
..\sqlite\libtagaini_sqlite.a(Query.cc.obj):Query.cc:(.text+0x1356): undefined reference to `_imp___ZN10QByteArrayC1EPKci'
c:/mingw32/bin/../lib/gcc/i686-w64-mingw32/4.7.2/../../../../i686-w64-mingw32/bin/ld.exe: ..\sqlite\libtagaini_sqlite.a(Query.cc.obj): bad reloc address 0x0 in section `.rdata'
c:/mingw32/bin/../lib/gcc/i686-w64-mingw32/4.7.2/../../../../i686-w64-mingw32/bin/ld.exe: final link failed: Invalid operation
collect2.exe: error: ld returned 1 exit status
src\gui\CMakeFiles\tagainijisho.dir\build.make:212: recipe for target 'src/gui/tagainijisho.exe' failed
mingw32-make[2]: *** [src/gui/tagainijisho.exe] Error 1
CMakeFiles\Makefile2:597: recipe for target 'src/gui/CMakeFiles/tagainijisho.dir/all' failed
mingw32-make[1]: *** [src/gui/CMakeFiles/tagainijisho.dir/all] Error 2
makefile:135: recipe for target 'all' failed
mingw32-make: *** [all] Error 2

I think this has something to do with the order at which the libraries are fed to the linker. If the Qt libs could just be put after libtagaini_sqlite.a to silence the linker.

src\gui\CMakeFiles\tagainijisho.dir\link.txt

C:\Mingw32\bin\g++.exe   -Wall -Wextra -Wnon-virtual-dtor -Wno-unused-parameter -fno-exceptions -fno-rtti -O3 -DNDEBUG    -mwindows -Wl,--whole-archive CMakeFiles\tagainijisho.dir/objects.a -Wl,--no-whole-archive  -o tagainijisho.exe -Wl,--out-implib,libtagainijisho.dll.a -Wl,--major-image-version,0,--minor-image-version,0  jmdict\libtagaini_gui_jmdict.a kanjidic2\libtagaini_gui_kanjidic2.a libtagaini_gui.a ..\core\jmdict\libtagaini_core_jmdict.a ..\core\kanjidic2\libtagaini_core_kanjidic2.a ..\core\libtagaini_core.a C:\Qt\4.8.4_mingw32\lib\libQtGui4.a C:\Qt\4.8.4_mingw32\lib\libQtNetwork4.a C:\Qt\4.8.4_mingw32\lib\libQtCore4.a -static-libgcc -static-libstdc++ -mwindows ..\core\jmdict\libtagaini_core_jmdict.a ..\core\kanjidic2\libtagaini_core_kanjidic2.a ..\sqlite\libtagaini_sqlite.a -lsqlite3 -lpthread -ldl -lkernel32 -luser32 -lgdi32 -lwinspool -lshell32 -lole32 -loleaut32 -luuid -lcomdlg32 -ladvapi32

Btw, I'm using gcc-4.7.2 and Qt 4.8.4

Gnurou commented 11 years ago

Maybe you need to edit src/gui/CMakeLists.txt, line 139, "target_link_libraries". If I add "tagaini_sqlite" right before ${QT_LIBRARIES} then the Qt libs are mentioned after libtagaini_sqlite.a as you want. Maybe this would fix the issue?

Strangely tagaini_core_jmdict/kandidic2 are both mentioned but appear after the Qt libraries, so I hope this won't turn into a problem as well.

As for the windres binary, if you change the mention to i486-mingw32-windres to ${CMAKE_RC_COMPILER}, then I think it should resolve to the correct binary on your system.

Please let me know if this improves things on your side, so I can commit the fixes. Thanks for trying this, a "real" Windows build could be a good thing to have!

firatakandere commented 11 years ago

Both two fixture suggestions worked on me. But there's another issue, when i try to install via both nullsoft and "make install", they only install the "tagainijisho.exe" file.

tuldok89 commented 11 years ago

I could confirm what both of the suggested fixes work

Gnurou commented 11 years ago

Both fixes pushed. By the way, why did you guys try to compile Tagaini under Windows? Shall I expect some patches in the near future? :P

On Thu, Feb 7, 2013 at 12:56 AM, tuldok89 notifications@github.com wrote:

I could confirm what both of the suggested fixes work

— Reply to this email directly or view it on GitHubhttps://github.com/Gnurou/tagainijisho/issues/71#issuecomment-13188612.

tuldok89 commented 11 years ago

I guess it's because we're fans of Qt and open source :3

Anyway, let's just see if I'm good enough to code hehe

firatakandere commented 11 years ago

Just like tuldok said :+1: Also, I'm a Japanese learner, software engineering student and have been using Tagaini Jisho for a while :P I am not as good as tuldok at programming but I'll do my best :P Just created a ~35mb installer on windows and it really works perfectly :+1:

Gnurou commented 11 years ago

Ohhh, that sounds like music to my hears. Tagaini badly needs new coders and if I could also get someone to take care of the Windows packaging (and come with something better than NSIS) that'd greatly ease the release process.

If you want to program on Tagaini you might be interested that I plan to launch the development of 2.0 which will be a "from scratch" rewrite to overcome the shortcomings of 1.0 (basically: code too complex ; not portable beyond Qt ; not enough community-based). I should announce this shortly along with a first draft for the DB layout and general directions for the project.

If you guys want to become active developers on Tagaini, this might be the right time. I will gladly provide all the code reviews you need.

firatakandere commented 11 years ago

I'm still a yet learner of qt but I'd like to help if there's anything I can do. I can help about Windows packaging. I suggest Inno Setup instead of NSIS.

Gnurou commented 11 years ago

If you can come with something using Inno Setup that looks better than NSIS I'd be glad to merge your patches!

Gnurou commented 11 years ago

Damn, every single Windows binary I try to cross-compile ends up being defective and crashes... Guys, if you are still around, would you mind trying to build and run a Windows binary from the latest source tree? This is the last item that prevents me from releasing 1.0.0.

firatakandere commented 11 years ago

I'll try to compile and return results here asap.

firatakandere commented 11 years ago

Compilation done successfully. Here are both binary files and installer: http://198.71.80.208/tagainijisho/

mingwm10.dll is not a dependency in the MinGW version I use. Instead, it has libstdc++-6.dll and libwinpthread-1.dll. So the installer will also add these dynamic link library files. I also added a condition in nsis installer to delete mingwm10.dll file if it exists. I tried installing&uninstalling in both pure installation and update.

Gnurou commented 11 years ago

Thanks a lot! Your binary seems to work perfectly. I will use it for the release if you don't mind. My cross-compiler seems to produce invalid binaries, how weird...

firatakandere commented 11 years ago

Sure you can use them, that's why i compiled it.