We have file1.cpp:
Code: Select all
extern "C"
{
__declspec(dllexport)
int f() { return 1; }
__declspec(dllexport)
int g() { return 2; }
int k() { return 3; }
}
Code: Select all
extern "C"
{
__declspec(dllexport)
int l() { return 1; }
__declspec(dllexport)
int m() { return 2; }
int n() { return 3; }
}
Code: Select all
g++ -o file1.o -c file1.cpp -fPIC
g++ -o file2.o -c file2.cpp -fPIC
Code: Select all
g++ -o test1.dll file1.o file2.o -shared -fPIC
dumpbin /exports test1.dll
But merging files into larger object file does not work:
Code: Select all
ld -r -o file3.o file1.o file2.o
g++ -o test2.dll file3.o -shared -fPIC
dumpbin /exports test2.dll
MinGW 8.1.0, tested different builds with the same result.
Any ideas how to make it work properly without using the DEF file?