(I'm on Windows.)
I'm testing a DLL I have compiled (libsox) with a C program which looks this way:
#include <stdio.h>
#include "sox.h"
int main(void) {
char const * versionText = sox_version();
printf(versionText);
return 0;
}
The function that is defined in the DLL has the following prototype in sox.h
(something of this contains cdecl
):
LSX_RETURN_VALID_Z LSX_RETURN_PURE
char const *
LSX_API
sox_version(void);
Here's the problem: When I try to build the file with gcc -lsox -o test.exe test.c
I get the following error:
C:\DOKUME~1\ADMINI~1\LOKALE~1\Temp\ccSS2h2z.o:test.c:(.text+0xf): undefined reference to `sox_version'
collect2: ld returned 1 exit status
A word to -lsox
: I have the library file "libsox.dll.a" in MinGW's lib
folder. If I write -lsoxnonsense
, then it says there is no library. That means in the shown case it finds the library. So why doesn't it want to create a link.