**I SOLVED THIS ISSUE BY MYSELF**

The problem was the linkage of the library.
I copied the libmywrapper.so(i renamed it) file to /usr/lib and linked with -mywrapper
That's it :-)

**Original post:**

I'm writing a wrapper library that allows to call C++ functions out of C-code.
Unfortnuately it doesn't link...

wrapper.h:

```
#ifdef __cplusplus
extern "C"
{
#endif
    extern char* (keygen) ();
#ifdef __cplusplus
 }
#endif

```

wrapper.cpp:

```
#include "wrapper.h"
#include <someincludes>
char* keygen ()
{
    urandom u;

```

Makefile:

```
TARGET      := ./mywrapperlib.so
CXXFLAGS    := -fPIC -shared -g -Wall -std=c++0x -I../someincludes -I.
CXX         := g++
LIB         := -lsomelibs
EXT         := cpp
BUILDDIR    := build

override BUILDDIR := $(strip $(BUILDDIR))
SOURCES  := $(wildcard *.$(EXT))
OBJECTS  := $(patsubst %.$(EXT), $(BUILDDIR)/%.o, $(SOURCES))
DEPS     := $(patsubst %.$(EXT), $(BUILDDIR)/%.dep, $(SOURCES))

.PHONY: all
all: $(TARGET)

$(TARGET): $(OBJECTS) $(DEPS)
    $(CXX) $(CXXFLAGS) -o $(TARGET) $(OBJECTS) $(LIBS)

ifneq ($(MAKECMDGOALS), clean)
-include $(DEPS)
endif

$(OBJECTS): $(BUILDDIR)/%.o: %.$(EXT) $(BUILDDIR)/%.dep $(BUILDDIR)/.tag
    $(CXX) $(CXXFLAGS) -c $< -o $@

$(DEPS): $(BUILDDIR)/%.dep: %.$(EXT) $(BUILDDIR)/.tag
    mkdir -p $(dir $(@))
    $(CXX) $(CXXFLAGS) -MM $< -MT $@ -MT $(<:.$(EXT)=.o) -o $@

%.tag:
    mkdir -p $(dir $(@))
    touch $@

.PHONY: clean
clean:
    $(RM) -r $(BUILDDIR)

```

A test file that should use the library:
test.c:

```
#include <wrapper.h>
int main()
{
    char* test = keygen();
}

```

When i try to compile it with

```
gcc  -o test.a -g -Iinclude -Llib/mywrapperlib.so test.c

```

I get

```
/tmp/ccB9bEot.o: In function `main':
/some/paths/test.c:7: undefined reference to `keygen'

```

Im very unexperienced with mixing C & C++ code and writing libraries.
Now im stuck and hope that someone can help me with this problem.

EDIT:

I checked the lib with nm:

```
nm lib/cryptdbwrapperlib.so | grep keygen
0000000000006935 T keygen

```

So, i guess that the problem is the linkage...