nim-lang / ui

Beginnings of what might become Nim's official UI library.
MIT License
240 stars 32 forks source link

Link problems on Windows #38

Open tabris17 opened 3 years ago

tabris17 commented 3 years ago

My environment: Windows 7 SP1 Nim Compiler Version 1.4.2 [Windows: i386] gcc version 8.1.0 (i686-posix-dwarf-rev0, Built by MinGW-W64 project)

Link error: ...\nimbledeps\pkgs\ui-0.9.4\res\resources.o: file not recognized: File format not recognized

So I delete line {.link: r"..\res\resources.o".} from ui/rawui.nim https://github.com/nim-lang/ui/blob/9b363b9065fe4e34db95a3a209d38445d8433ac1/ui/rawui.nim#L56

And get error:

C:\Users\...\nimcache\nimtest_d\win_alloc.cpp.obj:alloc.cpp:(.text+0x1c): undefined reference to `std::__cxx11::basic_ostringstream<char, std::char_traits<char>, std::allocator<char> >::basic_ostringstream(std::_Ios_Openmode)'
C:\Users\...\nimcache\nimtest_d\win_alloc.cpp.obj:alloc.cpp:(.text+0x2c): undefined reference to `std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> >::basic_string()'
C:\Users\...\nimcache\nimtest_d\win_alloc.cpp.obj:alloc.cpp:(.text+0xb6): undefined reference to `std::ostream::operator<<(void const*)'
C:\Users\...\nimcache\nimtest_d\win_alloc.cpp.obj:alloc.cpp:(.text+0xc9): undefined reference to `std::basic_ostream<char, std::char_traits<char> >& std::operator<< <std::char_traits<char> >(std::basic_ostream<char, std::char_traits<char> >&, char const*)'
C:\Users\...\nimcache\nimtest_d\win_alloc.cpp.obj:alloc.cpp:(.text+0xef): undefined reference to `std::basic_ostream<char, std::char_traits<char> >& std::operator<< <std::char_traits<char> >(std::basic_ostream<char, std::char_traits<char> >&, char const*)'
... ...

Then I add a line {.passL: r"-lstdc++".} into ui/rawui.nim, build successed.

But when I execute the .exe file,there has an error messagebox: Unable to find an entry point named 'TaskDialog' in DLL 'Comctl32.dll'.

veksha commented 3 years ago

it seems that resources.o is a 64-bit object file, so the check must be added to rawui.nim :

when defined(cpu64):
      {.link: r"..\res\resources.o".}

BUT, if the purpose of this file is to make modern look of windows controls then it's not working for me. but this method works -> https://github.com/nim-lang/ui/issues/17#issuecomment-850753272

devs, please, implement the same method for your project so all will work like a charm.

kwilson21 commented 2 years ago

This fix did not work for me on Windows 11 for a 32 bit project. I was not able to compile at all using gcc and had to switch to vcc to get it working, I simply had to add {.link: r"C:\Program Files (x86)\Windows Kits\10\Lib\10.0.19041.0\um\x86\windowscodecs.lib".} to the top of my file and compile using vcc for everything to compile on windows. It also renders the newer windows elements as opposed to the old windows xp style some were reporting.