How to override CMAKE_FIND_ROOT_PATH
by Richard Shaw
I have a CMake project where I'm building wxWidgets on the fly. The
libraries are in a subdirectory of the build directory.
Unfortunately the CMAKE_FIND_ROOT_PATH gets prepended to the library name
even though it's being provided as an absolute directory rather than a
relative one.
From running cmake --debug-find:
find_library considered the following locations:
/usr/x86_64-w64-mingw32/sys-root/mingw/home/build/build/freedv/external/dist/lib/(lib|)wxregexu-3.1-x86_64-w64-mingw32(\.dll|\.dll\.a|\.a|\.lib)
Obviously this is wrong. It should be using the
path, /home/build/build/freedv/external/dist/lib, directly without
prepending anything.
Help!
Thanks,
Richard
3 years, 8 months
Re: mingw GCC help needed: -fstack-protector and -lssp, undefined
reference to `__strcpy_chk'
by Yaakov Selkowitz
On Thu, 2020-07-09 at 00:07 +0200, Sandro Mani wrote:
> I'm working on updating the mingw toolchain [1], and am hitting the
> situation [2] where I build with -fstack-protector in the ldflags, can
> confirm that -lssp and -lssp_nonshared are automatically added to the
> ldflags (seen via gcc -v [3] and strace), but I still get i.e. with this
> minimal testcase:
>
> #include <dirent.h>
> int main () {
> return closedir (NULL);
> }
>
> $ i686-w64-mingw32-gcc -o test.exe test.c -fstack-protector
> /usr/lib/gcc/i686-w64-mingw32/10.1.1/../../../../i686-w64-mingw32/bin/ld:
> /usr/i686-w64-mingw32/sys-root/mingw/lib/../lib/libmingwex.a(lib32_libmingwex_a-dirent.o):(.text+0x22f):
> undefined reference to `__strcpy_chk'
> collect2: error: ld returned 1 exit status
Perhaps mingw-crt should be built with -fno-stack-protector?
> OTOH, if I write
>
> $ i686-w64-mingw32-gcc -o test.exe test.c -fstack-protector
> /usr/i686-w64-mingw32/sys-root/mingw/bin/libssp-0.dll
>
> it links correctly.
>
> The only other thing which came to mind to verify is that the import
> library references the correct dll, and this appears to be the case:
>
> $ i686-w64-mingw32-dlltool -I
> /usr/i686-w64-mingw32/sys-root/mingw/lib/libssp.dll.a
> libssp-0.dll
>
> I'd appreciate any pointers as I'm pretty much in the dark here.
>
> [1] https://copr.fedorainfracloud.org/coprs/smani/mingw-7.0.0/builds/
>
> [2] Specifically when building mingw-gdb, which adds
> -D_FORTIFY_SOURCES=2 internally, hence adding -fstack-protector to the
> ldflags
>
> [3] I.e. I gtt COLLECT_GCC_OPTIONS='-v' '-o' 'test.exe'
> '-fstack-protector' '-mtune=generic' '-march=pentiumpro'
> /usr/libexec/gcc/i686-w64-mingw32/10.1.1/collect2 -plugin
> /usr/libexec/gcc/i686-w64-mingw32/10.1.1/liblto_plugin.so
> -plugin-opt=/usr/libexec/gcc/i686-w64-mingw32/10.1.1/lto-wrapper
> -plugin-opt=-fresolution=/tmp/cckKHr8u.res
> -plugin-opt=-pass-through=-lmingw32 -plugin-opt=-pass-through=-lgcc
> -plugin-opt=-pass-through=-lgcc_eh -plugin-opt=-pass-through=-lmoldname
> -plugin-opt=-pass-through=-lmingwex -plugin-opt=-pass-through=-lmsvcrt
> -plugin-opt=-pass-through=-lpthread -plugin-opt=-pass-through=-ladvapi32
> -plugin-opt=-pass-through=-lshell32 -plugin-opt=-pass-through=-luser32
> -plugin-opt=-pass-through=-lkernel32 -plugin-opt=-pass-through=-lmingw32
> -plugin-opt=-pass-through=-lgcc -plugin-opt=-pass-through=-lgcc_eh
> -plugin-opt=-pass-through=-lmoldname -plugin-opt=-pass-through=-lmingwex
> -plugin-opt=-pass-through=-lmsvcrt
> --sysroot=/usr/i686-w64-mingw32/sys-root -m i386pe -Bdynamic -o test.exe
> /usr/i686-w64-mingw32/sys-root/mingw/lib/../lib/crt2.o
> /usr/lib/gcc/i686-w64-mingw32/10.1.1/crtbegin.o
> -L/usr/lib/gcc/i686-w64-mingw32/10.1.1
> -L/usr/lib/gcc/i686-w64-mingw32/10.1.1/../../../../i686-w64-mingw32/lib/../lib
> -L/usr/i686-w64-mingw32/sys-root/mingw/lib/../lib
> -L/usr/lib/gcc/i686-w64-mingw32/10.1.1/../../../../i686-w64-mingw32/lib
> -L/usr/i686-w64-mingw32/sys-root/mingw/lib /tmp/ccpeowDx.o
> /usr/i686-w64-mingw32/sys-root/mingw/bin/libssp-0.dll -lssp_nonshared
> -lssp -lmingw32 -lgcc -lgcc_eh -lmoldname -lmingwex -lmsvcrt -lpthread
> -ladvapi32 -lshell32 -luser32 -lkernel32 -lmingw32 -lgcc -lgcc_eh
> -lmoldname -lmingwex -lmsvcrt /usr/lib/gcc/i686-w64-mingw32/10.1.1/crtend.o
--
Yaakov Selkowitz
Senior Software Engineer - Platform Enablement
Red Hat, Inc.
3 years, 8 months