libgit2/libgit2 — Issue #543: mingw: issue linking libgit2.dll with THREADSAFE=ON
Author: luislavena
Created: 2012-01-26 20:43:07+00:00
State: open

GCC 4.5.2 and 4.6.2 (mingw.org) CMake 2.8.4 and configured with `-DTHREADSAFE=ON`

```
Linking C shared library libgit2.dll
Creating library file: libgit2.dll.aCMakeFiles/git2.dir/objects.a(blob.c.obj): In function `git_atomic_inc':
c:/Users/Luis/Projects/oss/libgit2/libgit2/src/thread-utils.h:52: undefined reference to `__sync_add_and_fetch_4'
CMakeFiles/git2.dir/objects.a(cache.c.obj): In function `git_atomic_inc':
c:/Users/Luis/Projects/oss/libgit2/libgit2/src/thread-utils.h:52: undefined reference to `__sync_add_and_fetch_4'
CMakeFiles/git2.dir/objects.a(cache.c.obj): In function `git_atomic_dec':
c:/Users/Luis/Projects/oss/libgit2/libgit2/src/thread-utils.h:63: undefined reference to `__sync_sub_and_fetch_4'
CMakeFiles/git2.dir/objects.a(object.c.obj): In function `git_atomic_dec':
c:/Users/Luis/Projects/oss/libgit2/libgit2/src/thread-utils.h:63: undefined reference to `__sync_sub_and_fetch_4'
CMakeFiles/git2.dir/objects.a(odb.c.obj): In function `git_atomic_dec':
c:/Users/Luis/Projects/oss/libgit2/libgit2/src/thread-utils.h:63: undefined reference to `__sync_sub_and_fetch_4'
collect2: ld returned 1 exit status
make[2]: *** [libgit2.dll] Error 1
```

It seems `__sync_sub_and_fetch_4` is not defined. However compiling without thread safety does work.

The only reference to it *on the internetz* is the usage of `-march=i686` when compiling on x86.