chicken-users
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Compile error with C library on Windows (Manual > Getting started > Acce


From: Josh Helzer
Subject: Compile error with C library on Windows (Manual > Getting started > Accessing C libraries)
Date: Wed, 27 Jan 2021 19:33:18 +0000

Greetings!

First-time CHICKEN user here!  :D

In working through the "Getting started" chapter of the manual, I've hit a snag 
in "Accessing C libraries" 
(https://wiki.call-cc.org/man/5/Getting%20started#accessing-c-libraries-), 
namely that gcc (via csc) complains about multiple definitions of both 
"C_toplevel" and "main" when run on Windows.


Steps:
------

1. With the content of the fib.c and fib-user.scm files as given in example,

>  gcc -c fib.c

runs without error, producing the output file fib.o.

2. Now for csc,

>  csc -o fib-user fib.o fib-user.scm

produces the following error output:

>  
> C:/tools/msys64/mingw64/bin/../lib/gcc/x86_64-w64-mingw32/10.2.0/../../../../x86_64-w64-mingw32/bin/ld.exe:
>  fib-user.obj:fib-user.c:(.text+0x2e): multiple definition of `C_toplevel'; 
> fib.obj:fib.c:(.text+0x0): first defined here
>  
> C:/tools/msys64/mingw64/bin/../lib/gcc/x86_64-w64-mingw32/10.2.0/../../../../x86_64-w64-mingw32/bin/ld.exe:
>  fib-user.obj:fib-user.c:(.text.startup+0x0): multiple definition of `main'; 
> fib.obj:fib.c:(.text.startup+0x0): first defined here
>  
> C:/tools/msys64/mingw64/bin/../lib/gcc/x86_64-w64-mingw32/10.2.0/../../../../x86_64-w64-mingw32/bin/ld.exe:
>  fib-user.obj:fib-user.c:(.text+0xba6): undefined reference to `fib'
>  collect2.exe: error: ld returned 1 exit status
>
>  Error: shell command terminated with non-zero exit status 1: ""gcc" 
> "fib.obj" "fib-user.obj" -o "fib-user" -Wl,--enable-auto-import 
> -LC:/tools/chicken/lib -lchicken -lm -lws2_32"

and the invocation also has the curious side effect of deleting fib.c!  :/


Versions:
---------

Windows:

>  OS Name:                   Microsoft Windows 10 Pro
>  OS Version:                10.0.19042 N/A Build 19042

CHICKEN:

>  Version 5.2.0 (rev 317468e4)
>  mingw32-windows-gnu-x86-64 [ 64bit dload ptables ]

GCC:

>  Using built-in specs.
>  COLLECT_GCC=gcc
>  
> COLLECT_LTO_WRAPPER=C:/tools/msys64/mingw64/bin/../lib/gcc/x86_64-w64-mingw32/10.2.0/lto-wrapper.exe
>  Target: x86_64-w64-mingw32
>  Configured with: ../gcc-10.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=c,lto,c++,fortran,ada,objc,obj-c++,jit 
> --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 --disable-plugin --with-libiconv --with-system-zlib 
> --with-gmp=/mingw64 --with-mpfr=/mingw64 --with-mpc=/mingw64 
> --with-isl=/mingw64 --with-pkgversion='Rev6, Built by MSYS2 project' 
> --with-bugurl=https://github.com/msys2/MINGW-packages/issues --with-gnu-as 
> --with-gnu-ld --with-boot-ldflags='-pipe 
> -Wl,--dynamicbase,--high-entropy-va,--nxcompat,--default-image-base-high 
> -Wl,--disable-dynamicbase -static-libstdc++ -static-libgcc' 
> 'LDFLAGS_FOR_TARGET=-pipe 
> -Wl,--dynamicbase,--high-entropy-va,--nxcompat,--default-image-base-high' 
> --enable-linker-plugin-flags='LDFLAGS=-static-libstdc++\ -static-libgcc\ 
> -pipe\ 
> -Wl,--dynamicbase,--high-entropy-va,--nxcompat,--default-image-base-high\ 
> -Wl,--stack,12582912'
>  Thread model: posix
>  Supported LTO compression algorithms: zlib zstd
>  gcc version 10.2.0 (Rev6, Built by MSYS2 project)


Notes:
------

I can successfully reproduce this example on Linux, as well as all of the 
earlier examples on Windows, so I hope it's not some obvious user error... :P

I installed CHICKEN (and GCC et al. as auto-installed dependencies) via 
Chocolatey (https://chocolatey.org/packages/chicken/).  Prior to that, the 
system was essentially a clean Windows installation (with respect to 
Mingw/Cygwin/WSL etc.).





reply via email to

[Prev in Thread] Current Thread [Next in Thread]