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

Directory picker support #22 #24

Merged
merged 1 commit into from
Aug 24, 2016
Merged

Conversation

MrSapps
Copy link
Contributor

@MrSapps MrSapps commented Aug 21, 2016

Tested on Windows 7 with MSVC, OSX and Ubuntu with gcc and clang

@MrSapps MrSapps changed the title Directory support #22 Directory picker support #22 Aug 21, 2016
@mlabbe
Copy link
Owner

mlabbe commented Aug 22, 2016

Great! I will have some time in the next couple days to look closely at this and #23.

@mlabbe mlabbe merged commit b35ff97 into mlabbe:devel Aug 24, 2016
@mlabbe
Copy link
Owner

mlabbe commented Aug 24, 2016

This change breaks Mingw builds on Windows because the added destructors generate link-time errors. Previously, NFD eschewed an RAII pattern, using gotos. This avoids a dependency on libc++ for the entire calling program and allows library users to compile with "gcc" instead of "g++".

In order to have the PR merged, exes need to link as C programs on all compilers. Please use the goto style instead of RAII. If you need steps to set up msys2's mingw on your computer to test, let me know.

Build error excerpt:

Linking test_opendialog
cc -o "../../build/bin/test_opendialog_d.exe" ../../build/obj/x64/Debug/test_opendialog/test_opendialog.o    -L/usr/lib64 -L../../build/lib/Debug/x64 -m64 -lnfd_d -lole32 -luuid
../../build/lib/Debug/x64/nfd_d.lib(nfd_win.o):nfd_win.cpp:(.data+0x0): undefined reference to `__gxx_personality_seh0'
../../build/lib/Debug/x64/nfd_d.lib(nfd_win.o):nfd_win.cpp:(.xdata+0xa0): undefined reference to `__gxx_personality_seh0'
../../build/lib/Debug/x64/nfd_d.lib(nfd_win.o):nfd_win.cpp:(.xdata$_ZN10AutoCoInitD1Ev+0xc): undefined reference to `__gxx_personality_seh0'
../../build/lib/Debug/x64/nfd_d.lib(nfd_win.o):nfd_win.cpp:(.xdata$_ZN6ComPtrI11IFileDialogED1Ev+0xc): undefined reference to `__gxx_personality_seh0'
../../build/lib/Debug/x64/nfd_d.lib(nfd_win.o):nfd_win.cpp:(.xdata$_ZN6ComPtrI10IShellItemED1Ev+0xc): undefined reference to `__gxx_personality_seh0'
collect2.exe: error: ld returned 1 exit status
make[1]: *** [test_opendialog.make:138: ../../build/bin/test_opendialog_d.exe] Error 1
make: *** [Makefile:53: test_opendialog] Error 2

Full msys2 mingw x64 buildbot output:

==== Building nfd (debug_x64) ====
Creating ../../build/lib/Debug/x64
mkdir -p ../../build/lib/Debug/x64
Creating ../../build/obj/x64/Debug/nfd
mkdir -p ../../build/obj/x64/Debug/nfd
nfd_common.c
cc   -MMD -MP -DDEBUG -I../../src/include -m64 -g  -o "../../build/obj/x64/Debug/nfd/nfd_common.o" -MF "../../build/obj/x64/Debug/nfd/nfd_common.d" -c "../../src/nfd_common.c"
nfd_win.cpp
g++    -MMD -MP -DDEBUG -I../../src/include -m64 -g  -o "../../build/obj/x64/Debug/nfd/nfd_win.o" -MF "../../build/obj/x64/Debug/nfd/nfd_win.d" -c "../../src/nfd_win.cpp"
Linking nfd
ar -rcs "../../build/lib/Debug/x64/nfd_d.lib" ../../build/obj/x64/Debug/nfd/nfd_common.o ../../build/obj/x64/Debug/nfd/nfd_win.o 
==== Building test_opendialog (debug_x64) ====
Creating ../../build/bin
mkdir -p ../../build/bin
Creating ../../build/obj/x64/Debug/test_opendialog
mkdir -p ../../build/obj/x64/Debug/test_opendialog
test_opendialog.c
cc   -MMD -MP -DDEBUG -I../../src/include -m64 -g  -o "../../build/obj/x64/Debug/test_opendialog/test_opendialog.o" -MF "../../build/obj/x64/Debug/test_opendialog/test_opendialog.d" -c "../../test/test_opendialog.c"
Linking test_opendialog
cc -o "../../build/bin/test_opendialog_d.exe" ../../build/obj/x64/Debug/test_opendialog/test_opendialog.o    -L/usr/lib64 -L../../build/lib/Debug/x64 -m64 -lnfd_d -lole32 -luuid
../../build/lib/Debug/x64/nfd_d.lib(nfd_win.o):nfd_win.cpp:(.data+0x0): undefined reference to `__gxx_personality_seh0'
../../build/lib/Debug/x64/nfd_d.lib(nfd_win.o):nfd_win.cpp:(.xdata+0xa0): undefined reference to `__gxx_personality_seh0'
../../build/lib/Debug/x64/nfd_d.lib(nfd_win.o):nfd_win.cpp:(.xdata$_ZN10AutoCoInitD1Ev+0xc): undefined reference to `__gxx_personality_seh0'
../../build/lib/Debug/x64/nfd_d.lib(nfd_win.o):nfd_win.cpp:(.xdata$_ZN6ComPtrI11IFileDialogED1Ev+0xc): undefined reference to `__gxx_personality_seh0'
../../build/lib/Debug/x64/nfd_d.lib(nfd_win.o):nfd_win.cpp:(.xdata$_ZN6ComPtrI10IShellItemED1Ev+0xc): undefined reference to `__gxx_personality_seh0'
collect2.exe: error: ld returned 1 exit status
make[1]: *** [test_opendialog.make:138: ../../build/bin/test_opendialog_d.exe] Error 1
make: *** [Makefile:53: test_opendialog] Error 2
program finished with exit code 2
elapsedTime=3.214000

@MrSapps
Copy link
Contributor Author

MrSapps commented Aug 24, 2016

Is it possible to build with -fno-exceptions flag? This seems to be caused because it wants to add SEH exception handling which is not required - and as you say the SEH handling code is in the runtime.

@mlabbe
Copy link
Owner

mlabbe commented Aug 25, 2016

Good call. I made the fix and committed the result to the devel branch. We now generate nfd.a with -fno-exceptions. The linking executable is free to use exceptions or not use exceptions.

I also regenerated all of the project files so that test_pickfolder is available. It is passing on all compilers, arches and build types. All these changes are currently sitting in devel. Thanks for the contribution!

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

Successfully merging this pull request may close these issues.

2 participants