use shared library with eclipse on windows

43 Views Asked by At

On Windows 10, using eclipse for c projects I have installed the MinGW compiler. I've been able to add a static library (*.h, *.c files). I can't for some reason get a shared library to work.

I notice that for my shared library I generate a *.o file and a *.dll file but I am not creating a *.so file.

Here are the steps I'm taking:

1) open eclipse in new workspace
2) create a new c project
    a) project name ->SharedLib
    b) project type -> shared Library -> empty project
    c) toolchain -> MinGW GCC
3) In SharedLib folder 
    a) create test.h (header file) and test.c (source file)

    test.h

    #ifndef TEST_H_
    #define TEST_H_
    void test_print(void);
    #endif /* TEST_H_ */

    test.c

    #include <stdio.h>
    void test_print(void){
    printf("we have lift off");
    }
4) build Sharedlib
    a) creates Binaries -> libSharedLib.dll
5) create new c project Exec
    a) empty project
    b) add source file main.c

    main.c

    #include <stdio.h>
    #include "test.h"
    int main(void){
        printf("we are on the launch pad");
        test_print();
    }
6) go into properties of Exec->Paths and Symbols->references
   a) choose SharedLib, apply and close

7) build all and then run

I have no error messages and no output. the only thing it says is:

<terminated>(exit value: -1,073,741,515)Exec.exe[C/C++ Application]
D:\workplace3\Exec\Debug\Exec.exe(9/14/23,3:05pm)

Could really use some help getting this to work.

The goal is to get this shared library automatically included in all my c projects

0

There are 0 best solutions below