Originally Posted by
Codeplug
>> ... compiled using the gcc via Cygwin
Compile with "g++" for C++ code.
Compile with "gcc" for C code.
Thanks for the elucidation, Codeplug. To clarify, I am using *gcc* to compile my *C* code. The functions that I want to access within my C code, are coded in C++, and saved in the .dll that I'm currently trying to access.
You'll need to post your code and exactly how you're compiling it for additional help.
ok, here goes:
Code:
/* in global workspace */
HINSTANCE dll;
extern "C" __declspec(dll) bool (*fcn1WrapperPointer)(int numInputs, int numOutputs, char *fileName); /* line 38 */
fcn1WrapperPointer fcn1Wrapper; /* Pointer to "fcn1Wrapper" function within the .dll */ /* line 39 */
main(){
dll = LoadLibrary("myLibrary.dll");
if (dll != NULL)
fcn1Wrapper = (fcn1WrapperPointer)GetProcAddress(dll, "fcn1Wrapper");
fcn1(6, 6, "Setup_File.txt"); /* line 77 */
}
Here are the compiler errors I receive from attempting to compile the code above:
38: error: expected identifier or '(' before string constant
39: error: expected '=', ',' ,';' , 'asm' or '__attribute__' before 'fcn1Wrapper'
77: error: 'fcn1Wrapper' undeclared (first use in this function)
77: error: 'fcn1WrapperPointer' undeclared (first use in this function)
77: error: expected ';' before 'GetProcAddress'
I compile using a Makefile, which has the following contents:
Code:
# Makefile
# First, specify the compiler -
CC=gcc
# Now, some flags
CFLAGS=-O3 -ffast-math -fregmove -frerun-loop-opt -fpretend-float
# the following flags would allow gprof to be used to profile the code
CFLAGS=-g
# Specify Suffixes
.SUFFIXES: .o .c
PROJ=my_Ccode.o
my_Ccode: $(PROJ)
$(CC) -o $@ $(PROJ) -lm
clean:; @echo "Cleaning out object files..."
rm -f *.o
# Form the object files from their native C code
.c.o:; $(CC) $(CFLAGS) -c $*.c
I've tried moving things around (e.g. moving the 3 lines from the global workspace to the beginning of main(); calling LoadLibrary() within the global workspace, etc. etc.); however, none of these changes improves the compiler errors.
Thanks in advance if you can spot what's wrong with my code and/or compilation procedure.