I believe something very odd is happening with my compiler options. When I compile class.c it compiles without error. However, when I try to create the .dll I get many errors:
undefined reference to '_method'
_method is any number of methods in class.c
I compile my code with the following:
gcc -c -g -w -I/path to include dir/include -MMD -MP -MF .../class.o.d -o class.o class.c
My link syntax is as follows:
gcc -Wl,--add-stdcall-alias -m32 -shared -o dist/libdt.dll class.o
To give an example, one of the undefined references is undefined refence to '_min_size' In class.c, however, it looks like:
if(min_size){ dsize=min_size; }
There is no underscore before the min_size in class.c. I’m sure this has something to do with my compile/link syntax but I just don’t see it. Any help is appreciated! Thanks!
PS: I’m using Netbeans and Cygwin.
The _ is just a prefix that the stdcall calling convention on windows requires, that the compiler adds.
If you have extern size_t min_size; , you’ve only declared the min_size. i.e. you’ve told the compiler that somewhere there will be a size_t min_size; defined. You have to actually define that variable somewhere (e.g. in your class.c, put size_t min_size; there.)