extern int
proto_register_protocol(const char *name, const char *short_name, const char *filter_name);
[C++] only extern declaration for imported functions?
I'm building a program, which uses some import library.
I have successfully created .a import library (Dev-C++, GCC, Win32) using dlltool, but can't link correctly with my program.
I have found that include files (can't change them) for that library has functions in style of:
So there is no __declspec(import) (or else) declared.
When I change 'extern' to 'extern "C" __declspec(import)' my program links ok.
But I don't want to change headers. How can I force linker to find 'proto_register_protocol' in import libraries and not showing me 'undefined reference to'?
OK, the "extern "C" __declspec(import)" is doing two things. Firstly, the extern "C" is telling the compiler to use C-style function name decoration for this function as opposed to C++ style. The second bit, the "__declspec(import)" is telling the compiler/linker that the function is in a DLL that is to be found at run time. Your program may compile/link but I don't think it will run. To resolve this, you must add the library name to the list of inputs to the linker command line - how you do this is dependent on the environment you're using. I've not used Dev-C++ so you'll need to find out from somewhere else.
Skizz
Skizz
This topic is closed to new replies.
Advertisement
Popular Topics
Advertisement