Skip to content

Linking with libpe-sieve.a fails (MinGW) #71

@hillu

Description

@hillu

Hi,

when trying to build this simple no-op program t.c

#include "pe_sieve_api.h"
int main() {
  PEsieve_params pp = {0};
  PESieve_scan(pp);
}

…using this following Makefile…

CC=x86_64-w64-mingw32-g++
CFLAGS=-I_pe-sieve/include
LDFLAGS=-L_pe-sieve -lpe-sieve
_t/t: _t/t.c
	$(CC) $(CFLAGS) -o $@ $< $(LDFLAGS)

…I get the following error:

x86_64-w64-mingw32-g++ -I_pe-sieve/include -o _t/t _t/t.c -L_pe-sieve -lpe-sieve
/usr/bin/x86_64-w64-mingw32-ld: /tmp/ccGImspX.o:t.c:(.text+0x76): undefined reference to `__imp_PESieve_scan'
collect2: error: ld returned 1 exit status
make: *** [Makefile:6: _t/t] Error 1

Seems to me like PESieve_scan is not a visible symbol.

Adding a __declspec(dllexport) to PESIEVE_API_FUNC seems to fix the linker error, but I am not at all sure if this is the right way.

(After that the linker complained about missing symbols from -llibpeconv and ultimately about missing symbols that could be resolved using -lpsapi -lntdll -lshlwapi, but the main issue was the non-visible PESieve_scan symbol.)

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions