Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Not compiling under MinGW-64 (static link) #438

Open
ConsoleTVs opened this issue Nov 7, 2018 · 17 comments
Open

Not compiling under MinGW-64 (static link) #438

ConsoleTVs opened this issue Nov 7, 2018 · 17 comments
Milestone

Comments

@ConsoleTVs
Copy link

ConsoleTVs commented Nov 7, 2018

  • Errors: (Also why is it displaying C:/projects/libui/....... ? I do not have this path anywhere
    image

  • G++ Version and info:
    image

As an added info, the failing is:

uiInitOptions o;
uiWindow *w;

memset(&o, 0, sizeof (uiInitOptions));
if (uiInit(&o) != NULL) abort();

w = uiNewWindow("Hello", 320, 240, 0);
uiWindowSetMargined(w, 1);

// onClosing is in another static function
uiWindowOnClosing(w, onClosing, NULL);
uiMain();

uiMain();

EDIT: If I try to build the source myself as the docs say, CMAKE success in the genreation but when make command is invoked, it fails at the following:

image

@msink
Copy link
Contributor

msink commented Nov 7, 2018

Add to comnand line:

-luser32 -lkernel32 -lgdi32 -lcomctl32 -luxtheme -lmsimg32 -lcomdlg32 -ld2d1 -ldwrite -lole32 -loleaut32 -loleacc -luuid

@ConsoleTVs
Copy link
Author

When building it in cmake or when using the static library provided?

@msink
Copy link
Contributor

msink commented Nov 7, 2018

When using.

Also - C:/projects/libui is path on Appveyor CI

@msink
Copy link
Contributor

msink commented Nov 7, 2018

And likely you will need manifest, as in #436

@ConsoleTVs
Copy link
Author

image

It compiled and broke at runetime. The code did not display anything, is this because of the manifest?

@msink
Copy link
Contributor

msink commented Nov 7, 2018

Not sure, but most likely its manifest.

@ConsoleTVs
Copy link
Author

ConsoleTVs commented Nov 7, 2018

Nothing happens. Using manifest.

image

GIF Video:
https://i.gyazo.com/0ec25ee944bd5a4d8e2a2aca83e8d6cb.mp4

Code compiles, starts and breaks.

image

@msink
Copy link
Contributor

msink commented Nov 7, 2018

Strange.

What happens if you compile for example https://github.com/andlabs/libui/blob/master/examples/timer/main.c by that toolchain?

If it not working too - maybe it's some subtle difference between msys2-mingw64 and your mingw variant. Then you need to compile libui from sources.

@ConsoleTVs
Copy link
Author

Aparently I get the same result... https://i.gyazo.com/d4a0e50a57b02dfdf1d3251a74032ea4.mp4

I cannot compile the source since I see this error:

image

What can I do? I'm feeling super lost right now... I really need to get this amazing thing working!!!

g++ -v
Using built-in specs.
COLLECT_GCC=g++
COLLECT_LTO_WRAPPER=C:/msys64/mingw64/bin/../lib/gcc/x86_64-w64-mingw32/8.2.0/lto-wrapper.exe
Target: x86_64-w64-mingw32
Configured with: ../gcc-8.2.0/configure --prefix=/mingw64 --with-local-prefix=/mingw64/local --build=x86_64-w64-mingw32 --host=x86_64-w64-mingw32 --target=x86_64-w64-mingw32 --with-native-system-header-dir=/mingw64/x86_64-w64-mingw32/include --libexecdir=/mingw64/lib --enable-bootstrap --with-arch=x86-64 --with-tune=generic --enable-languages=ada,c,lto,c++,objc,obj-c++,fortran --enable-shared --enable-static --enable-libatomic --enable-threads=posix --enable-graphite --enable-fully-dynamic-string --enable-libstdcxx-filesystem-ts=yes --enable-libstdcxx-time=yes --disable-libstdcxx-pch --disable-libstdcxx-debug --disable-isl-version-check --enable-lto --enable-libgomp --disable-multilib --enable-checking=release --disable-rpath --disable-win32-registry --disable-nls --disable-werror --disable-symvers --with-libiconv --with-system-zlib --with-gmp=/mingw64 --with-mpfr=/mingw64 --with-mpc=/mingw64 --with-isl=/mingw64 --with-pkgversion='Rev3, Built by MSYS2 project' --with-bugurl=https://sourceforge.net/projects/msys2 --with-gnu-as --with-gnu-ld
Thread model: posix
gcc version 8.2.0 (Rev3, Built by MSYS2 project)

@msink
Copy link
Contributor

msink commented Nov 7, 2018

Can you switch to msys2-mingw compiler?
https://www.msys2.org

All testing was done by it, and it definitely works.

@ConsoleTVs
Copy link
Author

C:/msys64/mingw64/bin/......

it's msys2-mingw already.

@msink
Copy link
Contributor

msink commented Nov 7, 2018

Well - then I gave up, maybe someone else have more ideas.

On my computer it works without any issues.

@ConsoleTVs
Copy link
Author

Could you post your g++ -v output please? Also, any ideas on the error I get when I compile the source? Do you use 32 bitrs or 64 bits version of msys64?

@msink
Copy link
Contributor

msink commented Nov 8, 2018

32-bit:

@echo off
set PATH=c:\msys64\mingw32\bin;%PATH%
g++ -v
windres resources.rc -O coff -o resources32.res
g++ timer.c -static lib32/libui.a resources32.res -o timer32.exe ^
 -luser32 -lkernel32 -lgdi32 -lcomctl32 -luxtheme -lmsimg32 -lcomdlg32 ^
 -ld2d1 -ldwrite -lole32 -loleaut32 -loleacc -luuid
Using built-in specs.
COLLECT_GCC=g++
COLLECT_LTO_WRAPPER=c:/msys64/mingw32/bin/../lib/gcc/i686-w64-mingw32/7.3.0/lto-wrapper.exe
Target: i686-w64-mingw32
Configured with: ../gcc-7.3.0/configure --prefix=/mingw32 --with-local-prefix=/mingw32/local --build=i686-w64-mingw32 --host=i686-w64-mingw32 --target=i686-w64-mingw32 --with-native-system-header-dir=/mingw32/i686-w64-mingw32/include --libexecdir=/mingw32/lib --enable-bootstrap --with-arch=i686 --with-tune=generic --enable-languages=c,lto,c++,objc,obj-c++,fortran,ada --enable-shared --enable-static --enable-libatomic --enable-threads=posix --enable-graphite --enable-fully-dynamic-string --enable-libstdcxx-time=yes --enable-libstdcxx-filesystem-ts=yes --disable-libstdcxx-pch --disable-libstdcxx-debug --disable-isl-version-check --enable-lto --enable-libgomp --disable-multilib --enable-checking=release --disable-rpath --disable-win32-registry --disable-nls --disable-werror --disable-symvers --with-libiconv --with-system-zlib --with-gmp=/mingw32 --with-mpfr=/mingw32 --with-mpc=/mingw32 --with-isl=/mingw32 --with-pkgversion='Rev2, Built by MSYS2 project' --with-bugurl=https://sourceforge.net/projects/msys2 --with-gnu-as --with-gnu-ld --disable-sjlj-exceptions --with-dwarf2
Thread model: posix
gcc version 7.3.0 (Rev2, Built by MSYS2 project)

image

64-bit:

@echo off
set PATH=c:\msys64\mingw64\bin;%PATH%
g++ -v
windres resources.rc -O coff -o resources64.res
g++ timer.c -static lib64/libui.a resources64.res -o timer64.exe ^
 -luser32 -lkernel32 -lgdi32 -lcomctl32 -luxtheme -lmsimg32 -lcomdlg32 ^
 -ld2d1 -ldwrite -lole32 -loleaut32 -loleacc -luuid
Using built-in specs.
COLLECT_GCC=g++
COLLECT_LTO_WRAPPER=c:/msys64/mingw64/bin/../lib/gcc/x86_64-w64-mingw32/8.2.0/lto-wrapper.exe
Target: x86_64-w64-mingw32
Configured with: ../gcc-8.2.0/configure --prefix=/mingw64 --with-local-prefix=/mingw64/local --build=x86_64-w64-mingw32 --host=x86_64-w64-mingw32 --target=x86_64-w64-mingw32 --with-native-system-header-dir=/mingw64/x86_64-w64-mingw32/include --libexecdir=/mingw64/lib --enable-bootstrap --with-arch=x86-64 --with-tune=generic --enable-languages=ada,c,lto,c++,objc,obj-c++,fortran --enable-shared --enable-static --enable-libatomic --enable-threads=posix --enable-graphite --enable-fully-dynamic-string --enable-libstdcxx-filesystem-ts=yes --enable-libstdcxx-time=yes --disable-libstdcxx-pch --disable-libstdcxx-debug --disable-isl-version-check --enable-lto --enable-libgomp --disable-multilib --enable-checking=release --disable-rpath --disable-win32-registry --disable-nls --disable-werror --disable-symvers --with-libiconv --with-system-zlib --with-gmp=/mingw64 --with-mpfr=/mingw64 --with-mpc=/mingw64 --with-isl=/mingw64 --with-pkgversion='Rev3, Built by MSYS2 project' --with-bugurl=https://sourceforge.net/projects/msys2 --with-gnu-as --with-gnu-ld
Thread model: posix
gcc version 8.2.0 (Rev3, Built by MSYS2 project)

image

@msink
Copy link
Contributor

msink commented Nov 8, 2018

For clang++:

clang version 7.0.0 (tags/RELEASE_700/final)
Target: i686-w64-windows-gnu
Thread model: posix
InstalledDir: c:\msys64\mingw32\bin
clang++.exe: warning: treating 'c' input as 'c++' when in C++ mode, this behavior is deprecated [-Wdeprecated]

clang version 7.0.0 (tags/RELEASE_700/final)
Target: x86_64-w64-windows-gnu
Thread model: posix
InstalledDir: c:\msys64\mingw64\bin
clang++.exe: warning: treating 'c' input as 'c++' when in C++ mode, this behavior is deprecated [-Wdeprecated]

@franko
Copy link

franko commented Nov 8, 2018

In case it helps, I have a "recipe" to install the msys2 system with mingw64 and build libui.

For me it was important to always use the mingw-w64's packages instead on the msys2's one, only exception being vim, make and tar.

Install MSYS2

Install Msys2 from https://www.msys2.org/. You can choose either i686 or x86_64 but is better to choose x86_64.

For Msys2 $HOME corresponds to the Msys2's install directory plus /home/$WINDOWS_USER_NAME.

To continue one needs to update with:

pacman -Syu

Close the terminal without returning to the bash shell and repeat again the update.

A simple pacman cheatsheet is available from:

https://devhints.io/pacman

Install dev packages

pacman -S vim make tar
pacman -S mingw64/mingw-w64-x86_64-python2
pacman -S mingw64/mingw-w64-x86_64-gcc
pacman -S mingw64/mingw-w64-x86_64-meson
pacman -S mingw64/mingw-w64-x86_64-pkg-config
pacman -S mingw64/mingw-w64-x86_64-cmake
pacman -S mingw64/mingw-w64-x86_64-diffutils

Optional:

pacman -S mingw64/mingw-w64-x86_64-gdb

NB: the msys' make is installed instead of the mingw's make because this latter does not
provide the make executable but only mingw32-make.

Install Git

Install git from the git website, the windows installer. Modify $HOME/.bashrc to add the git directory in the PATH:

export PATH="$PATH:/c/logiciels/git/mingw64/bin"

Recipe to build libui

git clone https://github.com/andlabs/libui.git
cd libui

git checkout alpha4.1

mkdir build && cd build

Disable shared libraries because MSVC build is required.

cmake -G "Ninja" -DBUILD_SHARED_LIBS=OFF ..

ninja
ninja examples
ninja tester

@andlabs andlabs added this to the Alpha 5 milestone Dec 31, 2018
@andlabs
Copy link
Owner

andlabs commented Apr 8, 2019

Right, you should be using MinGW-w64 as an environment, not MSYS2. MSYS2 is closer to a Unix environment than a Windows environment anyway.

I'll need to add something to the docs about that. Keep open until then.

As for the error building libui itself, it's now fixed (#446).

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants